mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-19 06:38:44 +00:00
SVG Options: Show in Browser opens the SVG in the default browser
The SVG export options on the help page list a Show in browser option beside Show Code, which displays the image in the default web browser: https://helpx.adobe.com/illustrator/desktop/save-and-export/export-files-to-different-formats/export-file-format-options-in-illustrator.html SVG Options gets a Show in Browser button beside Show Code. It writes the SVG of the dialog's current, unconfirmed choices for one page (the selection's crop under Export Selection, otherwise the first artboard the options choose) to a new folder inside "VectorCraft SVG Preview" in the system's temporary folder and opens it (file.export.svg.browser). The dialog stays open, the choices are not remembered, and nothing is written to the chosen file. The folder follows Save for Web's preview folders: a private folder per preview, and folders an hour old are removed; each kind removes only its own. The button is disabled on the web build, and control and MCP requests are refused, as Save for Web's Preview in Browser is. Show Code and Show in Browser share one encoding step, so Show Code changes in two ways. A range that OK refuses now shows OK's error: before, Show Code showed the first artboard's code for a range it could not read, and the first artboard named for a range such as "1, 9" when the document has no artboard 9. A range naming one missing artboard was already an error, with a different message. From Save As or Save a Copy, both keep hidden layers, as the save does. A document with no artboards shows the bounds of its art.
This commit is contained in:
@@ -143,6 +143,12 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
|
||||
"",
|
||||
"{} opens SVG Options; with params = document.export {path?, svg?: {…SVG options}, range?…} (a .svgz path writes it gzipped)",
|
||||
),
|
||||
(
|
||||
"file.export.svg.browser",
|
||||
"Show in Browser",
|
||||
"",
|
||||
"{svg?: {…SVG options}, exportSelection?} SVG Options' Show in Browser: write the SVG of one page (with exportSelection the selection's crop, else the first artboard the options choose) and its linked images to a new temporary folder and open it in the default browser (desktop; refused for control and MCP requests) → {path, warnings}",
|
||||
),
|
||||
("file.export.png", "Export As PNG…", "", "{path?, …document.export options}; no path: pick the file, then PNG Options"),
|
||||
(
|
||||
"file.exportForScreens",
|
||||
|
||||
@@ -237,29 +237,41 @@ pub(crate) fn browser_preview(app: &mut VectorcraftApp, p: &Value) -> Result<Val
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
const PREVIEW_KEEP: std::time::Duration = std::time::Duration::from_secs(3600);
|
||||
|
||||
/// The folder Save for Web's browser previews go to inside the system's temporary folder.
|
||||
const ROOT: &str = "VectorCraft Save for Web";
|
||||
|
||||
/// The folder a browser preview goes to: a new one for each preview, in the system's temporary
|
||||
/// folder ([`preview_folder_in`]).
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
/// folder ([`temp_folder_under`]).
|
||||
fn temp_folder() -> Result<String, String> {
|
||||
preview_folder_in(&std::env::temp_dir(), PREVIEW_KEEP)
|
||||
temp_folder_under(ROOT)
|
||||
}
|
||||
|
||||
/// The name of a folder that a preview made in the temporary folder, beside a `VectorCraft Save
|
||||
/// for Web` it couldn't use, before the process id and the count.
|
||||
/// A new folder for a browser preview in the system's temporary folder, under the folder named
|
||||
/// `root` ([`preview_folder_under`]).
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
const BESIDE: &str = "VectorCraft Save for Web ";
|
||||
pub(super) fn temp_folder_under(root: &str) -> Result<String, String> {
|
||||
preview_folder_under(&std::env::temp_dir(), root, PREVIEW_KEEP)
|
||||
}
|
||||
|
||||
/// A new folder for a browser preview in the temporary folder `tmp`: inside `VectorCraft Save for
|
||||
/// Web` ([`preview_folder`]), or, when that folder can't be used, directly in `tmp`, named
|
||||
/// [`BESIDE`] followed by the process id and a count. The log says why the shared folder wasn't
|
||||
/// used. Each preview first removes the folders of that name in `tmp` last changed `keep` or longer
|
||||
/// ago ([`remove_old`]).
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
/// A new folder for a Save for Web browser preview in the temporary folder `tmp`
|
||||
/// ([`preview_folder_under`] with `VectorCraft Save for Web`).
|
||||
#[cfg(all(test, not(target_arch = "wasm32")))]
|
||||
pub(super) fn preview_folder_in(tmp: &std::path::Path, keep: std::time::Duration) -> Result<String, String> {
|
||||
remove_old(tmp, BESIDE, keep);
|
||||
preview_folder(&tmp.join("VectorCraft Save for Web"), keep).or_else(|e| {
|
||||
log::warn!("vectorcraft: Preview in Browser can't use {e}, so the preview goes to a new folder of its own");
|
||||
new_folder(tmp, BESIDE)
|
||||
preview_folder_under(tmp, ROOT, keep)
|
||||
}
|
||||
|
||||
/// A new folder for a browser preview in the temporary folder `tmp`: inside the folder named `root`
|
||||
/// ([`preview_folder`]), or, when that folder can't be used, directly in `tmp`, named `root`, a
|
||||
/// space, the process id and a count. The log says why the shared folder wasn't used. Each preview
|
||||
/// first removes the folders of that name in `tmp` last changed `keep` or longer ago
|
||||
/// ([`remove_old`]). Previews under one `root` never remove the folders of another.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub(super) fn preview_folder_under(tmp: &std::path::Path, root: &str, keep: std::time::Duration) -> Result<String, String> {
|
||||
let beside = format!("{root} ");
|
||||
remove_old(tmp, &beside, keep);
|
||||
preview_folder(&tmp.join(root), keep).or_else(|e| {
|
||||
log::warn!("vectorcraft: a browser preview can't use {e}, so the preview goes to a new folder of its own");
|
||||
new_folder(tmp, &beside)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -381,7 +393,7 @@ fn is_preview_name(name: &std::ffi::OsStr, prefix: &str) -> bool {
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
fn temp_folder() -> Result<String, String> {
|
||||
pub(super) fn temp_folder_under(_: &str) -> Result<String, String> {
|
||||
Err("no file system here".into())
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
//! SVG Options (Export As SVG, Save As / Save a Copy to .svg): profile, styling, fonts, images,
|
||||
//! object ids, decimals, encoding, minify, responsive, embedded fonts, artboards (export) or
|
||||
//! editing data (save), and a read-only view of the code. OK remembers the choices for next time and runs the export or save command with
|
||||
//! them as `svg: {…}`.
|
||||
//! them as `svg: {…}`. Show in Browser (`file.export.svg.browser`) writes the SVG the choices give
|
||||
//! to a temporary folder and opens it in the default browser, leaving the dialog open.
|
||||
|
||||
use std::borrow::Cow;
|
||||
use std::sync::Arc;
|
||||
|
||||
use serde_json::{Map, Value, json};
|
||||
use vectorcraft_engine::cmd::fileio;
|
||||
|
||||
use super::DialogSpec;
|
||||
use crate::state::Dialog;
|
||||
use crate::theme::{self, Tokens};
|
||||
use crate::{VectorcraftApp, widgets};
|
||||
use crate::{VectorcraftApp, io, widgets};
|
||||
|
||||
pub(super) const SPEC: DialogSpec = DialogSpec {
|
||||
heading: |_| tl!("SVG Options").into(),
|
||||
@@ -26,6 +29,12 @@ pub(super) const SPEC: DialogSpec = DialogSpec {
|
||||
/// `Dialog::kind` of this dialog.
|
||||
pub const KIND: &str = "svgOptions";
|
||||
|
||||
/// The UI command of the dialog's Show in Browser button.
|
||||
pub const BROWSER: &str = "file.export.svg.browser";
|
||||
|
||||
/// The folder in the system's temporary folder that Show in Browser's previews go to.
|
||||
const PREVIEW_ROOT: &str = "VectorCraft SVG Preview";
|
||||
|
||||
/// What OK does: Export As SVG, Save As or Save a Copy.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum Mode {
|
||||
@@ -196,8 +205,16 @@ fn body(app: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) -> bool {
|
||||
}
|
||||
ui.add_space(10.0);
|
||||
let show = d.bool("showCode");
|
||||
if widgets::secondary_button(ui, if show { tl!("Hide Code") } else { tl!("Show Code") }).clicked() {
|
||||
d.fields.insert("showCode".into(), json!(!show));
|
||||
let mut browser = false;
|
||||
ui.horizontal(|ui| {
|
||||
if widgets::secondary_button(ui, if show { tl!("Hide Code") } else { tl!("Show Code") }).clicked() {
|
||||
d.fields.insert("showCode".into(), json!(!show));
|
||||
}
|
||||
let b = ui.add_enabled(!io::is_web(app), |ui: &mut egui::Ui| widgets::secondary_button(ui, tl!("Show in Browser")));
|
||||
browser = b.on_disabled_hover_text(tl!("Needs the desktop app")).clicked();
|
||||
});
|
||||
if browser && let Err(e) = app.run(BROWSER, preview_params(d)) {
|
||||
app.status(e);
|
||||
}
|
||||
if show {
|
||||
ui.add_space(6.0);
|
||||
@@ -269,6 +286,102 @@ fn artboards(app: &VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) {
|
||||
});
|
||||
}
|
||||
|
||||
/// The SVG options the dialog `d`'s OK writes with: [`options`], with hidden layers kept (not
|
||||
/// displayed) when OK saves, as a save keeps them unless told otherwise.
|
||||
fn written_options(d: &Dialog) -> Value {
|
||||
let mut o = options(d);
|
||||
if Mode::of(d) != Mode::Export
|
||||
&& let Some(m) = o.as_object_mut()
|
||||
{
|
||||
m.entry("hiddenLayers").or_insert(json!(true));
|
||||
}
|
||||
o
|
||||
}
|
||||
|
||||
/// The params of [`BROWSER`] for the dialog `d`: the SVG options OK writes with
|
||||
/// ([`written_options`]), and `exportSelection` when Export Selection opened it.
|
||||
fn preview_params(d: &Dialog) -> Value {
|
||||
super::export_as::exported(d, json!({ "svg": written_options(d) }))
|
||||
}
|
||||
|
||||
/// The SVG file that the SVG options `svg` write for one page of the document `st`, and the
|
||||
/// document it is drawn from. With `selection` (Export Selection) the page is the selection alone,
|
||||
/// cropped to it. Otherwise it is the first artboard the options choose, checked against the
|
||||
/// document's artboards as OK checks them, or what the options write without artboards (also for
|
||||
/// a document that has none). Linked scripts and images are checked against the read roots in
|
||||
/// force first.
|
||||
fn encode_page<'a>(
|
||||
st: &'a vectorcraft_engine::DocState,
|
||||
svg: &Value,
|
||||
selection: bool,
|
||||
) -> Result<(Cow<'a, vectorcraft_doc::Document>, fileio::Encoded), String> {
|
||||
let mut opts = svg.clone();
|
||||
if let Some(o) = opts.as_object_mut() {
|
||||
if selection {
|
||||
// Export Selection writes one crop, without artboards to choose.
|
||||
for k in fileio::ARTBOARD_PARAMS.iter().chain(&["useArtboards"]) {
|
||||
o.remove(*k);
|
||||
}
|
||||
} else if st.doc.artboards.is_empty() {
|
||||
for k in fileio::ARTBOARD_PARAMS {
|
||||
o.remove(k);
|
||||
}
|
||||
} else {
|
||||
let pick: fileio::ArtboardPick = serde_json::from_value(Value::Object(o.clone())).map_err(|e| e.to_string())?;
|
||||
if let Some(first) = pick.resolve(st.doc.artboards.len())?.and_then(|v| v.first().copied()) {
|
||||
for k in fileio::ARTBOARD_PARAMS {
|
||||
o.remove(k);
|
||||
}
|
||||
o.insert("artboard".into(), json!(first));
|
||||
}
|
||||
}
|
||||
}
|
||||
let params = json!({ "svg": opts });
|
||||
fileio::check_linked_scripts("document.export", "svg", st, ¶ms).map_err(|e| e.to_string())?;
|
||||
let doc = if selection {
|
||||
Cow::Owned(fileio::selection_doc(st, "document.exportSelection", false).map_err(|e| e.to_string())?.0)
|
||||
} else {
|
||||
Cow::Borrowed(&*st.doc)
|
||||
};
|
||||
fileio::check_linked_images("document.export", "svg", st, &doc, ¶ms).map_err(|e| e.to_string())?;
|
||||
let enc = fileio::encode_all(&doc, "svg", ¶ms).map_err(|e| e.to_string())?;
|
||||
Ok((doc, enc))
|
||||
}
|
||||
|
||||
/// `file.export.svg.browser {svg?, exportSelection?}` (SVG Options' Show in Browser): the SVG file
|
||||
/// that the SVG options `svg` write for one page ([`encode_page`]), written with its linked images
|
||||
/// to a new folder inside `VectorCraft SVG Preview` in the system's temporary folder and opened in
|
||||
/// the default browser (desktop) → `{path, warnings}`. Nothing is written to the chosen
|
||||
/// destination, and the document, its path and the remembered choices are left as they were.
|
||||
/// When the export has warnings, the status bar shows them as [`io::report_saved`] shows a save's
|
||||
/// notes. Nothing opens when a check, the encoding or a write fails.
|
||||
pub(crate) fn browser_preview(app: &mut VectorcraftApp, p: &Value) -> Result<Value, String> {
|
||||
if io::is_web(app) {
|
||||
return Err("no file system here".into());
|
||||
}
|
||||
app.refuse_automation(BROWSER)?;
|
||||
let (selection, p) = io::take_selection(p)?;
|
||||
let svg = p.get("svg").cloned().unwrap_or_else(|| json!({}));
|
||||
let (path, warnings) = {
|
||||
let st = app.session.active().ok_or("no document")?;
|
||||
let stem = fileio::file_stem(&st.doc.title);
|
||||
let (doc, enc) = encode_page(st, &svg, selection)?;
|
||||
let dir = super::save_for_web::temp_folder_under(PREVIEW_ROOT)?;
|
||||
let target = format!("{dir}/{}.svg", super::save_for_web::preview_name(&stem));
|
||||
let named = enc.named(&doc, &target);
|
||||
for (p, bytes) in &named {
|
||||
io::write_to(&mut app.services, p, bytes)?;
|
||||
}
|
||||
(named.first().map_or(target, |(p, _)| p.clone()), enc.notes())
|
||||
};
|
||||
app.open_url(&io::file_url(&path));
|
||||
let r = json!({ "path": path, "warnings": warnings });
|
||||
if !warnings.is_empty() {
|
||||
io::report_saved(app, &path, &r);
|
||||
}
|
||||
Ok(r)
|
||||
}
|
||||
|
||||
/// The SVG the current options write for the first chosen artboard, or under Export Selection for
|
||||
/// the selection alone, cropped to it (read-only, selectable), encoded again only when the
|
||||
/// options, the document or the selection change.
|
||||
@@ -276,19 +389,7 @@ fn code_view(app: &VectorcraftApp, ui: &mut egui::Ui, d: &Dialog) {
|
||||
let t = Tokens::get(ui.ctx());
|
||||
let Some(st) = app.session.active() else { return };
|
||||
let selection = d.bool(super::export_as::SELECTION_FIELD);
|
||||
let mut opts = options(d);
|
||||
if let Some(o) = opts.as_object_mut() {
|
||||
if selection {
|
||||
// Export Selection writes one crop, without artboards to choose.
|
||||
for k in vectorcraft_engine::cmd::fileio::ARTBOARD_PARAMS.iter().chain(&["useArtboards"]) {
|
||||
o.remove(*k);
|
||||
}
|
||||
} else if let Some(r) = o.remove("range") {
|
||||
// The first artboard of the range (or the first one).
|
||||
let first = r.as_str().and_then(|r| r.split([',', '-', '\u{2013}']).next()).and_then(|n| n.trim().parse::<usize>().ok());
|
||||
o.insert("artboard".into(), json!(first.map_or(0, |n| n.saturating_sub(1))));
|
||||
}
|
||||
}
|
||||
let opts = written_options(d);
|
||||
// One cached text, replaced when the document, the options or the selection change.
|
||||
let key = egui::Id::unique("svg-code");
|
||||
// The read roots in force and the document's folder decide whether the text may be shown.
|
||||
@@ -299,27 +400,15 @@ fn code_view(app: &VectorcraftApp, ui: &mut egui::Ui, d: &Dialog) {
|
||||
Some((_, c)) => c,
|
||||
None => {
|
||||
const MAX: usize = 200_000;
|
||||
let params = json!({ "svg": opts });
|
||||
let encoded = vectorcraft_engine::cmd::fileio::check_linked_scripts("document.export", "svg", st, ¶ms).and_then(|()| {
|
||||
let selected;
|
||||
let doc = if selection {
|
||||
selected = vectorcraft_engine::cmd::fileio::selection_doc(st, "document.exportSelection", false)?.0;
|
||||
&selected
|
||||
} else {
|
||||
&st.doc
|
||||
};
|
||||
vectorcraft_engine::cmd::fileio::check_linked_images("document.export", "svg", st, doc, ¶ms)?;
|
||||
vectorcraft_engine::cmd::fileio::encode_all(doc, "svg", ¶ms)
|
||||
});
|
||||
let mut text = match encoded {
|
||||
let mut text = match encode_page(st, &opts, selection) {
|
||||
// Shown as text whatever the file's encoding.
|
||||
Ok(enc) => enc
|
||||
Ok((_, enc)) => enc
|
||||
.files
|
||||
.into_iter()
|
||||
.next()
|
||||
.map(|(_, b)| vectorcraft_svg::text_of(&b).map_or_else(|_| String::from_utf8_lossy(&b).into_owned(), |t| t.into_owned()))
|
||||
.unwrap_or_default(),
|
||||
Err(e) => e.to_string(),
|
||||
Err(e) => e,
|
||||
};
|
||||
if text.len() > MAX {
|
||||
let cut = (0..=MAX).rev().find(|i| text.is_char_boundary(*i)).unwrap_or(0);
|
||||
@@ -389,6 +478,153 @@ mod tests {
|
||||
String::from_utf8(w.borrow()[i].1.clone()).unwrap()
|
||||
}
|
||||
|
||||
type Opened = Rc<RefCell<Vec<String>>>;
|
||||
|
||||
/// [`app`] whose browser records each URL it is asked to open.
|
||||
fn browsing(picked: &str) -> (VectorcraftApp, Written, Opened) {
|
||||
let (mut app, written) = app(picked);
|
||||
let opened = Opened::default();
|
||||
let o = opened.clone();
|
||||
app.services.open_url = Some(Box::new(move |u: &str| o.borrow_mut().push(u.to_string())));
|
||||
(app, written, opened)
|
||||
}
|
||||
|
||||
/// Show in Browser for the open dialog's current choices, as its button runs it.
|
||||
fn show_in_browser(app: &mut VectorcraftApp) -> Result<Value, String> {
|
||||
let p = preview_params(app.ui.dialog.as_ref().expect("SVG Options open"));
|
||||
app.run(BROWSER, p)
|
||||
}
|
||||
|
||||
/// Show in Browser writes the SVG of the dialog's current, unconfirmed choices for the first
|
||||
/// artboard of the range to a new temporary folder and opens that file once. The dialog stays
|
||||
/// open, nothing is remembered, and OK then writes the same SVG to the chosen file.
|
||||
#[test]
|
||||
fn show_in_browser_opens_what_ok_writes_without_confirming() {
|
||||
let (mut app, written, opened) = browsing("/tmp/out.svg");
|
||||
app.run("file.export.svg", Value::Null).unwrap();
|
||||
frame(&mut app);
|
||||
let f = &mut app.ui.dialog.as_mut().unwrap().fields;
|
||||
f.insert("decimals".into(), json!(1));
|
||||
f.insert("allArtboards".into(), json!(false));
|
||||
f.insert("range".into(), json!("2"));
|
||||
let remembered = app.ui.svg_options.clone();
|
||||
let r = show_in_browser(&mut app).unwrap_or_else(|e| panic!("{e}"));
|
||||
let path = r["path"].as_str().unwrap().to_string();
|
||||
assert!(path.contains("/VectorCraft SVG Preview/") && path.ends_with("/Untitled-1.svg"), "{path}");
|
||||
assert_eq!(*opened.borrow(), [io::file_url(&path)]);
|
||||
assert_eq!(written.borrow().len(), 1);
|
||||
assert_eq!(written.borrow()[0].0, path);
|
||||
assert_eq!(app.ui.dialog.as_ref().map(|d| d.kind.as_str()), Some(KIND), "the dialog stays open");
|
||||
assert_eq!(app.ui.svg_options, remembered, "nothing is remembered");
|
||||
assert!(app.session.active().unwrap().path.is_none());
|
||||
frame(&mut app);
|
||||
super::super::confirm(&mut app).unwrap();
|
||||
assert_eq!(written.borrow()[1].0, "/tmp/out.svg");
|
||||
assert_eq!(text(&written, 0), text(&written, 1), "the preview is the file OK writes");
|
||||
assert_eq!(opened.borrow().len(), 1);
|
||||
}
|
||||
|
||||
/// A range the document has no artboard for is refused, as OK refuses it: nothing is written
|
||||
/// or opened, and the dialog stays open.
|
||||
#[test]
|
||||
fn show_in_browser_refuses_a_range_the_document_lacks() {
|
||||
let (mut app, written, opened) = browsing("/tmp/out.svg");
|
||||
app.run("file.export.svg", Value::Null).unwrap();
|
||||
let f = &mut app.ui.dialog.as_mut().unwrap().fields;
|
||||
f.insert("allArtboards".into(), json!(false));
|
||||
f.insert("range".into(), json!("5"));
|
||||
assert!(show_in_browser(&mut app).is_err());
|
||||
assert!(written.borrow().is_empty() && opened.borrow().is_empty());
|
||||
assert!(app.ui.dialog.is_some());
|
||||
}
|
||||
|
||||
/// Under Export Selection the preview is the selection alone, cropped to it, as OK writes it.
|
||||
#[test]
|
||||
fn show_in_browser_under_export_selection_shows_the_selection() {
|
||||
let (mut app, written, opened) = browsing("/tmp/selection.svg");
|
||||
app.run("shape.rectangle", json!({"x": 70, "y": 40, "width": 20, "height": 20})).unwrap();
|
||||
app.run("document.exportSelection", Value::Null).unwrap();
|
||||
assert!(app.ui.dialog.as_ref().unwrap().bool(super::super::export_as::SELECTION_FIELD));
|
||||
show_in_browser(&mut app).unwrap_or_else(|e| panic!("{e}"));
|
||||
super::super::confirm(&mut app).unwrap();
|
||||
assert_eq!(written.borrow()[1].0, "/tmp/selection.svg");
|
||||
assert_eq!(text(&written, 0), text(&written, 1));
|
||||
assert_eq!(text(&written, 0).matches("<rect").count(), 1, "{}", text(&written, 0));
|
||||
assert_eq!(opened.borrow().len(), 1);
|
||||
}
|
||||
|
||||
/// From Save As, the preview leaves the document's path and unsaved state alone, and OK still
|
||||
/// saves to the chosen file.
|
||||
#[test]
|
||||
fn show_in_browser_from_save_as_leaves_the_document_unsaved() {
|
||||
let (mut app, written, opened) = browsing("/tmp/doc.svg");
|
||||
app.run("file.saveAs", Value::Null).unwrap();
|
||||
let dirty = app.session.active().unwrap().is_dirty();
|
||||
show_in_browser(&mut app).unwrap_or_else(|e| panic!("{e}"));
|
||||
let st = app.session.active().unwrap();
|
||||
assert_eq!((st.path.as_deref(), st.is_dirty()), (None, dirty));
|
||||
assert_eq!(opened.borrow().len(), 1);
|
||||
super::super::confirm(&mut app).unwrap();
|
||||
assert_eq!(written.borrow()[1].0, "/tmp/doc.svg");
|
||||
assert_eq!(app.session.active().unwrap().path.as_deref(), Some("/tmp/doc.svg"));
|
||||
}
|
||||
|
||||
/// From Save As, a hidden layer is in the preview, kept hidden, as the save keeps it. The two
|
||||
/// differ only in the title: the save takes it from the file's name, the preview from the
|
||||
/// document's.
|
||||
#[test]
|
||||
fn show_in_browser_from_save_as_keeps_hidden_layers_as_the_save_does() {
|
||||
let (mut app, written, _) = browsing("/tmp/doc.svg");
|
||||
let notes = app.run("layer.new", json!({"name": "Notes"})).unwrap()["id"].clone();
|
||||
app.run("shape.ellipse", json!({"x": 60, "y": 10, "width": 20, "height": 20})).unwrap();
|
||||
app.run("layer.setProps", json!({"id": notes, "visible": false})).unwrap();
|
||||
app.run("file.saveAs", Value::Null).unwrap();
|
||||
show_in_browser(&mut app).unwrap_or_else(|e| panic!("{e}"));
|
||||
super::super::confirm(&mut app).unwrap();
|
||||
assert!(text(&written, 0).contains("id=\"Notes\""), "{}", text(&written, 0));
|
||||
assert_eq!(text(&written, 0).replace("<title>Untitled-1</title>", "<title>doc</title>"), text(&written, 1));
|
||||
}
|
||||
|
||||
/// A document with no artboards is previewed by the bounds of its art, as the SVG writer
|
||||
/// writes it, rather than refused for its artboard range.
|
||||
#[test]
|
||||
fn show_in_browser_previews_a_document_without_artboards() {
|
||||
let (mut app, written, opened) = browsing("/tmp/out.svg");
|
||||
app.run("file.export.svg", Value::Null).unwrap();
|
||||
std::sync::Arc::make_mut(&mut app.session.doc_mut().unwrap().doc).artboards.clear();
|
||||
show_in_browser(&mut app).unwrap_or_else(|e| panic!("{e}"));
|
||||
assert_eq!(vectorcraft_testkit::svg_shapes(&text(&written, 0)), 1, "{}", text(&written, 0));
|
||||
assert_eq!(opened.borrow().len(), 1);
|
||||
}
|
||||
|
||||
/// The web build has no file to open, and a control or MCP request may not open another app:
|
||||
/// both are refused before anything is written or opened.
|
||||
#[test]
|
||||
fn show_in_browser_is_refused_on_the_web_and_for_automation() {
|
||||
let (mut app, written, opened) = browsing("/tmp/out.svg");
|
||||
app.run("file.export.svg", Value::Null).unwrap();
|
||||
app.ui.answering_control = true;
|
||||
assert!(show_in_browser(&mut app).unwrap_err().contains("opens another app"));
|
||||
app.ui.answering_control = false;
|
||||
app.services.download = Some(Box::new(|_: &str, _: &[u8]| Ok(())));
|
||||
assert!(show_in_browser(&mut app).is_err());
|
||||
assert!(written.borrow().is_empty() && opened.borrow().is_empty());
|
||||
}
|
||||
|
||||
/// SVG previews have their own folder: making one removes only old SVG preview folders and
|
||||
/// leaves Save for Web's alone.
|
||||
#[test]
|
||||
fn svg_preview_folders_leave_save_for_web_previews_alone() {
|
||||
let tmp = vectorcraft_testkit::temp_dir("svg-preview-folders");
|
||||
let web = super::super::save_for_web::preview_folder_in(&tmp, std::time::Duration::from_secs(3600)).unwrap();
|
||||
let old = super::super::save_for_web::preview_folder_under(&tmp, PREVIEW_ROOT, std::time::Duration::from_secs(3600)).unwrap();
|
||||
let new = super::super::save_for_web::preview_folder_under(&tmp, PREVIEW_ROOT, std::time::Duration::ZERO).unwrap();
|
||||
assert!(new.contains("/VectorCraft SVG Preview/"), "{new}");
|
||||
assert!(std::path::Path::new(&web).is_dir(), "Save for Web's preview is kept");
|
||||
assert!(!std::path::Path::new(&old).exists(), "the old SVG preview is removed");
|
||||
assert!(std::path::Path::new(&new).is_dir());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn export_as_svg_opens_the_options_and_remembers_them() {
|
||||
let (mut app, written) = app("/tmp/out.svg");
|
||||
|
||||
@@ -3430,6 +3430,7 @@ digits Malayalam Малаялам
|
||||
Show Brush Size Показване на размера на четката
|
||||
Show Center Показване на център
|
||||
Show Code Показване на код
|
||||
Show in Browser Показване в браузър
|
||||
Show Color Groups Показване на цътни групи
|
||||
Show Color Swatches Показване на цветни образци
|
||||
Show Corner Widget Показване на уиджета за ъгъл
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3238,6 +3238,7 @@ antiAlias Sharp Oštro
|
||||
Preserve Editing Capabilities Očuvaj mogućnosti uređivanja
|
||||
Responsive Responzivno
|
||||
Show Code Prikaži kod
|
||||
Show in Browser Prikaži u pregledniku
|
||||
Style Attributes Atributi stila
|
||||
Style Attributes (Entity References) Atributi stila (reference entiteta)
|
||||
Styling: Stilizovanje:
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -4469,6 +4469,7 @@ digits Malayalam Malaiàlam
|
||||
Show Center Mostra el centre
|
||||
Show Center Mark Mostra la marca del centre
|
||||
Show Code Mostra el codi
|
||||
Show in Browser Mostra al navegador
|
||||
Show Color Groups Mostra els grups de colors
|
||||
Show Color Swatches Mostra les mostres de color
|
||||
Show Corner Widget Mostra el giny de cantonada
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -3322,6 +3322,7 @@ antiAlias Sharp Ostré
|
||||
Preserve Editing Capabilities Zachovat možnosti úprav
|
||||
Responsive Responzivní
|
||||
Show Code Zobrazit kód
|
||||
Show in Browser Zobrazit v prohlížeči
|
||||
Style Attributes Atributy stylu
|
||||
Style Attributes (Entity References) Atributy stylu (odkazy na entity)
|
||||
Styling: Stylování:
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -5795,6 +5795,7 @@ antiAlias Sharp Skarp
|
||||
Preserve Editing Capabilities Bevar redigeringsfunktioner
|
||||
Responsive Responsiv
|
||||
Show Code Vis kode
|
||||
Show in Browser Vis i browser
|
||||
Style Attributes Stilattributter
|
||||
Style Attributes (Entity References) Stilattributter (enhedsreferencer)
|
||||
Styling: Styling:
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3496,6 +3496,7 @@ digits Malayalam Malayalam
|
||||
Show Brush Size Pinselgröße anzeigen
|
||||
Show Center Mittelpunkt anzeigen
|
||||
Show Code Code einblenden
|
||||
Show in Browser Im Browser anzeigen
|
||||
Show Color Groups Farbgruppen einblenden
|
||||
Show Color Swatches Farbfelder einblenden
|
||||
Show Corner Widget Ecken-Widget einblenden
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -4177,6 +4177,7 @@ digits Malayalam Μαλαγιάλαμ
|
||||
Show Brush Size Εμφάνιση μεγέθους πινέλου
|
||||
Show Center Εμφάνιση κέντρου
|
||||
Show Code Εμφάνιση κώδικα
|
||||
Show in Browser Εμφάνιση στο πρόγραμμα περιήγησης
|
||||
Show Color Groups Εμφάνιση ομάδων χρωμάτων
|
||||
Show Color Swatches Εμφάνιση δειγμάτων χρωμάτων
|
||||
Show Corner Widget Εμφάνιση στοιχείου γωνιών
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3532,6 +3532,7 @@ digits Malayalam Malayálam
|
||||
Show Brush Size Mostrar tamaño del pincel
|
||||
Show Center Mostrar centro
|
||||
Show Code Mostrar código
|
||||
Show in Browser Mostrar en el navegador
|
||||
Show Color Groups Mostrar grupos de colores
|
||||
Show Color Swatches Mostrar muestras de color
|
||||
Show Corner Widget Mostrar widget de esquina
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -3266,6 +3266,7 @@ antiAlias Sharp Terävä
|
||||
Preserve Editing Capabilities Säilytä muokkausominaisuudet
|
||||
Responsive Responsiivinen
|
||||
Show Code Näytä koodi
|
||||
Show in Browser Näytä selaimessa
|
||||
Style Attributes Tyyliattribuutit
|
||||
Style Attributes (Entity References) Tyyliattribuutit (entiteettiviittaukset)
|
||||
Styling: Tyylit:
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -3520,6 +3520,7 @@ digits Malayalam Malayalam
|
||||
Show Brush Size Afficher la taille de la forme
|
||||
Show Center Afficher le centre
|
||||
Show Code Afficher le code
|
||||
Show in Browser Afficher dans le navigateur
|
||||
Show Color Groups Afficher les groupes de couleurs
|
||||
Show Color Swatches Afficher les nuances de couleur
|
||||
Show Corner Widget Afficher le widget d’angle
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3663,6 +3663,7 @@
|
||||
Show Center કેન્દ્ર બતાવો
|
||||
Show Center Mark કેન્દ્ર ચિહ્ન બતાવો
|
||||
Show Code કોડ બતાવો
|
||||
Show in Browser બ્રાઉઝરમાં બતાવો
|
||||
Show Corner Widget કોર્નર વિજેટ બતાવો
|
||||
Show Cross Hairs ક્રોસ હેર બતાવો
|
||||
Show East Asian Options પૂર્વ એશિયન વિકલ્પો બતાવો
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 72 and column 5.
|
@@ -4792,6 +4792,7 @@ antiAlias Sharp शार्प
|
||||
Show Center केंद्र दिखाएँ
|
||||
Show Center Mark शो सेंटर मार्क
|
||||
Show Code कोड दिखाएं
|
||||
Show in Browser ब्राउज़र में दिखाएँ
|
||||
Show color bars रंग सलाखों दिखाएँ
|
||||
Show brightness and hue on wheel व्हील पर ब्राइटनेस और ह्यू दिखाएँ
|
||||
Show saturation and hue on wheel व्हील पर सैचुरेशन और ह्यू दिखाएँ
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -4184,6 +4184,7 @@ mark-style Japanese Japán
|
||||
Show Brush Size Ecsetméret megjelenítése
|
||||
Show Center Középpont megjelenítése
|
||||
Show Code Kód megjelenítése
|
||||
Show in Browser Megjelenítés böngészőben
|
||||
Show Color Groups Színcsoportok megjelenítése
|
||||
Show Color Swatches Színes színminták megjelenítése
|
||||
Show Corner Widget Sarokfogantyú megjelenítése
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3047,6 +3047,7 @@ antiAlias Sharp Tajam
|
||||
Preserve Editing Capabilities Pertahankan kemampuan pengeditan
|
||||
Responsive Responsif
|
||||
Show Code Tampilkan kode
|
||||
Show in Browser Tampilkan di browser
|
||||
Style Attributes Atribut gaya
|
||||
Style Attributes (Entity References) Atribut gaya (referensi entitas)
|
||||
Styling: Penataan gaya:
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2511 and column 5.
|
@@ -3577,6 +3577,7 @@ digits Malayalam Malayalam
|
||||
Show Brush Size Mostra dimensione pennello
|
||||
Show Center Mostra centro
|
||||
Show Code Mostra codice
|
||||
Show in Browser Mostra nel browser
|
||||
Show Color Groups Mostra gruppi colori
|
||||
Show Color Swatches Mostra campioni colore
|
||||
Show Corner Widget Mostra widget angolo
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3391,6 +3391,7 @@ mark-style Japanese 日本式
|
||||
Show Brush Size ブラシサイズを表示
|
||||
Show Center 中心を表示
|
||||
Show Code コードを表示
|
||||
Show in Browser ブラウザーで表示
|
||||
Show East Asian Options 東アジアのオプションを表示
|
||||
Show Find Field 検索フィールドを表示
|
||||
Show Font Names in English フォント名を英語で表示
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -5136,6 +5136,7 @@ antiAlias Sharp მკვეთრი
|
||||
Preserve Editing Capabilities რედაქტირების შესაძლებლობების შენარჩუნება
|
||||
Responsive ადაპტური
|
||||
Show Code კოდის ჩვენება
|
||||
Show in Browser ბრაუზერში ჩვენება
|
||||
Style Attributes სტილის ატრიბუტები
|
||||
Style Attributes (Entity References) სტილის ატრიბუტები (ერთეულის მიმართვები)
|
||||
Styling: სტილი:
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3380,6 +3380,7 @@ mark-style Japanese 일본식
|
||||
Show Brush Size 브러시 크기 표시
|
||||
Show Center 중심 표시
|
||||
Show Code 코드 표시
|
||||
Show in Browser 브라우저에서 보기
|
||||
Show East Asian Options 동아시아 옵션 표시
|
||||
Show Find Field 찾기 필드 표시
|
||||
Show Font Names in English 글꼴 이름을 영어로 표시
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3669,6 +3669,7 @@ antiAlias Sharp Scherp
|
||||
Preserve Editing Capabilities Bewerkbaarheid behouden
|
||||
Responsive Responsive
|
||||
Show Code Code weergeven
|
||||
Show in Browser Tonen in browser
|
||||
Style Attributes Stijlattributen
|
||||
Style Attributes (Entity References) Stijlattributen (entiteitsverwijzingen)
|
||||
Styling: Stijl:
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3207,6 +3207,7 @@ antiAlias Sharp Ostre
|
||||
Preserve Editing Capabilities Zachowaj możliwości edycji
|
||||
Responsive Responsywny
|
||||
Show Code Pokaż kod
|
||||
Show in Browser Pokaż w przeglądarce
|
||||
Style Attributes Atrybuty stylu
|
||||
Style Attributes (Entity References) Atrybuty stylu (odwołania do encji)
|
||||
Styling: Stylizacja:
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2975,6 +2975,7 @@ digits Malayalam Malaiala
|
||||
Show Brush Size Mostrar Tamanho do Pincel
|
||||
Show Center Mostrar Centro
|
||||
Show Code Mostrar Código
|
||||
Show in Browser Mostrar no Navegador
|
||||
Show Corner Widget Mostrar Widget de Canto
|
||||
Show East Asian Options Mostrar Opções do Leste Asiático
|
||||
Show Edges Mostrar Bordas
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3564,6 +3564,7 @@ digits Malayalam Малаялам
|
||||
Show Brush Size Показать размер кисти
|
||||
Show Center Показать центр
|
||||
Show Code Показать код
|
||||
Show in Browser Показать в браузере
|
||||
Show Color Groups Показать цветовые группы
|
||||
Show Color Swatches Показать цветовые образцы
|
||||
Show Corner Widget Показать угловой виджет
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3450,6 +3450,7 @@ digits Malayalam Malayalam
|
||||
Show Brush Size Visa penselstorlek
|
||||
Show Center Visa mittpunkt
|
||||
Show Code Visa kod
|
||||
Show in Browser Visa i webbläsare
|
||||
Show Color Groups Visa färggrupper
|
||||
Show Color Swatches Visa färgrutor
|
||||
Show Corner Widget Visa hörnwidget
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3322,6 +3322,7 @@ digits Malayalam Malayalam
|
||||
Show Brush Size Fırça Boyutunu Göster
|
||||
Show Center Gösteri Merkezi
|
||||
Show Code Kodu Göster
|
||||
Show in Browser Tarayıcıda Göster
|
||||
Show Color Groups Renk Gruplarını Göster
|
||||
Show Color Swatches Renk Örneklerini Göster
|
||||
Show Corner Widget Köşe Widget'ını Göster
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3569,6 +3569,7 @@ digits Malayalam Малаялам
|
||||
Show Brush Size Показати розмір пензля
|
||||
Show Center Показати центр
|
||||
Show Code Показати код
|
||||
Show in Browser Показати у браузері
|
||||
Show Color Groups Показати групи кольорів
|
||||
Show Color Swatches Показати колірні зразки
|
||||
Show Corner Widget Показати кутовий віджет
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3934,6 +3934,7 @@ mark-style Japanese Kiểu Nhật
|
||||
Show Brush Size Hiện kích thước cọ
|
||||
Show Center Hiện tâm
|
||||
Show Code Hiện mã
|
||||
Show in Browser Hiện trong trình duyệt
|
||||
Show Color Groups Hiện nhóm màu
|
||||
Show Color Swatches Hiện mẫu màu
|
||||
Show Corner Widget Hiện widget góc
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 205 and column 5.
|
@@ -3392,6 +3392,7 @@ digits Malayalam 马拉雅拉姆数字
|
||||
Show Brush Size 显示画笔大小
|
||||
Show Center 显示中心点
|
||||
Show Code 显示代码
|
||||
Show in Browser 在浏览器中显示
|
||||
Show Color Groups 显示颜色组
|
||||
Show Color Swatches 显示颜色色板
|
||||
Show Corner Widget 显示转角 Widget
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -4710,6 +4710,7 @@ digits Malayalam 馬來亞拉姆數字
|
||||
Show Brush Size 顯示筆刷大小
|
||||
Show Center 顯示中心點
|
||||
Show Code 顯示程式碼
|
||||
Show in Browser 在瀏覽器中顯示
|
||||
Show Color Groups 顯示顏色群組
|
||||
Show Color Swatches 顯示顏色色票
|
||||
Show Corner Widget 顯示轉角 Widget
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -24,7 +24,7 @@ mod tests_read_only_save;
|
||||
pub use export::{EXPORT_CANCELLED, cancel_exports, export, export_for_screens, export_pdf, hide_exports, reveal, save_command_output};
|
||||
pub(crate) use export::{
|
||||
EXPORT_SELECTION, export_files, exported_with_notes, file_url, open_in_app, open_original, reveal_path, run_to_file, save_command_output_named,
|
||||
selection_path,
|
||||
selection_path, take_selection,
|
||||
};
|
||||
pub(crate) use open::report_installed;
|
||||
pub(crate) use open::{EXPORT_PRESETS, import_presets, open_notes, open_with_on, opened, opened_after_notice, show_opened};
|
||||
|
||||
@@ -15,7 +15,7 @@ pub(crate) const EXPORT_SELECTION: &str = "exportSelection";
|
||||
|
||||
/// `params` without [`EXPORT_SELECTION`], and whether it asked for the selection. A selection
|
||||
/// export writes one page, the selection's crop, so the artboard choices are left out too.
|
||||
fn take_selection(params: &Value) -> Result<(bool, Value), String> {
|
||||
pub(crate) fn take_selection(params: &Value) -> Result<(bool, Value), String> {
|
||||
let mut p = params.clone();
|
||||
let Some(o) = p.as_object_mut() else { return Ok((false, p)) };
|
||||
match o.remove(EXPORT_SELECTION) {
|
||||
|
||||
@@ -219,6 +219,7 @@ fn run_ui_part2(app: &mut VectorcraftApp, id: &str, p: &Value) -> Option<Result<
|
||||
Ok(Value::Null)
|
||||
}
|
||||
"file.export.svg" => io::export(app, Some("svg"), s("path"), p),
|
||||
"file.export.svg.browser" => crate::dialogs::svg_options::browser_preview(app, p),
|
||||
"file.exportForScreens" if p.as_object().is_none_or(|o| o.is_empty()) => {
|
||||
crate::dialogs::open_export_for_screens(app);
|
||||
Ok(Value::Null)
|
||||
|
||||
@@ -317,7 +317,7 @@ pub fn enabled(app: &VectorcraftApp, id: &str) -> bool {
|
||||
"ui.packageDialog" | "docInfo.save" => app.session.active().is_some(),
|
||||
"ui.batchDialog" => !app.ui.action_sets.is_empty() && app.ui.action_sets.iter().any(|s| !s.actions.is_empty()),
|
||||
"ui.epsOptionsDialog" => app.session.active().is_some(),
|
||||
"file.saveForWeb" | "file.saveForWeb.browser" => app.session.active().is_some(),
|
||||
"file.saveForWeb" | "file.saveForWeb.browser" | "file.export.svg.browser" => app.session.active().is_some(),
|
||||
"file.exportSelection" => app.session.active().is_some_and(|d| !d.selection.is_empty()),
|
||||
"css.copy" | "css.exportFile" => app.session.active().is_some(),
|
||||
"print.printerSetup" => app.services.print.as_ref().is_some_and(|s| s.has_setup()),
|
||||
|
||||
@@ -144,6 +144,12 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
|
||||
"",
|
||||
"{} opens SVG Options; with params = document.export {path?, svg?: {…SVG options}, range?…} (a .svgz path writes it gzipped)",
|
||||
),
|
||||
(
|
||||
"file.export.svg.browser",
|
||||
"Show in Browser",
|
||||
"",
|
||||
"{svg?: {…SVG options}, exportSelection?} SVG Options' Show in Browser: write the SVG of one page (with exportSelection the selection's crop, else the first artboard the options choose) and its linked images to a new temporary folder and open it in the default browser (desktop; refused for control and MCP requests) → {path, warnings}",
|
||||
),
|
||||
("file.export.png", "Export As PNG…", "", "{path?, …document.export options}; no path: pick the file, then PNG Options"),
|
||||
(
|
||||
"file.exportForScreens",
|
||||
|
||||
@@ -112,7 +112,7 @@ the two can still win that race.
|
||||
| `ui.dialog.*` on `gradientStop` | `{field: "color" \| "opacity" \| "location", value}` | double-clicking a stop on the Gradient tool's annotator opens its popover (fields `index`, `x`, `y`, `tab`); set `color` (hex), `opacity` or `location` (percentages) and `ui.dialog.confirm` to apply them to the selected stop. `gradient.selectStop {index}` picks the stop the annotator, the panels and Delete/←/→ (`ui.key`) act on |
|
||||
| `engine.execute` `ui.savePdfDialog` | `{path?, preset?, range?, …document.exportPdf options}` | opens the Save PDF dialog (`file.export.pdf` with no params opens it too). Its fields are the `document.exportPdf` options: set `compatibility` with `ui.dialog.set {field: "compatibility", value: "1.5"}`, a whole section with `{field: "compression", value: {…}}`, the artboards with `__allArtboards: false` and `range`, the visible section with `__section` (General, Compression, Marks and Bleeds, Output, Advanced, Security, Summary). `useArtboards: false` opens it for one page of the visible art's bounds, as Export As with Use Artboards off does: the dialog has no Artboards section and its `__artBounds` field is true. `ui.dialog.confirm` writes `path` (else asks for one), returns `{path, bytes, warnings}` and opens the file when `viewAfterSaving` is set. With `useArtboards: false` it writes the page as `app.export` does and returns `{path, warnings}`, or `{background: true, status}` while Background Export writes it |
|
||||
| `file.save` / `file.saveAs` / `file.saveCopy` / `file.saveAsTemplate` (via `engine.execute`) | `{path?, format?, options?, svg?}` | Save writes the document's own file in its own format (a document opened from or saved as SVG/PDF saves as that again; the result's `warnings` say what the format loses). With `path` the file is written at once (Save As or a Copy to an SVG path without SVG options first opens SVG Options, below). Without one (never saved, a converted older file, Save As, a Copy, a Template) the app shows a save panel with one file type per save format (`vectorcraft`, `template`, `pdf`, `svg`, `svgz`, `ai`; for a Template, `template` and `ait`), then the format's options: SVG opens the `svgOptions` dialog (below; returns `{"pending": "svgOptions", "path"}`), PDF the `savePdf` dialog (its `__save` field names the save command); `ui.dialog.confirm` finishes the save. A name typed in the panel without the file type's extension gets it, and a name the panel returns with the extension of a format the panel does not list has it replaced (in a native save, `card.png` and `card.ait` are saved as `card.vectorcraft`, and `notes.v2`, whose extension names no format, is saved as `notes.v2.vectorcraft`); when a file of that name exists, which the panel did not ask about, the save (and every export or other write through a save panel) answers `cancelled` and opens a `replaceFile` dialog (fields `message`, `detail`, `path`): `ui.dialog.confirm` writes that file, `ui.dialog.cancel` writes nothing. A save or export that writes other files beside that path (a file per artboard, linked images, image maps) checks them before it writes anything: when any of them exists, it writes nothing and opens a `replaceFiles` dialog (fields `message`, `detail` (each file's name when there are several), `files`, `__command`, `__params`; the reply is `{"pending": "replaceFiles"}`, or comes once a Background Save or Export ends): `ui.dialog.confirm` runs the save or export again and replaces them, `ui.dialog.cancel` writes nothing; a dialog open when a background job asks stays open, and the question follows it. A save does not ask about the files the document's last Save or Save As in this session wrote. On the web a `saveOptions` dialog (fields `path`, `format`) first names the file and picks the format. `file.formatOptions {format?}` reads the options a save would use. `file.revert` opens a `confirm` dialog (`{"pending": "confirm"}`); `ui.dialog.confirm` reloads the saved file in the same tab. Location refusals return `READ_ONLY_LOCATION: <reason>` without a fallback panel for automation; see [Save location errors](#save-location-errors). |
|
||||
| SVG Options (`engine.execute` of `file.export.svg`, `file.saveAs`, `file.saveCopy`) | `{}` / `{path?, svg?: {…}}` | `file.export.svg` without params, and Save As or Save a Copy to an `.svg`/`.svgz` path without SVG options, open the `svgOptions` dialog (`ui.dialog.set` its fields: `styling`, `outlineText`, `images`, `objectIds`, `decimals`, `minify`, `responsive`, `fewerTspans`, `metadata`, `preserveEditing`, `useArtboards`, `allArtboards`, `range`, `showCode`, `profile` (`svg11`/`tiny12`), `encoding` (`utf8`/`utf16`/`latin1`), `embedFonts`; `ui.dialog.confirm` exports or saves and remembers the choices). With `svg: {…}` (the `document.formats` SVG options) they run directly. `app.save {path?, svg?}` takes the same options; a document saved as SVG saves as SVG again with the same options |
|
||||
| SVG Options (`engine.execute` of `file.export.svg`, `file.saveAs`, `file.saveCopy`) | `{}` / `{path?, svg?: {…}}` | `file.export.svg` without params, and Save As or Save a Copy to an `.svg`/`.svgz` path without SVG options, open the `svgOptions` dialog (`ui.dialog.set` its fields: `styling`, `outlineText`, `images`, `objectIds`, `decimals`, `minify`, `responsive`, `fewerTspans`, `metadata`, `preserveEditing`, `useArtboards`, `allArtboards`, `range`, `showCode`, `profile` (`svg11`/`tiny12`), `encoding` (`utf8`/`utf16`/`latin1`), `embedFonts`; `ui.dialog.confirm` exports or saves and remembers the choices). The dialog's Show in Browser button (`file.export.svg.browser`) writes the SVG of the current choices for one page to a temporary folder and opens it in the default browser, leaving the dialog open; a request through `engine.execute` is refused because it opens another app. With `svg: {…}` (the `document.formats` SVG options) they run directly. `app.save {path?, svg?}` takes the same options; a document saved as SVG saves as SVG again with the same options |
|
||||
| `engine.execute` `file.place` | `{paths?}` / `{path \| name+dataBase64, …file.place params}` | with no file, picks files and opens the `place` dialog; with `paths`, opens it for them (fields `files`, `link`, `template`, `replace`; `__replace` says whether Replace applies, `__info` describes each file). `ui.dialog.confirm` places one file centered in the view (or in place of the selected object) and loads the place cursor with several (`file.place.queue`). In the desktop app the dialog reads its files off the UI thread: `__info` is empty until they are read, `ui.dialog.confirm` returns `{background: true, status}`, `ui.inspect` lists the files still being read in `placing`, and the file is placed (or the cursor loaded) once it is read. With a file, it runs `file.place` centered in the view, at once. Files dropped on the window with no document open open. On the web, files dropped on the canvas are placed at the drop point (linked; Shift embeds) and files dropped off it (the tab bar) open, as in Illustrator; desktop drops carry no pointer position, so documents (native, SVG, PDF, `.ai`, EPS, DXF, EMF/WMF) open as tabs of their own and pictures and text are placed in the middle of the view. Swatch libraries and color books (`.vcswatches`, `.gpl`, `.ase`, `.acb`), graphic style libraries (`.vcstyles`), Libraries panel files (`.vclibrary`), presets (`.vcflattener`, `.vcpdfpresets`, `.vcprintpresets`, `.vcperspective`, `.vcexportpresets`), plug-ins (`.wasm`) and shortcut sets (`.kys`, in Import Shortcut Set) open wherever they are dropped, as File › Open opens them. With the cursor loaded (`ui.inspect` → `tool: "place"`, `toolOptions: {count, current, name, names}`), `ui.pointer` clicks and drags place files (in the desktop app each file is read off the UI thread and placed once it is read, and `ui.inspect` lists it in `placing` until then) and `ui.key` ←/→/↑/↓ and Escape cycle and discard them |
|
||||
| `app.export` raster options | `{path?, format: png \| jpg \| webp, ppi?, width?, height?, background?, antiAlias?, interlaced?, quality?}` | `ppi` sets the pixel size (72 = one pixel per point) and is stored in PNG and JPEG files (WebP files store no resolution); `width` or `height` sets the size of each file in pixels instead (`width` wins), and PNG and JPEG files store the resolution that results; `background` is `transparent`, `white`, `black` or `"#rrggbb"`; `antiAlias` is `none`, `art` or `type` (text snapped to pixels); `interlaced` writes an Adam7 PNG. The PNG Options dialog (`pngOptions`; `jpgOptions` / `webpOptions` for the other raster formats) has the same fields: fill them with `ui.dialog.set` and press OK with `ui.dialog.confirm` |
|
||||
| `app.export` JPEG options | `{path?, format: jpg, quality?: 0–100, colorModel?: rgb \| cmyk \| gray, method?: baseline \| optimized \| progressive, scans?: 3–5, embedIcc?, imageMap?: none \| client \| server}` | `cmyk` writes ink amounts in the working CMYK space (CMYK colours keep their inks; RGB ones are separated with the colour settings); `embedIcc` (default true) embeds sRGB, the working CMYK profile or a grey profile, generated by the CMS; `imageMap` also writes `<stem>.html` (client-side `<map>`) or `<stem>.map` (NCSA) beside the image for the objects with a URL and an Image Map shape (`attributes.set`), returned in `linked`. The `jpgOptions` dialog has these fields too (`quality` is shown 0–10; a CMYK document defaults to `cmyk`) |
|
||||
|
||||
+2
-1
@@ -244,7 +244,8 @@ the suite) keep the agent to the folders you give it:
|
||||
`export`), `document.exportSelection`, `document.exportForScreens` and `assets.export` (before the folder is
|
||||
made or any row is written), `document.save`, `file.save`, `file.saveAs` and `file.saveCopy` (also a save
|
||||
without a path of a document whose own format is SVG or SVGZ), `file.exportAs`, and the SVG Options dialog's
|
||||
Show Code. The same error refuses, before any file is written, every output that carries the native document,
|
||||
Show Code. The dialog's Show in Browser (`file.export.svg.browser`) runs the same checks, and a control or MCP
|
||||
request for it is refused before it writes a file, since it opens another app. The same error refuses, before any file is written, every output that carries the native document,
|
||||
which holds the link: a native file or template, an EPS file, a `.ai` or `.ait` file of every artboard (not a
|
||||
legacy version 7 `.ai` file; a save of a `.ai` file always has every artboard), a PDF of every artboard with
|
||||
Preserve Editing on (also from `document.exportPdf`), and `file.package` (also when a linked native document,
|
||||
|
||||
@@ -891,6 +891,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
- Export for Screens with Include Bleed: a PDF row's page keeps the artboard as its TrimBox and puts the bleed around it once as the BleedBox (a 100 pt artboard with a 9 pt document bleed gives a 100 pt TrimBox in a 118 pt BleedBox, in one file per artboard, a single file and the Full Document), so printer's marks line up with the artboard's edge. The bleed is the row's own (zero included, which a PDF/X row warns about), else the document's when the row sets none and its PDF preset gives none or a bleed of 0; raster, SVG and EPS rows still write the grown artboard. Tests: `fileio::tests_screens::include_bleed_pdf_pages_trim_at_the_artboard` and `include_bleed_pdfx_rows_do_not_warn_about_the_bleed`.
|
||||
- Export for Screens refuses `pdfs: "single"` with `assets`, `layers` or `selection: "each"`, whose files each hold one item's art, instead of writing the first item alone as one PDF named after the document; `pdfs: "multiple"` writes a PDF of each item, and the selection as one file writes one PDF either way. The rule is VectorCraft's own. Tests: `fileio::tests_screens::single_file_pdfs_are_refused_for_assets_layers_and_each_object`.
|
||||
- Save for Web: Preview in Browser writes each preview's page and images to a folder of its own inside `VectorCraft Save for Web` in the system's temporary folder. A later preview, from the same app or another one running, does not overwrite an earlier one. Each preview first removes the preview folders there that are an hour old or older and, on Linux, macOS and FreeBSD, belong to the current user; it leaves other files and folders alone. The folders a preview makes there are open to their owner only on those systems. When `VectorCraft Save for Web` is a link or is not a folder, or on those systems belongs to another user or can be written by other users, the preview goes to a new folder of its own in the temporary folder, which a later preview removes once it is an hour old (`file.saveForWeb.browser`).
|
||||
- SVG Options: Show in Browser opens the SVG in the default web browser, beside Show Code, which shows the code instead; the SVG export options on the help page (https://helpx.adobe.com/illustrator/desktop/save-and-export/export-files-to-different-formats/export-file-format-options-in-illustrator.html) list both. VectorCraft writes the SVG of the dialog's current choices for one page to a new folder inside `VectorCraft SVG Preview` in the system's temporary folder, which is kept and cleaned up as Save for Web's previews are, and the dialog stays open without remembering the choices or writing the chosen file. The page is VectorCraft's own choice: under Export Selection the selection's crop, otherwise the first artboard the options choose, and a range the document does not have is an error. The web build disables the button, and control and MCP requests for `file.export.svg.browser` are refused. `crates/ui-egui/src/dialogs/svg_options.rs` (`show_in_browser_opens_what_ok_writes_without_confirming`, `show_in_browser_is_refused_on_the_web_and_for_automation`, `svg_preview_folders_leave_save_for_web_previews_alone`).
|
||||
- Save for Web: Optimize to File Size… opens rows for a desired file size in K, Start With (Current Settings, Auto Select GIF/JPEG) and, with slices, Use (Total of All Slices, Each Slice, Current Slice); OK takes the settings whose files fit and shows the size found, or says that no setting tried fits ([the help page](https://help.adobe.com/archive/en_US/illustrator/cs4/illustrator_cs4_help.pdf#page=395)). The search lowers JPEG quality or palette colors (GIF then lossy) and encodes at most 32 trial settings; Auto Select chooses GIF for transparent art or art of at most 256 colors and JPEG otherwise. The slices share one setting, so every Use choice changes all of them (`webExport.optimizeToFileSize`). Scores and estimates are unchanged.
|
||||
- Save for Web: while Alt (Option on macOS) is held, the dialog's Cancel button reads Reset, which puts the remembered settings back on the document's active artboard and leaves the dialog open (`ui.dialogReset`).
|
||||
- Export for Screens, Save for Web (slice images, and files named after the document's title) and the Libraries panel name files with the characters Windows does not allow written as `-` and with a `-` after a Windows device name such as `CON`, on every platform (`document.exportForScreens`, `document.exportForWeb`, `library.create`).
|
||||
|
||||
Reference in New Issue
Block a user