diff --git a/crates/engine/src/cmd/fileio/save.rs b/crates/engine/src/cmd/fileio/save.rs index ad1011f63..166eda8b9 100644 --- a/crates/engine/src/cmd/fileio/save.rs +++ b/crates/engine/src/cmd/fileio/save.rs @@ -322,19 +322,6 @@ fn fidelity_warning(f: &Format) -> Option { }) } -/// What an SVG save loses of a document with several artboards: the file is one artboard and -/// reopens as one, unless it carries the native document (Preserve Editing Capabilities). -fn artboards_warning(f: &Format, doc: &Document, params: &Value) -> Option { - let n = doc.artboards.len(); - let preserved = super::svg::options_map(params).ok().and_then(|m| m.get("preserveEditing").and_then(Value::as_bool)).unwrap_or(false); - (is_svg(f) && n > 1 && !preserved).then(|| { - format!( - "{} keeps 1 of the document's {n} artboards (the first, unless one is chosen) and reopens with only that one: turn on Preserve Editing Capabilities or save as VectorCraft to keep them all", - f.label - ) - }) -} - /// A save of the active document, snapshotted and ready to encode and write anywhere (Background /// Save does both on a worker thread): [`save_job`], then [`SaveJob::write`], then /// [`SaveJob::finish`]. Cheap to clone (the documents are shared). @@ -564,7 +551,8 @@ impl SaveJob { } // Lost artboards first: the status bar shows only the first warning. let f = self.plan.format; - enc.warnings.splice(0..0, artboards_warning(f, &self.doc, &self.params).into_iter().chain(fidelity_warning(f))); + let lost = if is_svg(f) { super::svg::lost_artboards_warning(&self.doc, &self.params, f.label) } else { None }; + enc.warnings.splice(0..0, lost.into_iter().chain(fidelity_warning(f))); Ok(enc) } diff --git a/crates/engine/src/cmd/fileio/svg.rs b/crates/engine/src/cmd/fileio/svg.rs index 62c2d1a3a..e2883a773 100644 --- a/crates/engine/src/cmd/fileio/svg.rs +++ b/crates/engine/src/cmd/fileio/svg.rs @@ -147,6 +147,19 @@ fn plan(doc: &Document, p: &Value) -> Result<(ExportOptions, Vec>, Ok((opts, named.unwrap_or_else(|| vec![0]).into_iter().map(Some).collect(), chosen)) } +/// What a save of `doc` as SVG (format `label`) with options `p` loses of several artboards: the +/// file is one artboard and reopens as one, unless it carries the native document (Preserve +/// Editing Capabilities). +pub(super) fn lost_artboards_warning(doc: &Document, p: &Value, label: &str) -> Option { + let n = doc.artboards.len(); + let preserved = plan(doc, p).is_ok_and(|(opts, ..)| opts.preserve_editing); + (n > 1 && !preserved).then(|| { + format!( + "{label} keeps 1 of the document's {n} artboards (the first, unless one is chosen) and reopens with only that one: turn on Preserve Editing Capabilities or save as VectorCraft to keep them all" + ) + }) +} + /// Encode `doc` as SVG (or gzipped, SVGZ): one file per chosen artboard, with the images they /// link to and the writer's warnings. pub(super) fn encode(doc: &Document, p: &Value, compressed: bool) -> Result {