diff --git a/crates/engine/src/cmd/links.rs b/crates/engine/src/cmd/links.rs index 81d1c72497..55c6612494 100644 --- a/crates/engine/src/cmd/links.rs +++ b/crates/engine/src/cmd/links.rs @@ -36,7 +36,7 @@ use vectorcraft_doc::{ use vectorcraft_geom::{Affine, FillRule, PathData, Rect, shapes}; use super::fileio::{self, RasterImage, absolute_path, file_created, file_stamp, read_file, write_file}; -use super::{CommandSpec, EngineError, Result, Session, bad, bool_or, cmd, has_doc, ids_param, object_param, str_param, switch_or}; +use super::{CommandSpec, EngineError, Result, Session, bad, bool_or, cmd, has_doc, ids_param, object_param, str_param, switch_or, text_param}; pub fn specs() -> Vec { vec![ @@ -108,7 +108,7 @@ pub fn specs() -> Vec { "Unembed", [], None, - "{id?: an embedded image (default: the one selected), path?} write the image's pixels to the file at path (PNG, JPEG, GIF or WebP as stored, other images as PNG; a path ending in .png/.jpg/.jpeg/.gif/.webp/.tif/.tiff/.bmp converts them) and link the image to it, keeping its bounds. One undo step → {id, path}; no path → {name, dataBase64} (nothing changes: there is no file to link to)", + "{id?: an embedded image (default: the one selected), path?, ids?: [image ids] (instead of id; one id is the same as id), folder?} write the image's pixels to the file at path (PNG, JPEG, GIF or WebP as stored, other images as PNG; a path ending in .png/.jpg/.jpeg/.gif/.webp/.tif/.tiff/.bmp converts them) and link the image to it, keeping its bounds. One undo step → {id, path}; no path → {name, dataBase64} (nothing changes: there is no file to link to). With folder: write each embedded image of ids or id (default: the selected embedded images) to a new file in folder, as stored (as PNG when that format is not one of VectorCraft's raster file formats), named after the image (characters a file name can't hold become _; Image when nothing is left), with Name 2 … Name 99 when the name is taken; a file already there is never replaced. Linked images among ids are left as they are. Each image links to its file and keeps its bounds. One undo step (undo does not remove the files); when a file can't be written, the files this call wrote are removed and nothing changes → {unembedded: [{id, path}], skipped: [ids of linked images]}; id with ids, path with folder, and ids of more or fewer than one image without folder are errors", has_doc, unembed ), @@ -2686,11 +2686,35 @@ fn convert_image(bytes: &[u8], ext: &str) -> std::result::Result, String craft_image_codecs::encode(&raw, format, &craft_image_codecs::EncodeOptions::default()).map_err(|e| e.to_string()) } +/// The extension of the format embedded image `blob` is stored in (PNG for one Unembed doesn't +/// name). +fn stored_extension(blob: &vectorcraft_doc::ImageBlob) -> &'static str { + fileio::FORMATS.iter().find(|f| f.raster && f.mime == blob.mime).map_or("png", |f| f.extensions.first().copied().unwrap_or("png")) +} + +/// The bytes of embedded image `blob` in the format of extension `ext`: its own bytes when it is +/// stored in that format, else converted. +fn unembed_bytes(blob: &vectorcraft_doc::ImageBlob, ext: &str) -> std::result::Result, String> { + let same = fileio::format(ext).is_some_and(|f| f.mime == blob.mime); + if same { Ok(blob.bytes.to_vec()) } else { convert_image(&blob.bytes, ext) } +} + fn unembed(s: &mut Session, p: &Value) -> Result { const C: &str = "links.unembed"; + let given = |k: &str| p.get(k).is_some_and(|v| !v.is_null()); + // `id` with `ids`, and `path` with `folder`, are refused, in a replayed step too. + super::params::check_exclusive_keys(C, p)?; + let ids = ids_param(p, "ids", C)?; + if given("folder") || ids.as_ref().is_some_and(|ids| ids.len() != 1) { + return unembed_to_folder(s, p, ids); + } let st = s.doc()?; let doc = with_brush_art(&st.doc); - let id = image_param(st, &doc, p, C)?; + // `ids` of one image is `id`. + let id = match ids.as_deref() { + Some(&[id]) => id, + _ => image_param(st, &doc, p, C)?, + }; let n = stored(&doc, id).ok_or(crate::EngineError::NoNode(id))?; let im = image_of(&doc, id).ok_or_else(|| bad(C, format!("object {} is not an image", id.0)))?; if im.link.is_some() { @@ -2698,15 +2722,14 @@ fn unembed(s: &mut Session, p: &Value) -> Result { } let blob = st.doc.images.get(&im.key).filter(|b| !b.is_proxy()).ok_or_else(|| bad(C, "the image's pixels aren't in the document"))?; // As stored (PNG, JPEG, GIF, WebP), unless the path names another format. - let stored = fileio::FORMATS.iter().find(|f| f.raster && f.mime == blob.mime).map_or("png", |f| f.extensions.first().copied().unwrap_or("png")); + let stored = stored_extension(blob); let path = str_param(p, "path"); let ext = match path.map(fileio::extension) { Some(e) if UNEMBED_EXTS.contains(&e.as_str()) => e, Some(e) if !e.is_empty() => return Err(bad(C, format!("can't write .{e} images: use .png, .jpg, .gif, .webp, .tif or .bmp"))), _ => stored.to_string(), }; - let same = fileio::format(&ext).is_some_and(|f| f.mime == blob.mime); - let bytes = if same { blob.bytes.to_vec() } else { convert_image(&blob.bytes, &ext).map_err(|e| bad(C, e))? }; + let bytes = unembed_bytes(blob, &ext).map_err(|e| bad(C, e))?; let Some(path) = path else { let name = n.display_name(); let stem = Path::new(&name).file_stem().map_or_else(|| name.clone(), |s| s.to_string_lossy().into_owned()); @@ -2722,6 +2745,146 @@ fn unembed(s: &mut Session, p: &Value) -> Result { Ok(json!({ "id": id.0, "path": path })) } +/// `links.unembed {ids?, folder}`: each embedded image of `ids` (`id` as `ids` of one; default: the +/// selected embedded images) written to a new file in `folder` as stored (as PNG when that format is not one of +/// VectorCraft's raster file formats) and linked to it, in one undo step. Linked images are skipped. When any image fails, the files written before it +/// are removed and the document does not change. +fn unembed_to_folder(s: &mut Session, p: &Value, ids: Option>) -> Result { + const C: &str = "links.unembed"; + let folder = text_param(p, "folder", C)?.filter(|f| !f.is_empty()).ok_or_else(|| bad(C, "missing `folder`"))?; + let ids = match ids { + Some(ids) => Some(ids), + None => object_param(p, "id", C)?.map(|id| vec![id]), + }; + let st = s.doc()?; + let doc = with_brush_art(&st.doc); + let ids = ids.unwrap_or_else(|| selected_images(st, |im| im.link.is_none())); + let mut seen = BTreeSet::new(); + if !ids.iter().all(|id| seen.insert(id.0)) { + return Err(bad(C, "`ids` names an object twice")); + } + let (mut embedded, mut skipped) = (vec![], vec![]); + for &id in &ids { + let n = stored(&doc, id).ok_or(crate::EngineError::NoNode(id))?; + let im = image_of(&doc, id).ok_or_else(|| bad(C, format!("object {} is not an image", id.0)))?; + if im.link.is_some() { + skipped.push(id); + continue; + } + let blob = st.doc.images.get(&im.key).filter(|b| !b.is_proxy()).ok_or_else(|| bad(C, "the image's pixels aren't in the document"))?; + embedded.push((id, n.display_name(), blob)); + } + match (embedded.is_empty(), skipped.first()) { + (true, Some(id)) => return Err(bad(C, format!("image {} is linked already", id.0))), + (true, None) => return Err(bad(C, "select an image")), + _ => {} + } + let dir = absolute_path(folder); + writable_folder(&dir)?; + // One image at a time: its bytes are read before its file is written, so pixels that can't be + // read leave no file behind. + let mut written: Vec = vec![]; + let mut reads = Vec::with_capacity(embedded.len()); + let wrote = embedded.iter().try_for_each(|(id, name, blob)| { + vectorcraft_doc::cancel::check()?; + let ext = stored_extension(blob); + let bytes = unembed_bytes(blob, ext).map_err(|e| bad(C, e))?; + let name = format!("{}.{ext}", unembed_stem(name)); + let img = linked_image(&bytes, Some(Path::new(&dir).join(&name).to_string_lossy().as_ref()))?; + let path = write_numbered(&dir, &name, &bytes)?; + written.push(path.clone()); + reads.push((*id, (link_info(&path, &bytes), img))); + Ok(()) + }); + let remove_written = |written: &[String]| { + for path in written { + let _ = std::fs::remove_file(path); + } + }; + if let Err(e) = wrote { + remove_written(&written); + return Err(e); + } + drop(doc); + let done: Vec = reads.iter().map(|(id, (l, _))| json!({ "id": id.0, "path": l.path })).collect(); + let edited = s.edit("Unembed", |d, _| { + editing_brush_art(d, |d| reads.into_iter().try_for_each(|(id, read)| install(d, &[id], read, Some(Preserve::Bounds), None))) + }); + if let Err(e) = edited { + remove_written(&written); + return Err(e); + } + Ok(json!({ "unembedded": done, "skipped": ids_json(&skipped) })) +} + +/// The name Unembed gives image `name`'s file in a folder, before its extension: the name without +/// a folder part or extension, each character a file name can't hold on some system +/// (`/ \ : * ? " < > |` and control characters) as `_`, without leading spaces or trailing dots and +/// spaces, at most 150 bytes long, and `Image` when nothing is left. A name Windows keeps for a +/// device (`CON`, `NUL`, `COM1` …) gets `_` after it. +fn unembed_stem(name: &str) -> String { + let base = name.rsplit(['/', '\\']).next().unwrap_or_default(); + let stem = match base.rfind('.') { + Some(i) if i > 0 => &base[..i], + _ => base, + }; + let mut clean = String::new(); + for c in stem.chars().map(|c| if c.is_control() || "/\\:*?\"<>|".contains(c) { '_' } else { c }) { + if clean.len() + c.len_utf8() > 150 { + break; + } + clean.push(c); + } + let clean = clean.trim_start_matches(' ').trim_end_matches(['.', ' ']); + if clean.is_empty() { + return "Image".to_string(); + } + let device = clean.split('.').next().unwrap_or_default().trim_end().to_ascii_uppercase(); + let numbered = |prefix: &str| device.strip_prefix(prefix).is_some_and(|d| d.len() == 1 && matches!(d.as_bytes().first(), Some(b'1'..=b'9'))); + if matches!(device.as_str(), "CON" | "PRN" | "AUX" | "NUL") || numbered("COM") || numbered("LPT") { + format!("{clean}_") + } else { + clean.to_string() + } +} + +/// Folder `path` may take Unembed's files: inside the automation write roots, and a folder. +#[cfg(not(target_arch = "wasm32"))] +fn writable_folder(path: &str) -> Result<()> { + crate::file_access::check_write(path).map_err(EngineError::Other)?; + if !std::fs::metadata(path).is_ok_and(|m| m.is_dir()) { + return Err(EngineError::Other(format!("{path} is not a folder"))); + } + Ok(()) +} + +/// Write `bytes` to a new file named `name` in folder `dir`, never replacing a file there: `Name.ext`, +/// else `Name 2.ext` up to `Name 99.ext`, as [`fileio::copy_new`] names them → its path. +#[cfg(not(target_arch = "wasm32"))] +fn write_numbered(dir: &str, name: &str, bytes: &[u8]) -> Result { + use std::io::Write as _; + let create = |to: &Path| { + crate::file_access::check_write(&to.to_string_lossy()).map_err(|e| std::io::Error::new(std::io::ErrorKind::PermissionDenied, e))?; + vectorcraft_format::write_new_with(to, |f| f.write_all(bytes)) + }; + match fileio::copy_new(Path::new(name), Path::new(dir), create, |_, _| false) { + Ok(Some(fileio::Placed::Copied(to) | fileio::Placed::Kept(to))) => Ok(to.to_string_lossy().into_owned()), + Ok(None) => Err(EngineError::Other(format!("every numbered name for {name} is taken in that folder"))), + Err(e) => Err(EngineError::Other(format!("{dir}: {e}"))), + } +} + +/// The web has no folders to write to. +#[cfg(target_arch = "wasm32")] +fn writable_folder(_: &str) -> Result<()> { + Err(EngineError::Other("no file system here".into())) +} + +#[cfg(target_arch = "wasm32")] +fn write_numbered(_: &str, _: &str, _: &[u8]) -> Result { + Err(EngineError::Other("no file system here".into())) +} + /// Placement Options as `{preserve, align, clip}`. fn placement_json(o: PlacementOptions) -> Value { json!({ "preserve": o.preserve.id(), "align": o.align.id(), "clip": o.clip }) @@ -2901,4 +3064,28 @@ mod tests { let c = read(); assert!(!Arc::ptr_eq(&a.blob.bytes, &c.blob.bytes)); } + + #[test] + fn unembed_names_a_file_after_the_image_with_only_characters_a_file_name_holds() { + for (name, stem) in [ + ("photo.png", "photo"), + ("Image", "Image"), + ("../../etc/passwd", "passwd"), + ("C:\\art\\logo.tif", "logo"), + ("a:b*c?d\"eg|h", "a_b_c_d_e_f_g_h"), + ("tab\there", "tab_here"), + (" name. .png", "name"), + ("..", "Image"), + ("", "Image"), + (".hidden", ".hidden"), + ("CON.png", "CON_"), + ("lpt1", "lpt1_"), + ("COM0", "COM0"), + ("console", "console"), + ] { + assert_eq!(unembed_stem(name), stem, "{name:?}"); + } + let long = unembed_stem(&"é".repeat(200)); + assert!(long.len() <= 150 && long.chars().all(|c| c == 'é'), "{}", long.len()); + } } diff --git a/crates/engine/src/cmd/params.rs b/crates/engine/src/cmd/params.rs index 8dc29b9704..3ee7117dbb 100644 --- a/crates/engine/src/cmd/params.rs +++ b/crates/engine/src/cmd/params.rs @@ -258,11 +258,16 @@ pub fn check_keys(id: &str, doc: &'static str, params: &Value) -> Result<()> { /// Parameters a command takes instead of one another: (command, key, other key). Giving both, /// neither null, is a parameter error ([`check_exclusive_keys`]). -const EXCLUSIVE_KEYS: &[(&str, &str, &str)] = &[("addon.pathtools.cornerSet", "items", "ids"), ("addon.pathtools.cornerRemove", "items", "ids")]; +const EXCLUSIVE_KEYS: &[(&str, &str, &str)] = &[ + ("addon.pathtools.cornerSet", "items", "ids"), + ("addon.pathtools.cornerRemove", "items", "ids"), + ("links.unembed", "id", "ids"), + ("links.unembed", "path", "folder"), +]; /// `params` of command `id` give at most one of each pair in [`EXCLUSIVE_KEYS`], or the parameter /// error naming the pair. -fn check_exclusive_keys(id: &str, params: &Value) -> Result<()> { +pub(crate) fn check_exclusive_keys(id: &str, params: &Value) -> Result<()> { let given = |key: &str| params.get(key).filter(|v| !v.is_null()); for (_, key, other) in EXCLUSIVE_KEYS.iter().filter(|(c, ..)| *c == id) { if given(key).is_some() && given(other).is_some() { diff --git a/crates/engine/src/tests/linkspanel.rs b/crates/engine/src/tests/linkspanel.rs index a1402cc43f..cd844fa28d 100644 --- a/crates/engine/src/tests/linkspanel.rs +++ b/crates/engine/src/tests/linkspanel.rs @@ -203,6 +203,140 @@ fn unembed_of_pixels_that_cant_be_read_writes_no_file() { assert!(image(&s, id).link.is_none()); } +/// The files of folder `dir`, sorted by name. +fn files_in(dir: &str) -> Vec { + let mut names: Vec = std::fs::read_dir(dir).unwrap().map(|e| e.unwrap().file_name().to_string_lossy().into_owned()).collect(); + names.sort(); + names +} + +/// The path of the file `name` in folder `dir`. +fn file_in(dir: &str, name: &str) -> String { + std::path::Path::new(dir).join(name).to_string_lossy().into_owned() +} + +/// Several images unembed into one folder: each gets a new file named after it (a taken name +/// numbered, a file already there never replaced), links to it and keeps its bounds, linked images +/// are skipped, and one undo step makes them embedded again while the files stay. +#[test] +fn unembed_to_a_folder_writes_each_image_and_links_it_in_one_undo_step() { + let dir = Folder::new("unembed-folder"); + let out = dir.file("out"); + for sub in ["a", "b", "out"] { + std::fs::create_dir_all(dir.file(sub)).unwrap(); + } + let (red, blue) = (png(60, 30, RED), png(40, 20, BLUE)); + write(&dir.file("a/photo.png"), &red); + write(&dir.file("b/photo.png"), &blue); + write(&dir.file("a/linked.png"), &red); + let kept = b"not an image".to_vec(); + write(&file_in(&out, "photo.png"), &kept); + let mut s = session(); + let a = place_embedded(&mut s, &dir.file("a/photo.png")); + let b = place_embedded(&mut s, &dir.file("b/photo.png")); + let linked = place(&mut s, &dir.file("a/linked.png")); + let linked_path = image(&s, linked).link.unwrap().path; + let (bounds_a, bounds_b) = (bounds(&s, a), bounds(&s, b)); + let undo_before = s.doc().unwrap().history.undo.len(); + let r = run(&mut s, "links.unembed", json!({"ids": [a.0, linked.0, b.0], "folder": out})); + let (path_a, path_b) = (file_in(&out, "photo 2.png"), file_in(&out, "photo 3.png")); + assert_eq!(r, json!({"unembedded": [{"id": a.0, "path": path_a}, {"id": b.0, "path": path_b}], "skipped": [linked.0]})); + assert_eq!(files_in(&out), ["photo 2.png", "photo 3.png", "photo.png"]); + assert_eq!(std::fs::read(file_in(&out, "photo.png")).unwrap(), kept, "a file already there is not replaced"); + assert_eq!(std::fs::read(&path_a).unwrap(), red); + assert_eq!(std::fs::read(&path_b).unwrap(), blue); + assert_eq!(image(&s, a).link.unwrap().path, path_a); + assert_eq!(image(&s, b).link.unwrap().path, path_b); + assert_eq!(image(&s, linked).link.unwrap().path, linked_path, "a linked image is left as it is"); + assert_eq!((bounds(&s, a), bounds(&s, b)), (bounds_a, bounds_b)); + assert_eq!(s.doc().unwrap().history.undo.len(), undo_before + 1, "one undo step"); + run(&mut s, "edit.undo", json!({})); + assert!(image(&s, a).link.is_none() && image(&s, b).link.is_none(), "both embedded again"); + assert_eq!(files_in(&out).len(), 3, "undo leaves the files"); + // `ids` of one image without `folder` is `id`: the bytes, and nothing changes. + let one = run(&mut s, "links.unembed", json!({"ids": [a.0]})); + assert_eq!(one, run(&mut s, "links.unembed", json!({"id": a.0}))); + assert!(one["dataBase64"].is_string(), "{one}"); + assert!(image(&s, a).link.is_none()); + // With no ids, the selected embedded images. + s.doc_mut().unwrap().selection.objects = vec![b, linked]; + let r = run(&mut s, "links.unembed", json!({"folder": out})); + assert_eq!(r, json!({"unembedded": [{"id": b.0, "path": file_in(&out, "photo 4.png")}], "skipped": []})); + assert_eq!(std::fs::read(file_in(&out, "photo 4.png")).unwrap(), blue); + // `id` with `folder` is `ids` of that one image. + let r = run(&mut s, "links.unembed", json!({"id": a.0, "folder": out})); + assert_eq!(r, json!({"unembedded": [{"id": a.0, "path": file_in(&out, "photo 5.png")}], "skipped": []})); + assert_eq!(image(&s, a).link.unwrap().path, file_in(&out, "photo 5.png")); +} + +/// A batch that fails part way writes no file and changes nothing; requests that don't fit the +/// command are refused before anything is written. +#[test] +fn unembed_to_a_folder_that_fails_leaves_no_file_and_no_change() { + let dir = Folder::new("unembed-folder-fail"); + let out = dir.file("out"); + std::fs::create_dir_all(&out).unwrap(); + write(&dir.file("one.png"), &png(60, 30, RED)); + write(&dir.file("two.png"), &png(60, 30, BLUE)); + let mut s = session(); + let a = place_embedded(&mut s, &dir.file("one.png")); + let b = place_embedded(&mut s, &dir.file("two.png")); + // The second image's pixels can't be read: the first one's file is removed again. + let key = image(&s, b).key; + let saved = s.doc().unwrap().doc.images.get(&key).cloned().unwrap(); + std::sync::Arc::make_mut(&mut s.doc_mut().unwrap().doc).images.insert(key.clone(), vectorcraft_doc::ImageBlob::png(png_header(60, 30))); + let undo_before = s.doc().unwrap().history.undo.len(); + let e = s.execute("links.unembed", &json!({"ids": [a.0, b.0], "folder": out})).unwrap_err(); + assert!(e.to_string().ends_with("the image's pixels can't be read"), "{e}"); + assert!(files_in(&out).is_empty(), "no file left behind"); + assert!(image(&s, a).link.is_none() && image(&s, b).link.is_none()); + assert_eq!(s.doc().unwrap().history.undo.len(), undo_before); + std::sync::Arc::make_mut(&mut s.doc_mut().unwrap().doc).images.insert(key, saved); + + let refused = |s: &mut Session, p: Value| s.execute("links.unembed", &p).unwrap_err().to_string(); + let both = "give `path` or `folder`, not both"; + assert!(refused(&mut s, json!({"ids": [a.0, a.0], "folder": out})).ends_with("`ids` names an object twice")); + assert!(refused(&mut s, json!({"id": a.0, "path": file_in(&out, "x.png"), "folder": out})).ends_with(both)); + assert!(refused(&mut s, json!({"ids": [a.0], "path": file_in(&out, "x.png"), "folder": out})).ends_with(both)); + assert!(refused(&mut s, json!({"ids": [a.0, b.0]})).ends_with("missing `folder`")); + assert!(refused(&mut s, json!({"ids": []})).ends_with("missing `folder`")); + assert!(refused(&mut s, json!({"id": a.0, "ids": [b.0], "folder": out})).ends_with("give `id` or `ids`, not both")); + assert!(refused(&mut s, json!({"id": a.0, "ids": [b.0]})).ends_with("give `id` or `ids`, not both")); + assert!(refused(&mut s, json!({"ids": [a.0], "folder": 5})).ends_with("`folder` must be a string")); + assert!(refused(&mut s, json!({"ids": [], "folder": out})).ends_with("select an image")); + let file = dir.file("one.png"); + assert!(refused(&mut s, json!({"ids": [a.0], "folder": file})).ends_with(&format!("{file} is not a folder"))); + run(&mut s, "shape.rectangle", json!({"x": 0, "y": 0, "width": 10, "height": 10})); + let rect = s.doc().unwrap().selection.objects[0]; + assert!(refused(&mut s, json!({"ids": [a.0, rect.0], "folder": out})).ends_with(&format!("object {} is not an image", rect.0))); + assert!(files_in(&out).is_empty(), "nothing written for a refused request"); + run(&mut s, "links.unembed", json!({"ids": [a.0], "folder": out})); + assert!(refused(&mut s, json!({"ids": [a.0], "folder": out})).ends_with(&format!("image {} is linked already", a.0))); + assert_eq!(files_in(&out), ["one.png"]); +} + +/// Under automation write roots, a folder outside them takes no file. +#[test] +fn unembed_to_a_folder_outside_the_write_roots_is_refused() { + use crate::file_access::{AutomationRoots, confine}; + let dir = Folder::new("unembed-folder-roots"); + let (inside, outside) = (dir.file("inside"), dir.file("outside")); + std::fs::create_dir_all(&inside).unwrap(); + std::fs::create_dir_all(&outside).unwrap(); + write(&file_in(&inside, "pic.png"), &png(60, 30, RED)); + let mut s = session(); + let id = place_embedded(&mut s, &file_in(&inside, "pic.png")); + let roots = AutomationRoots::new(&[dir.0.as_path()], &[std::path::Path::new(&inside)]).unwrap(); + let p = json!({"ids": [id.0], "folder": outside}); + let e = confine(roots.as_ref(), || s.execute("links.unembed", &p)).unwrap_err().to_string(); + assert!(e.contains("outside the write root"), "{e}"); + assert!(files_in(&outside).is_empty()); + assert!(image(&s, id).link.is_none()); + let p = json!({"ids": [id.0], "folder": inside}); + confine(roots.as_ref(), || s.execute("links.unembed", &p)).unwrap(); + assert!(image(&s, id).link.is_some()); +} + #[test] fn go_to_selects_the_image() { let dir = Folder::new("goto"); diff --git a/crates/ui-egui/src/i18n/ca.tsv b/crates/ui-egui/src/i18n/ca.tsv index 04f3309076..d35c2ec8e6 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -6765,6 +6765,8 @@ liquify-list-end {0}, {1} {0} i {1} @msg Trap: select two or more objects filled with solid colours Trap: selecciona dos o més objectes emplenats amb colors sòlids @msg truncated truncat @msg Unembedded to {_1} S’ha desincrustat a {_1} +@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} S’ha desincrustat {n} imatge a {folder}|S’han desincrustat {n} imatges a {folder} +@msg every numbered name for {name} is taken in that folder tots els noms numerats per a {name} estan ocupats en aquesta carpeta @msg unknown command `{0}` ordre desconeguda `{0}` @msg step {step} of “{action}” runs the unknown command `{command}` el pas {step} de “{action}” executa l’ordre desconeguda `{command}` @msg unknown command `{0}`; did you mean `{1}`? ordre desconeguda `{0}`; volies dir `{1}`? diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index f44e8cb147..75a8d098dc 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -5754,6 +5754,8 @@ liquify-list-end {0}, {1} {0} a {1} @msg All colors are within the CMYK gamut Všechny barvy jsou v gamutu CMYK @msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut {n} barva je mimo gamut CMYK|{n} barvy jsou mimo gamut CMYK|{n} barev je mimo gamut CMYK @msg Unembedded to {_1} Vložení zrušeno, uloženo do: {_1} +@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} Vložení zrušeno u {n} obrázku, uloženo do: {folder}|Vložení zrušeno u {n} obrázků, uloženo do: {folder}|Vložení zrušeno u {n} obrázků, uloženo do: {folder} +@msg every numbered name for {name} is taken in that folder v této složce jsou obsazena všechna číslovaná jména pro {name} @msg Reset {_1} Obnoveno: {_1} @msg Sent to {_1} Odesláno do {_1} @msg {_1} files Soubory {_1} diff --git a/crates/ui-egui/src/i18n/da.tsv b/crates/ui-egui/src/i18n/da.tsv index c0b12d0ef7..2f8d08a716 100644 --- a/crates/ui-egui/src/i18n/da.tsv +++ b/crates/ui-egui/src/i18n/da.tsv @@ -7885,6 +7885,8 @@ imageTrace Outline Kontur @msg All colors are within the CMYK gamut Alle farver er inden for CMYK-farveomfanget @msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut {n} farve er uden for CMYK-farveomfanget|{n} farver er uden for CMYK-farveomfanget @msg Unembedded to {_1} Fjernede indlejring til {_1} +@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} Fjernede indlejring af {n} billede til {folder}|Fjernede indlejring af {n} billeder til {folder} +@msg every numbered name for {name} is taken in that folder alle nummererede navne til {name} er optaget i den mappe @msg Reset {_1} Nulstillede {_1} @msg Sent to {_1} Sendte til {_1} @msg {_1} files {_1}-filer diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index 8bec92dce5..2f5ff905c7 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -5357,6 +5357,8 @@ liquify-list-end {0}, {1} {0} und {1} @msg All colors are within the CMYK gamut Alle Farben liegen im CMYK-Farbumfang @msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut {n} Farbe liegt außerhalb des CMYK-Farbumfangs|{n} Farben liegen außerhalb des CMYK-Farbumfangs @msg Unembedded to {_1} Einbettung aufgehoben, gespeichert unter {_1} +@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} Einbettung von {n} Bild aufgehoben, gespeichert unter {folder}|Einbettung von {n} Bildern aufgehoben, gespeichert unter {folder} +@msg every numbered name for {name} is taken in that folder alle nummerierten Namen für {name} sind in diesem Ordner bereits vergeben @msg Reset {_1} {_1} zurückgesetzt @msg Sent to {_1} An {_1} gesendet @msg {_1} files {_1}-Dateien diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index 2c062d8d88..c4d205d796 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -5409,6 +5409,8 @@ digits Malayalam Μαλαγιάλαμ @msg All colors are within the CMYK gamut Όλα τα χρώματα βρίσκονται εντός της χρωματικής γκάμας CMYK @msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut {n} χρώμα βρίσκεται εκτός της χρωματικής γκάμας CMYK|{n} χρώματα βρίσκονται εκτός της χρωματικής γκάμας CMYK @msg Unembedded to {_1} Καταργήθηκε η ενσωμάτωση στο {_1} +@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} Καταργήθηκε η ενσωμάτωση {n} εικόνας στο {folder}|Καταργήθηκε η ενσωμάτωση {n} εικόνων στο {folder} +@msg every numbered name for {name} is taken in that folder όλα τα αριθμημένα ονόματα για το {name} χρησιμοποιούνται ήδη σε αυτόν τον φάκελο @msg Reset {_1} Επαναφορά {_1} @msg Sent to {_1} Στάλθηκε στο {_1} @msg {_1} files {_1} αρχεία diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index fcb5ff0cc7..21e9c77f61 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -5462,6 +5462,8 @@ liquify-list-end {0}, {1} {0}, {1} @msg All colors are within the CMYK gamut Todos los colores están dentro de la gama CMYK @msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut {n} color está fuera de la gama CMYK|{n} colores están fuera de la gama CMYK @msg Unembedded to {_1} Se desincrustó en {_1} +@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} Se desincrustó {n} imagen en {folder}|Se desincrustaron {n} imágenes en {folder} +@msg every numbered name for {name} is taken in that folder todos los nombres numerados para {name} ya existen en esa carpeta @msg Reset {_1} Se restableció {_1} @msg Sent to {_1} Se envió a {_1} @msg {_1} files {_1} archivos diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index a7ec3ce7ed..e5d586e0bf 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -5678,6 +5678,8 @@ liquify-list-end {0}, {1} {0} ja {1} @msg All colors are within the CMYK gamut Kaikki värit ovat CMYK-väriavaruuden sisällä @msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut {n} väri on CMYK-väriavaruuden ulkopuolella|{n} väriä on CMYK-väriavaruuden ulkopuolella @msg Unembedded to {_1} Upotus purettiin kohteeseen {_1} +@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} Upotus purettiin {n} kuvalta kohteeseen {folder}|Upotus purettiin {n} kuvalta kohteeseen {folder} +@msg every numbered name for {name} is taken in that folder kaikki kohteen {name} numeroidut nimet ovat jo käytössä siinä kansiossa @msg Reset {_1} Palautettiin oletukseksi {_1} @msg Sent to {_1} Lähetettiin kohteeseen {_1} @msg {_1} files {_1}-tiedostot diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index a028a5bab8..9681c29f09 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -5420,6 +5420,8 @@ liquify-list-end {0}, {1} {0} et {1} @msg All colors are within the CMYK gamut Toutes les couleurs sont dans la gamme CMJN @msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut {n} couleur est hors de la gamme CMJN|{n} couleurs sont hors de la gamme CMJN @msg Unembedded to {_1} Incorporation annulée vers {_1} +@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} Incorporation annulée pour {n} image vers {folder}|Incorporation annulée pour {n} images vers {folder} +@msg every numbered name for {name} is taken in that folder tous les noms numérotés pour {name} sont déjà pris dans ce dossier @msg Reset {_1} {_1} réinitialisé @msg Sent to {_1} Envoyé à {_1} @msg {_1} files Fichiers {_1} diff --git a/crates/ui-egui/src/i18n/hi.tsv b/crates/ui-egui/src/i18n/hi.tsv index b2ad3538b2..7ef716aded 100644 --- a/crates/ui-egui/src/i18n/hi.tsv +++ b/crates/ui-egui/src/i18n/hi.tsv @@ -8834,6 +8834,8 @@ liquify-list-end {0}, {1} {0} और {1} @msg type that changes writing direction inside a text object opens in the direction of its first character टेक्स्ट ऑब्जेक्ट के भीतर लेखन दिशा बदलने वाला टेक्स्ट अपने पहले वर्ण की दिशा में खुलता है @msg type used as a mask in linked areas, wraparound text or a compound path doesn't clip लिंक्ड एरिया, रैपअराउंड टेक्स्ट या कंपाउंड पाथ में मास्क के रूप में इस्तेमाल किया गया टाइप क्लिप नहीं करता @msg Unembedded to {_1} एम्बेड हटाकर {_1} में रखा गया +@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} {n} इमेज का एम्बेड हटाकर {folder} में रखा गया|{n} इमेज का एम्बेड हटाकर {folder} में रखा गया +@msg every numbered name for {name} is taken in that folder {name} के लिए हर नंबर वाला नाम उस फ़ोल्डर में पहले से लिया गया है @msg unexpected host trap होस्ट में अप्रत्याशित ट्रैप @msg unexpected resources अप्रत्याशित संसाधन @msg unknown {k} key `{key}` (size, position) अज्ञात {k} कुंजी `{key}` (size, position) diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index 98a905561a..43d8424959 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -6147,6 +6147,8 @@ liquify-list-end {0}, {1} {0} és {1} @msg tool shortcuts must be a single key (optionally with Shift) eszköz billentyűparancsa egyetlen billentyű lehet (Shifttel vagy anélkül) @msg truncated csonka @msg Unembedded to {_1} Beágyazás megszüntetve, ide: {_1} +@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} Beágyazás megszüntetve, képek: {n}, ide: {folder} +@msg every numbered name for {name} is taken in that folder abban a mappában minden sorszámozott név foglalt: {name} @msg unknown command `{0}` ismeretlen parancs: `{0}` @msg step {step} of “{action}” runs the unknown command `{command}` „{action}”, lépés: {step}: ismeretlen parancsot futtat: `{command}` @msg unknown command `{0}`; did you mean `{1}`? ismeretlen parancs: `{0}`; erre gondolt: `{1}`? diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 46081631c1..55974ede1d 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -5490,6 +5490,8 @@ liquify-list-end {0}, {1} {0} e {1} @msg All colors are within the CMYK gamut Tutti i colori rientrano nella gamma CMYK @msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut {n} colore è fuori dalla gamma CMYK|{n} colori sono fuori dalla gamma CMYK @msg Unembedded to {_1} Incorporamento rimosso, salvato in {_1} +@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} Incorporamento rimosso per {n} immagine, salvata in {folder}|Incorporamento rimosso per {n} immagini, salvate in {folder} +@msg every numbered name for {name} is taken in that folder tutti i nomi numerati per {name} sono già usati in quella cartella @msg Reset {_1} Reimpostato {_1} @msg Sent to {_1} Inviato a {_1} @msg {_1} files {_1} file diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index d38faf2a54..d87cde79f4 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -5559,6 +5559,8 @@ liquify-list-end {0}, {1} {0}、{1} @msg All colors are within the CMYK gamut すべてのカラーが CMYK の色域内です @msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut {n} 個のカラーが CMYK の色域外です @msg Unembedded to {_1} 埋め込みを解除して {_1} に保存しました +@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} {n} 枚の画像の埋め込みを解除して {folder} に保存しました +@msg every numbered name for {name} is taken in that folder そのフォルダーでは、{name} の番号付きの名前がすべて使われています @msg no swatch library `{l}` (see swatch.library.list) スウォッチライブラリ `{l}` が見つかりません (swatch.library.list を参照) @msg no user library folder here この環境にはユーザーライブラリフォルダーがありません @msg Couldn't place {name}: the document it was dropped on was closed {name} を配置できませんでした: ドロップ先のドキュメントは閉じられています diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index 1c588f8b9f..c7cb26204f 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -7234,6 +7234,8 @@ font-technology Variable ცვლადი @msg All colors are within the CMYK gamut ყველა ფერი CMYK-ის გამის ფარგლებშია @msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut CMYK-ის გამის ფარგლებს გარეთაა ფერი ({n}) @msg Unembedded to {_1} ჩაშენება მოხსნილია: {_1} +@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} ჩაშენება მოხსნილია, გამოსახულებები: {n}, საქაღალდე: {folder} +@msg every numbered name for {name} is taken in that folder იმ საქაღალდეში {name}-ის ყველა დანომრილი სახელი დაკავებულია @msg Reset {_1} ჩამოყრილია: {_1} @msg Sent to {_1} გაგზავნილია: {_1} @msg {_1} files ფაილები: {_1} diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index fcc1f18616..c98d771b5a 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -5486,6 +5486,8 @@ liquify-list-end {0}, {1} {0} 및 {1} @msg All colors are within the CMYK gamut 모든 색상이 CMYK 색상 범위 안에 있습니다 @msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut 색상 {n}개가 CMYK 색상 범위를 벗어났습니다 @msg Unembedded to {_1} {_1}에 포함 해제했습니다 +@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} 이미지 {n}개를 {folder}에 포함 해제했습니다 +@msg every numbered name for {name} is taken in that folder 해당 폴더에서 {name}을(를) 위한 번호 이름이 모두 사용 중입니다 @msg no swatch library `{l}` (see swatch.library.list) 견본 라이브러리 `{l}`이(가) 없습니다(swatch.library.list 참조) @msg no user library folder here 여기에는 사용자 라이브러리 폴더가 없습니다 @msg Couldn't place {name}: the document it was dropped on was closed {name}을(를) 가져올 수 없습니다: 놓은 문서가 닫혔습니다 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index b30f1107b9..82701c120e 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -5759,6 +5759,8 @@ imageTrace Outline Contour @msg All colors are within the CMYK gamut Alle kleuren vallen binnen het CMYK-gamut @msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut {n} kleur valt buiten het CMYK-gamut|{n} kleuren vallen buiten het CMYK-gamut @msg Unembedded to {_1} Extern gemaakt: {_1} +@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} {n} afbeelding extern gemaakt in {folder}|{n} afbeeldingen extern gemaakt in {folder} +@msg every numbered name for {name} is taken in that folder elke genummerde naam voor {name} is al vergeven in die map @msg Reset {_1} {_1} opnieuw ingesteld @msg Sent to {_1} Verzonden naar {_1} @msg {_1} files {_1}-bestanden diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 562f0f6b42..693bd152c3 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -5580,6 +5580,8 @@ liquify-list-end {0}, {1} {0} i {1} @msg All colors are within the CMYK gamut Wszystkie kolory mieszczą się w gamucie CMYK @msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut {n} kolor nie mieści się w gamucie CMYK|{n} kolory nie mieszczą się w gamucie CMYK|{n} kolorów nie mieści się w gamucie CMYK @msg Unembedded to {_1} Wyodrębniono do {_1} +@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} Wyodrębniono {n} obraz do {folder}|Wyodrębniono {n} obrazy do {folder}|Wyodrębniono {n} obrazów do {folder} +@msg every numbered name for {name} is taken in that folder wszystkie numerowane nazwy dla {name} są zajęte w tym folderze @msg Reset {_1} Zresetowano {_1} @msg Sent to {_1} Wysłano do {_1} @msg {_1} files Pliki {_1} diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index f9805d972f..84ae735515 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -4759,6 +4759,8 @@ axis Both Ambos @msg All colors are within the CMYK gamut Todas as cores estão dentro do gamut CMYK @msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut {n} cor está fora do gamut CMYK|{n} cores estão fora do gamut CMYK @msg Unembedded to {_1} Desincorporado para {_1} +@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} {n} imagem desincorporada para {folder}|{n} imagens desincorporadas para {folder} +@msg every numbered name for {name} is taken in that folder todos os nomes numerados para {name} já existem nessa pasta @msg Reset {_1} Redefinir {_1} @msg Sent to {_1} Enviado para {_1} @msg {_1} files {_1} arquivos diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index 28106fdc38..1737e7a6aa 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -5486,6 +5486,8 @@ liquify-list-end {0}, {1} {0} и {1} @msg All colors are within the CMYK gamut Все цвета входят в цветовой охват CMYK @msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut {n} цвет выходит за пределы цветового охвата CMYK|{n} цвета выходят за пределы цветового охвата CMYK|{n} цветов выходят за пределы цветового охвата CMYK @msg Unembedded to {_1} Извлечено в {_1} +@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} Извлечено {n} изображение в {folder}|Извлечено {n} изображения в {folder}|Извлечено {n} изображений в {folder} +@msg every numbered name for {name} is taken in that folder все нумерованные имена для {name} уже заняты в этой папке @msg Reset {_1} Сброшено: {_1} @msg Sent to {_1} Отправлено в {_1} @msg {_1} files {_1} файлов diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index e2dc2e87a4..0dd78d2516 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -5350,6 +5350,8 @@ liquify-list-end {0}, {1} {0} och {1} @msg All colors are within the CMYK gamut Alla färger ligger inom CMYK-färgomfånget @msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut {n} färg ligger utanför CMYK-färgomfånget|{n} färger ligger utanför CMYK-färgomfånget @msg Unembedded to {_1} Extraherad till {_1} +@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} Extraherade {n} bild till {folder}|Extraherade {n} bilder till {folder} +@msg every numbered name for {name} is taken in that folder alla numrerade namn för {name} är upptagna i den mappen @msg Reset {_1} Återställ {_1} @msg Sent to {_1} Skickat till {_1} @msg {_1} files {_1}-filer diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index f276fda11d..e854ae5464 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -5179,6 +5179,8 @@ liquify-list-end {0}, {1} {0} ve {1} @msg All colors are within the CMYK gamut Tüm renkler CMYK gamındadır @msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut {n} renk CMYK gamının dışında @msg Unembedded to {_1} {_1}'ye gömülü değil +@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} {n} görselin gömülmesi kaldırıldı: {folder} +@msg every numbered name for {name} is taken in that folder {name} için numaralandırılmış her ad o klasörde zaten kullanılıyor @msg Reset {_1} {_1}'yi sıfırla @msg Sent to {_1} {_1}'ye gönderildi @msg {_1} files {_1} dosyaları diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index 21318b0b06..7b52da5810 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -5474,6 +5474,8 @@ liquify-list-end {0}, {1} {0} і {1} @msg All colors are within the CMYK gamut Усі кольори входять у колірне охоплення CMYK @msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut {n} колір виходить за межі колірного охоплення CMYK|{n} кольори виходять за межі колірного охоплення CMYK|{n} кольорів виходять за межі колірного охоплення CMYK @msg Unembedded to {_1} Вилучено у {_1} +@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} Вилучено {n} зображення у {folder}|Вилучено {n} зображення у {folder}|Вилучено {n} зображень у {folder} +@msg every numbered name for {name} is taken in that folder усі нумеровані імена для {name} уже зайняті в цій папці @msg Reset {_1} Скинуто: {_1} @msg Sent to {_1} Відправлено до {_1} @msg {_1} files {_1} файлів diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index 1f919dd7fe..1ab5d5f5d5 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -5923,6 +5923,8 @@ liquify-list-end {0}, {1} {0} và {1} @msg tool shortcuts must be a single key (optionally with Shift) phím tắt công cụ phải là một phím đơn (tùy chọn với Shift) @msg truncated bị cắt ngắn @msg Unembedded to {_1} Đã bỏ nhúng vào {_1} +@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} Đã bỏ nhúng {n} ảnh vào {folder} +@msg every numbered name for {name} is taken in that folder mọi tên đánh số cho {name} đã được dùng trong thư mục đó @msg unknown command `{0}` lệnh không xác định `{0}` @msg step {step} of “{action}” runs the unknown command `{command}` bước {step} của “{action}” chạy lệnh không xác định `{command}` @msg unknown command `{0}`; did you mean `{1}`? lệnh không xác định `{0}`; ý bạn là `{1}`? diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index 8c4e5b59f4..da7073f5dd 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -5236,6 +5236,8 @@ liquify-list-end {0}, {1} {0}和{1} @msg All colors are within the CMYK gamut 所有颜色皆在 CMYK 色域内 @msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut {n} 个颜色超出 CMYK 色域 @msg Unembedded to {_1} 已取消嵌入到 {_1} +@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} 已将 {n} 张图像取消嵌入到 {folder} +@msg every numbered name for {name} is taken in that folder 该文件夹中 {name} 的所有带编号的名称均已被占用 @msg no swatch library `{l}` (see swatch.library.list) 没有色板库 `{l}` (请参阅 swatch.library.list) @msg no user library folder here 此处没有用户库文件夹 @msg Couldn't place {name}: the document it was dropped on was closed 无法置入 {name}:将它拖放到的文档已关闭 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index d5f4972bed..c678efb662 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -2773,6 +2773,8 @@ liquify-list-end {0}, {1} {0}和{1} @msg All colors are within the CMYK gamut 所有顏色皆在 CMYK 色域內 @msgplural {n} color is out of the CMYK gamut|{n} colors are out of the CMYK gamut {n} 個顏色超出 CMYK 色域 @msg Unembedded to {_1} 已取消內嵌至 {_1} +@msgplural Unembedded {n} image to {folder}|Unembedded {n} images to {folder} 已將 {n} 個影像取消內嵌至 {folder} +@msg every numbered name for {name} is taken in that folder 該資料夾中 {name} 的所有編號名稱都已被使用 @msg no swatch library `{l}` (see swatch.library.list) 沒有色票資料庫 `{l}` (請參閱 swatch.library.list) @msg no user library folder here 此處沒有使用者資料庫資料夾 @msg Couldn't place {name}: the document it was dropped on was closed 無法置入 {name}:放置它的文件已關閉 diff --git a/crates/ui-egui/src/panels/links.rs b/crates/ui-egui/src/panels/links.rs index 611c9e472a..3b45e450d4 100644 --- a/crates/ui-egui/src/panels/links.rs +++ b/crates/ui-egui/src/panels/links.rs @@ -335,6 +335,37 @@ pub(crate) fn unembed(app: &mut VectorcraftApp, id: u64, name: &str) { }); } +/// Whether Unembed… can act on `embedded` selected embedded images: one goes to a picked file, +/// several to a picked folder (the web downloads each one). +pub(crate) fn can_unembed(app: &VectorcraftApp, embedded: usize) -> bool { + match embedded { + 0 => false, + 1 => true, + _ => app.services.download.is_some() || app.services.pick_folder.is_some(), + } +} + +/// Write embedded images `ids` to new files in a picked folder and link each one to its file, in +/// one undo step (the web downloads each one and links none). +pub(crate) fn unembed_several(app: &mut VectorcraftApp, ids: Vec) { + if app.services.download.is_some() { + for id in ids { + unembed(app, id, ""); + } + return; + } + crate::picks::button(app, move |app| unembed_to_picked_folder(app, ids.clone())); +} + +fn unembed_to_picked_folder(app: &mut VectorcraftApp, ids: Vec) { + let Some(folder) = crate::picks::folder(app) else { return }; + let r = app.run("links.unembed", json!({ "ids": ids, "folder": folder })); + report(app, r, |v| { + let n = v["unembedded"].as_array().map_or(0, Vec::len); + crate::i18n::msg_n(n as u64, "Unembedded {n} image to {folder}", "Unembedded {n} images to {folder}", &[("folder", &folder)]) + }); +} + /// The UI commands `links.editOriginal` (open the linked file in its app) and `links.reveal` /// (show it in its folder) for image `id` (default: the selected linked image) → `{path}`. pub(crate) fn open_file(app: &mut VectorcraftApp, p: &Value, reveal: bool) -> Result { @@ -834,12 +865,16 @@ pub fn menu(app: &mut VectorcraftApp, ui: &mut Ui) { } }); } - if menu_item(ui, tl!("Unembed…"), embedded.len() == 1, false) - && let Some(r) = embedded.first() - && let Some(id) = r["id"].as_u64() - { - let name = r["name"].as_str().unwrap_or("Image").to_string(); - unembed(app, id, &name); + if menu_item(ui, tl!("Unembed…"), can_unembed(app, embedded.len()), false) { + match &embedded[..] { + [r] => { + if let Some(id) = r["id"].as_u64() { + let name = r["name"].as_str().unwrap_or("Image").to_string(); + unembed(app, id, &name); + } + } + rows => unembed_several(app, rows.iter().filter_map(|r| r["id"].as_u64()).collect()), + } } if menu_item(ui, tl!("Placement Options…"), any, false) { crate::menus::invoke(app, "ui.placementOptionsDialog", json!({ "ids": ids(&sel, |_| true) })); diff --git a/crates/ui-egui/src/panels/tests_links.rs b/crates/ui-egui/src/panels/tests_links.rs index 781c4f5840..aaf0ed0be7 100644 --- a/crates/ui-egui/src/panels/tests_links.rs +++ b/crates/ui-egui/src/panels/tests_links.rs @@ -500,6 +500,36 @@ fn properties_shows_the_selected_image_and_its_link_actions() { assert!(text.contains("Linked File") && text.contains("Edit Original") && text.contains("Embed"), "{text}"); } +/// Unembed… acts on several selected embedded images: it asks for one folder, writes a file for +/// each image there and links each one to its file; with no folder picked, nothing changes. +#[test] +fn unembed_writes_several_images_to_one_picked_folder() { + let dir = Folder::new("unembed-several"); + let (mut app, _, embedded) = app(&dir); + let c = dir.file("other.png", &png(30, 10)); + let other = app.run("file.place", json!({"path": c, "at": [50, 50], "link": false})).unwrap()["ids"][0].as_u64().unwrap(); + assert!(super::links::can_unembed(&app, 1)); + assert!(!super::links::can_unembed(&app, 0)); + assert!(!super::links::can_unembed(&app, 2), "no folder to pick"); + let out = dir.0.join("out"); + std::fs::create_dir_all(&out).unwrap(); + // No folder picked: nothing written or linked. + app.services.pick_folder = Some(Box::new(|| None)); + assert!(super::links::can_unembed(&app, 2)); + super::links::unembed_several(&mut app, vec![embedded, other]); + assert_eq!(std::fs::read_dir(&out).unwrap().count(), 0); + assert_eq!(app.run("links.info", json!({"id": embedded})).unwrap()["status"], "embedded"); + let picked = out.to_string_lossy().into_owned(); + let answer = picked.clone(); + app.services.pick_folder = Some(Box::new(move || Some(answer.clone()))); + super::links::unembed_several(&mut app, vec![embedded, other]); + for (id, name) in [(embedded, "embedded.png"), (other, "other.png")] { + let info = app.run("links.info", json!({"id": id})).unwrap(); + assert_eq!(info["path"], out.join(name).to_string_lossy().as_ref(), "{info}"); + } + assert_eq!(app.ui.status, format!("Unembedded 2 images to {picked}")); +} + #[test] fn the_links_menu_items_run_commands() { let tree = crate::menus::menu_tree(); diff --git a/docs/mcp.md b/docs/mcp.md index 5139df3e7f..efcdc592f6 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -8497,6 +8497,18 @@ every object in the layers each time the list is read. A `dcsTransparency` that returns `{id, onCanvas: false, owner}`, and the panel says the link has no place on the canvas. `links.embed {ids?}` keeps linked files' pixels in the document (an image whose file is missing stays linked: relink it first); `links.unembed {id, path}` writes an embedded image to a file (another extension converts it) and links to it, and without `path` returns `{name, dataBase64}`. +`ids` of one image works as `id` does. `links.unembed {ids?, folder}` writes each embedded image of `ids` (or of +`id`; default: the selected embedded images) to a new +file in `folder`, in the format it is stored in (as PNG when that format is not one of VectorCraft's raster file formats), and links each image to its file, keeping its bounds, in one undo +step; undo does not remove the files. A file is named after its image, with each character a file name can't hold +(`/ \ : * ? " < > |` and control characters) as `_` and `Image` when nothing is left; when the name is taken it is +`Name 2.png` … `Name 99.png`, and a file already in the folder is never replaced. Linked images among `ids` are left +as they are and listed in `skipped`. It returns `{unembedded: [{id, path}], skipped}`. When an image can't be written, +the files the call wrote are removed and the document does not change. A folder outside the automation write roots, +`id` given with `ids`, `path` given with `folder`, `ids` of more or fewer than one image without `folder`, an id given twice, and `ids` with +no embedded image are errors. The Links +panel menu's Unembed… with several embedded images selected asks for one folder and runs this form (on the web it +downloads each image instead and links none). `links.placementOptions {ids?, preserve?: transforms|bounds|fileDimensions|fit|fill, align?: topLeft…bottomRight, clip?}` decides how a relinked or updated file takes an image's place (default `bounds`: stretched into the old bounds; `clip` puts it in a clip group of the old bounds when it is larger). The UI commands `links.editOriginal` and @@ -8515,6 +8527,7 @@ malformed `ids`, or nothing to copy is an error, and the clipboard is left as it {"name":"run_command","arguments":{"command":"links.list","params":{"show":"missing"}}} {"name":"run_command","arguments":{"command":"links.placementOptions","params":{"ids":[12],"preserve":"fit","align":"top"}}} {"name":"run_command","arguments":{"command":"links.unembed","params":{"id":14,"path":"/tmp/logo.png"}}} +{"name":"run_command","arguments":{"command":"links.unembed","params":{"ids":[14,15],"folder":"/tmp/images"}}} ``` ## Package and Document Info diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index f87ec0360d..8b78d3c8d4 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -2137,6 +2137,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - Missing linked files can be looked for in a folder and its subfolders: Find in Folder… in the Linked File Not Found dialog and in the Links panel menu lists the files with each one's name, those with the size and contents saved with the link first, and relinks the files chosen, copying an image's file into the document's folder when asked, without replacing a file there (`links.findFiles`, `links.relink {copy}`). In the Links panel it looks for the selected linked files when any are selected. - The Links panel's Relink… opens a Relink dialog whose Replace menu picks which links take the new file: Selected Instances (the selected images, as before), All Instances (every image linked to the same file), Missing Links from This Folder (then every other missing link whose file name is in the new file's folder) and Each Link Separately (a file for each selected link in turn). Each relinks as one undo step (`links.relink {scope}`, `ui.relinkDialog`). Relink to Folder… stays as it is. - The Links panel menu's Copy Info ([Links panel](https://helpx.adobe.com/illustrator/desktop/add-and-import-files/import-from-other-apps/links-panel-in-illustrator.html)) copies the selected link's file name to the clipboard (`links.copyInfo`). VectorCraft's own rules: with several rows selected it copies one name per line in the order the panel shows them, an embedded image gives the name its row shows, and the item is off with no row selected. + - The Links panel menu's Unembed… works on several selected embedded images at once and writes them all to one chosen folder ([Embed and unembed images and files](https://helpx.adobe.com/illustrator/desktop/add-and-import-files/manage-linked-and-embedded-files/embed-images-and-files.html)): it asks for a folder once, writes a file for each image there and links each image to its file in one undo step (`links.unembed {ids, folder}`). VectorCraft's own rules: each file keeps the format its image is stored in (or PNG when that format is not one of VectorCraft's raster file formats) and is named after the image, a taken name gets a number (`Name 2`) and a file already in the folder is never replaced, linked rows in the selection are left as they are, and when one image can't be written the files already written are removed and nothing is unembedded. On the web each image is downloaded instead. Evidence: `unembed_to_a_folder_writes_each_image_and_links_it_in_one_undo_step`, `unembed_to_a_folder_that_fails_leaves_no_file_and_no_change`, `unembed_writes_several_images_to_one_picked_folder`. - Linked files inside symbols, graph designs, patterns and opacity masks are saved with their paths relative to the document, as linked files in the layers are, so they are found after the document and its files move to another folder together; on open each of those links takes the path where its file was found. Update Links, and opening with Update Links: Automatically, read a modified file again for that art too, and saving a document refreshes its placed copies inside symbols and patterns of the other open documents. Evidence: `links_outside_the_layers_find_their_files_after_the_folder_moves`, `update_links_reads_files_again_inside_symbols_patterns_and_masks`, `saving_a_document_refreshes_its_placed_copies_inside_symbols_and_patterns`. - A linked file that is missing when a moved document is saved keeps the folder its relative path names, instead of a relative path worked out from the out-of-date absolute path, also for a `.ai` file another app wrote (such as `src/`), so the file is found once it is back in that folder. Evidence: `a_missing_link_keeps_its_relative_path_when_the_moved_document_is_saved`, `links_of_an_imported_file_are_found_by_their_relative_folder`, `a_missing_link_of_a_moved_document_keeps_its_relative_place`. - On Windows, a document opened from a mapped network drive finds its links stored with the share's own path (`\\server\share\…`), as the same document opened from the share does; links on other computers stay missing.