diff --git a/crates/doc/src/text.rs b/crates/doc/src/text.rs index 25a2451968..073a0f2efd 100644 --- a/crates/doc/src/text.rs +++ b/crates/doc/src/text.rs @@ -7,6 +7,7 @@ use vectorcraft_geom::{Affine, PathData, Point, Rect, Vec2}; use crate::appearance::{Appearance, AppearanceItem, Dash, FillLayer, LineCap, LineJoin, StrokeAlign, StrokeLayer}; mod area; +mod attr_ranges; mod char_style; mod composite; mod file_fonts; @@ -18,6 +19,9 @@ mod tabs_lists; mod wrap; pub use area::{AreaFit, AreaOptions, PathAlign, PathEffect, TextFlow, TextWrap, VerticalAlign, WrapShape}; +pub use attr_ranges::{ + AttrRangeError, CHAR_MITER_LIMIT, CHAR_ROTATION, CHAR_SCALE, CHAR_SPACING, FONT_SIZE, LEADING, MAX_BASELINE_SHIFT, MAX_PARA_DISTANCE, +}; use char_style::yes; pub use char_style::{ CharAlign, CharPosition, CharStyle, Digits, FontHeightReference, GlyphChoice, GlyphForm, MAX_AKI, MAX_DIACRITIC_POSITION, MAX_TSUME, diff --git a/crates/doc/src/text/attr_ranges.rs b/crates/doc/src/text/attr_ranges.rs new file mode 100644 index 0000000000..bce0098ac2 --- /dev/null +++ b/crates/doc/src/text/attr_ranges.rs @@ -0,0 +1,215 @@ +//! The ranges the character and paragraph style commands keep each numeric attribute to, checked +//! in one place: the style commands check the attributes a call changes, and type a plug-in +//! returns has every attribute checked. + +use std::fmt; +use std::ops::RangeInclusive; + +use super::{CharStyle, JustificationOptions, ParaStyle, TabStop}; + +/// Font size ([`CharStyle::size`]), in points. +pub const FONT_SIZE: RangeInclusive = 0.1..=1296.0; +/// Leading ([`CharStyle::leading`]) other than Auto, in points. +pub const LEADING: RangeInclusive = 0.1..=5000.0; +/// Horizontal and vertical scale ([`CharStyle::h_scale`], [`CharStyle::v_scale`]), in percent. +pub const CHAR_SCALE: RangeInclusive = 1.0..=10000.0; +/// Tracking, kerning and the space before a line's first character ([`CharStyle::tracking`], +/// [`CharStyle::kerning`], [`CharStyle::kerning_before`]), in 1/1000 em. +pub const CHAR_SPACING: RangeInclusive = -1000.0..=10000.0; +/// The largest baseline shift and Tate-chu-yoko Up/Down and Left/Right either way, in points. +pub const MAX_BASELINE_SHIFT: f64 = 1296.0; +/// Character rotation ([`CharStyle::rotation`]), in degrees. +pub const CHAR_ROTATION: RangeInclusive = -360.0..=360.0; +/// The miter limit of a character stroke ([`CharStyle::stroke_miter_limit`]). +pub const CHAR_MITER_LIMIT: RangeInclusive = 1.0..=500.0; +/// The largest paragraph indent, space before or after and Hyphenation Zone either way, in points. +pub const MAX_PARA_DISTANCE: f64 = 1296.0; + +/// An attribute outside the range the style commands keep it to. +#[derive(Clone, Debug, PartialEq)] +pub struct AttrRangeError { + /// The attribute's JSON name, a nested field after a dot (`hyphenation.zone`). + pub key: String, + /// What is wrong, naming the attribute. + pub message: String, +} + +impl fmt::Display for AttrRangeError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(&self.message) + } +} + +impl std::error::Error for AttrRangeError {} + +fn out(key: &str, message: String) -> AttrRangeError { + AttrRangeError { key: key.to_string(), message } +} + +/// `value` within `lo..=hi`, or the error naming `key` (a value that is not a number is outside). +fn within(key: &str, value: f64, lo: f64, hi: f64) -> Result<(), AttrRangeError> { + if (lo..=hi).contains(&value) { Ok(()) } else { Err(out(key, format!("`{key}` must be from {lo} to {hi}"))) } +} + +impl CharStyle { + /// Checks each numeric attribute `check` names, by its JSON key, against the range the + /// character style commands keep it to: size, leading, scales, tracking, kerning, baseline + /// shift, rotation, the character stroke's weight, miter limit and dashes, Small Caps, Insert + /// Aki, Tsume, diacritic positions, the Tate-chu-yoko offsets, the Warichu settings and the + /// variable font axes. The first attribute out of its range is the error. + pub fn check_ranges(&self, check: impl Fn(&str) -> bool) -> Result<(), AttrRangeError> { + for (key, value, range) in [("size", self.size, FONT_SIZE), ("h_scale", self.h_scale, CHAR_SCALE), ("v_scale", self.v_scale, CHAR_SCALE)] { + if check(key) { + within(key, value, *range.start(), *range.end())?; + } + } + if check("leading") && self.leading.is_some_and(|value| !LEADING.contains(&value)) { + let (lo, hi) = (LEADING.start(), LEADING.end()); + return Err(out("leading", format!("`leading` must be from {lo} to {hi}, or null for Auto"))); + } + let shift = MAX_BASELINE_SHIFT; + for (key, value) in [("baseline_shift", self.baseline_shift), ("tcyUpDown", self.tcy_up_down), ("tcyLeftRight", self.tcy_left_right)] { + if check(key) { + within(key, value, -shift, shift)?; + } + } + let spacing = [("tracking", Some(self.tracking)), ("kerning", self.kerning), ("kerningBefore", Some(self.kerning_before))]; + for (key, value) in spacing { + if check(key) + && let Some(value) = value + { + within(key, value, *CHAR_SPACING.start(), *CHAR_SPACING.end())?; + } + } + if check("rotation") { + within("rotation", self.rotation, *CHAR_ROTATION.start(), *CHAR_ROTATION.end())?; + } + for (key, value) in [("akiLeft", self.aki_left), ("akiRight", self.aki_right)] { + if check(key) { + within(key, value, 0.0, super::MAX_AKI)?; + } + } + if check("tsume") { + within("tsume", self.tsume, 0.0, super::MAX_TSUME)?; + } + let hi = super::MAX_DIACRITIC_POSITION; + for (key, value) in [("diacriticHorizontal", self.diacritic_horizontal), ("diacriticVertical", self.diacritic_vertical)] { + if check(key) { + within(key, value, -hi, hi)?; + } + } + let lines = super::WARICHU_LINES; + if check("warichuLines") && !lines.contains(&self.warichu_lines) { + return Err(out("warichuLines", format!("`warichuLines` must be a whole number from {} to {}", lines.start(), lines.end()))); + } + let scale = super::WARICHU_SCALE; + for (key, value, lo, hi) in + [("warichuGap", self.warichu_gap, 0.0, super::MAX_WARICHU_GAP), ("warichuScale", self.warichu_scale, *scale.start(), *scale.end())] + { + if check(key) { + within(key, value, lo, hi)?; + } + } + if check("stroke_width") { + within("stroke_width", self.stroke_width, 0.0, crate::MAX_COORD)?; + } + if check("stroke_miter_limit") { + within("stroke_miter_limit", self.stroke_miter_limit, *CHAR_MITER_LIMIT.start(), *CHAR_MITER_LIMIT.end())?; + } + if check("stroke_dash") + && let Some(dash) = &self.stroke_dash + { + for value in &dash.pattern { + within("stroke_dash.pattern", *value, 0.0, crate::MAX_COORD)?; + } + within("stroke_dash.offset", dash.offset, -crate::MAX_COORD, crate::MAX_COORD)?; + } + if check("small_caps") + && let Some(value) = self.small_caps + { + within("small_caps", value, 1.0, crate::setup::MAX_SMALL_CAPS)?; + } + if check("fontAxes") + && let Some((tag, _)) = self.font_axes.iter().find(|(_, v)| !v.is_finite()) + { + return Err(out("fontAxes", format!("`fontAxes`: the setting of axis `{tag}` must be a number"))); + } + Ok(()) + } +} + +impl ParaStyle { + /// Checks each paragraph attribute `check` names, by its JSON key and for a nested option its + /// field, against the range the paragraph style commands keep it to: the indents and the space + /// before and after, each Hyphenation option, each Justification option in `justification` + /// (the options as given, since reading a paragraph style brings them into range) with + /// Minimum, Desired and Maximum in order, and the number of tab stops with the position and + /// leader of each stop that is not in `kept_tabs`. The first attribute out of its range is the + /// error. + pub fn check_ranges( + &self, + justification: Option<&JustificationOptions>, + kept_tabs: &[TabStop], + check: impl Fn(&str, Option<&str>) -> bool, + ) -> Result<(), AttrRangeError> { + for (key, value) in [ + ("left_indent", self.left_indent), + ("right_indent", self.right_indent), + ("first_line_indent", self.first_line_indent), + ("space_before", self.space_before), + ("space_after", self.space_after), + ] { + if check(key, None) { + within(key, value, -MAX_PARA_DISTANCE, MAX_PARA_DISTANCE)?; + } + } + let h = &self.hyphenation; + for (field, value, lo, hi) in [ + ("words_longer_than", f64::from(h.words_longer_than), 1.0, 25.0), + ("after_first", f64::from(h.after_first), 1.0, 15.0), + ("before_last", f64::from(h.before_last), 1.0, 15.0), + ("hyphen_limit", f64::from(h.hyphen_limit), 0.0, 25.0), + ("zone", h.zone, 0.0, MAX_PARA_DISTANCE), + ] { + if check("hyphenation", Some(field)) { + within(&format!("hyphenation.{field}"), value, lo, hi)?; + } + } + if let Some(j) = justification { + for (field, values, (lo, hi)) in [ + ("word_spacing", j.word_spacing, JustificationOptions::WORD_SPACING), + ("letter_spacing", j.letter_spacing, JustificationOptions::LETTER_SPACING), + ("glyph_scaling", j.glyph_scaling, JustificationOptions::GLYPH_SCALING), + ] { + if !check("justification", Some(field)) { + continue; + } + let name = format!("justification.{field}"); + for value in values { + within(&name, value, lo, hi)?; + } + if !(values[0] <= values[1] && values[1] <= values[2]) { + return Err(out(&name, format!("`{name}`: Minimum must not exceed Desired, nor Desired Maximum"))); + } + } + if check("justification", Some("auto_leading")) { + let (lo, hi) = JustificationOptions::AUTO_LEADING; + within("justification.auto_leading", j.auto_leading, lo, hi)?; + } + } + if check("tabs", None) { + let max = TabStop::MAX_STOPS; + if self.tabs.len() > max.max(kept_tabs.len()) { + return Err(out("tabs", format!("at most {max} tab stops"))); + } + for stop in self.tabs.iter().filter(|stop| !kept_tabs.contains(stop)) { + within("tabs.position", stop.position, 0.0, TabStop::MAX_POSITION)?; + let (label, max) = ("`tabs.leader`", TabStop::MAX_LEADER); + if stop.leader.chars().count() > max { + return Err(out("tabs.leader", format!("{label} must be at most {max} characters"))); + } + } + } + Ok(()) + } +} diff --git a/crates/doc/src/text/tests.rs b/crates/doc/src/text/tests.rs index b3cff3aa47..9371947565 100644 --- a/crates/doc/src/text/tests.rs +++ b/crates/doc/src/text/tests.rs @@ -802,6 +802,45 @@ fn auto_alignment_saves_readable_by_older_builds() { assert_eq!(serde_json::from_str::(r#"{"justify":"Center"}"#).unwrap().justify, Justify::Center); } +/// The default character and paragraph styles are in range, and each number outside its range, +/// one that is not a number included, is the error naming its attribute; an attribute the check +/// is not asked about is not checked. +#[test] +fn style_ranges_name_the_attribute_out_of_range() { + let all = |_: &str| true; + assert_eq!(CharStyle::default().check_ranges(all), Ok(())); + let key = |s: CharStyle| s.check_ranges(all).map_err(|e| e.key); + let d = CharStyle::default(); + assert_eq!(key(CharStyle { baseline_shift: f64::NAN, ..d.clone() }), Err("baseline_shift".into())); + assert_eq!(key(CharStyle { leading: Some(1e9), ..d.clone() }), Err("leading".into())); + assert_eq!(key(CharStyle { v_scale: 0.0, ..d.clone() }), Err("v_scale".into())); + assert_eq!(key(CharStyle { kerning: Some(f64::INFINITY), ..d.clone() }), Err("kerning".into())); + assert_eq!(key(CharStyle { rotation: 720.0, ..d.clone() }), Err("rotation".into())); + assert_eq!(key(CharStyle { warichu_lines: 9, ..d.clone() }), Err("warichuLines".into())); + assert_eq!(key(CharStyle { stroke_miter_limit: 0.0, ..d.clone() }), Err("stroke_miter_limit".into())); + assert_eq!(key(CharStyle { small_caps: Some(0.0), ..d.clone() }), Err("small_caps".into())); + let axes = std::iter::once(("wght".to_string(), f64::NAN)).collect(); + assert_eq!(key(CharStyle { font_axes: axes, ..d.clone() }), Err("fontAxes".into())); + let dash = Some(Dash { pattern: vec![2.0, -1.0], offset: 0.0, align_corners: false }); + assert_eq!(key(CharStyle { stroke_dash: dash, ..d.clone() }), Err("stroke_dash.pattern".into())); + assert_eq!(CharStyle { size: 0.0, ..d.clone() }.check_ranges(|k| k != "size"), Ok(())); + + let all = |_: &str, _: Option<&str>| true; + let p = ParaStyle::default(); + assert_eq!(p.check_ranges(Some(&JustificationOptions::default()), &[], all), Ok(())); + let key = |s: ParaStyle, j: Option<&JustificationOptions>| s.check_ranges(j, &[], all).map_err(|e| e.key); + assert_eq!(key(ParaStyle { first_line_indent: f64::NAN, ..p.clone() }, None), Err("first_line_indent".into())); + let stop = TabStop { position: 1.0, align: TabAlign::Left, leader: String::new(), align_on: '.' }; + assert_eq!(key(ParaStyle { tabs: vec![stop.clone(); TabStop::MAX_STOPS + 1], ..p.clone() }, None), Err("tabs".into())); + let far = TabStop { position: -1.0, ..stop.clone() }; + assert_eq!(key(ParaStyle { tabs: vec![far.clone()], ..p.clone() }, None), Err("tabs.position".into())); + assert_eq!(ParaStyle { tabs: vec![far.clone()], ..p.clone() }.check_ranges(None, &[far], all), Ok(()), "a kept stop"); + let hyphenation = HyphenationOptions { hyphen_limit: 99, ..HyphenationOptions::default() }; + assert_eq!(key(ParaStyle { hyphenation, ..p.clone() }, None), Err("hyphenation.hyphen_limit".into())); + let reversed = JustificationOptions { word_spacing: [133.0, 100.0, 80.0], ..JustificationOptions::default() }; + assert_eq!(key(p.clone(), Some(&reversed)), Err("justification.word_spacing".into())); +} + #[test] fn file_fonts_draw_type_only_while_its_text_is_the_files() { use super::file_fonts::*; diff --git a/crates/engine/src/cmd/panelcmds.rs b/crates/engine/src/cmd/panelcmds.rs index 13f7051223..77cdfdcb7d 100644 --- a/crates/engine/src/cmd/panelcmds.rs +++ b/crates/engine/src/cmd/panelcmds.rs @@ -420,7 +420,7 @@ pub(crate) fn push_artboard_copy(d: &mut vectorcraft_doc::Document, src: &vector // ---------- text ---------- /// Largest indent or paragraph spacing (points; Illustrator's limit). -const MAX_PARA: f64 = 1296.0; +const MAX_PARA: f64 = vectorcraft_doc::text::MAX_PARA_DISTANCE; /// `text.setFormat`'s `bullet` values and the bullets they pick. const BULLETS: [(&str, vectorcraft_doc::text::Bullet); 4] = [ diff --git a/crates/engine/src/cmd/plugin.rs b/crates/engine/src/cmd/plugin.rs index 6f8ce2256f..7203149212 100644 --- a/crates/engine/src/cmd/plugin.rs +++ b/crates/engine/src/cmd/plugin.rs @@ -42,7 +42,9 @@ //! //! A filter whose manifest lists `inputs` (plug-in API level 2) is also given the selected type, //! images or symbol instances of those kinds, to read only: its output must return each of them -//! unchanged ([`objects::decode_output_with`]). +//! unchanged ([`objects::decode_output_with`]). At level 3 its manifest's `writes` lists the kinds +//! among them it may change: type's runs and paragraph styles, an image's transform and opacity, +//! an instance's symbol and transform, and each one's name ([`objects::decode_output_writing`]). //! //! A filter, or a live effect's command, whose manifest lists `context` (plug-in API level 3) is //! also given the parts of the active document it names in `_context.document`, whether or not @@ -53,7 +55,7 @@ use std::collections::HashMap; use std::sync::{Arc, Mutex, RwLock}; use serde_json::{Map, Value, json}; -use vectorcraft_doc::{Document, Effect, Node}; +use vectorcraft_doc::{Document, Effect, Node, NodeKind}; use vectorcraft_plugins::{Budget, Command, Kind, Plugin, effect, export, objects, registry, safe_mode}; use super::{CommandSpec, EngineError, NodeId, Result, Session, always, bad, cmd, has_doc, ids_param, str_param, switch_or}; @@ -113,6 +115,9 @@ pub fn describe(p: &Plugin) -> Value { if !m.inputs.is_empty() { v["inputs"] = json!(m.inputs); } + if !m.writes.is_empty() { + v["writes"] = json!(m.writes); + } if !m.context.is_empty() { v["context"] = json!(m.context); } @@ -377,7 +382,7 @@ impl FilterRun { fn finish(self, s: &mut Session, output: &[u8]) -> Result { let m = self.plugin.manifest(); let may = m.permissions(); - let out = objects::decode_output_with(output, &self.input, &self.read_only).map_err(err)?; + let out = objects::decode_output_writing(output, &self.input, &self.read_only, &m.write_kinds()).map_err(err)?; if out.document_data.is_some() && !may.contains(&Permission::State) { return Err(not_granted(&m.name, Permission::State)); } @@ -393,18 +398,52 @@ impl FilterRun { if s.script_running() { return Err(EngineError::Busy); } - if !s.previewing && super::typing_in_progress(s) { + // Typing whose text Real-time Drawing off left out of the document isn't in what the + // plug-in was given, and the output would replace it ([`keep_unapplied_typing`] keeps it + // before the run is prepared). + if unapplied_typing(s) { + return Err(err(vectorcraft_plugins::Error::Output( + "typing in progress isn't in what the plug-in was given: nothing was changed".into(), + ))); + } + let data = out.document_data; + // The output applied to `now`, with the checks that refuse it. + let build = |now: &Document, objects: Vec| -> Result<(Document, Vec)> { + let mut d = now.clone(); + let before = (!may_write).then(|| d.layers.clone()); + let ids = objects::apply_output(&mut d, &inputs, objects, parent, &admit_effects).map_err(err)?; + if before.is_some_and(|b| b != d.layers) { + return Err(not_granted(&m.name, Permission::DocWrite)); + } + // Type whose text the output changed is laid out again. + let retyped: Vec = ids + .iter() + .copied() + .filter(|&id| match (d.node(id).map(|n| &n.kind), now.node(id).map(|n| &n.kind)) { + (Some(NodeKind::Text(new)), Some(NodeKind::Text(old))) => new.runs != old.runs || new.paras != old.paras || new.para != old.para, + _ => false, + }) + .collect(); + super::typecmd::refresh_bounds_of(&mut d, &retyped); + if let Some(data) = data.clone() { + d.set_plugin_data(&m.id, data); + } + Ok((d, ids)) + }; + // Typing in progress, its text already in the document, is kept as `s.edit` keeps it once + // nothing can refuse the output, so a refused output leaves it in progress. Keeping it can + // change the document, and the output is then applied to the document as kept. + let typing = !s.previewing && super::typing_in_progress(s); + let again = typing.then(|| out.objects.clone()); + let mut now = s.doc()?.doc.clone(); + let (mut d, mut ids) = build(&now, out.objects)?; + if let Some(objects) = again { super::settle_interaction(s)?; - } - let now = s.doc()?.doc.clone(); - let mut d = (*now).clone(); - let before = (!may_write).then(|| d.layers.clone()); - let ids = objects::apply_output(&mut d, &inputs, out.objects, parent, &admit_effects).map_err(err)?; - if before.is_some_and(|b| b != d.layers) { - return Err(not_granted(&m.name, Permission::DocWrite)); - } - if let Some(data) = out.document_data { - d.set_plugin_data(&m.id, data); + let kept = s.doc()?.doc.clone(); + if !Arc::ptr_eq(&kept, &now) { + now = kept; + (d, ids) = build(&now, objects)?; + } } let selectable = |d: &Document| ids.iter().copied().filter(|&id| d.node(id).is_some_and(objects::selectable)).collect::>(); if same_art(&d.layers, &now.layers) && d.plugin_data(&m.id) == now.plugin_data(&m.id) { @@ -447,6 +486,23 @@ fn not_granted(name: &str, permission: Permission) -> EngineError { err(vectorcraft_plugins::Error::Output(format!("“{name}” wasn't granted `{p}`, which its output needs: nothing was changed"))) } +/// Is typing in progress whose text Real-time Drawing off left out of the document (not in a +/// preview's run)? A run prepared now isn't given that text. +pub fn unapplied_typing(s: &Session) -> bool { + !s.previewing && super::typing_in_progress(s) && s.unapplied_interaction_preview().is_some() +} + +/// Keeps typing in progress whose text Real-time Drawing off left out of the document +/// ([`super::settle_interaction`]) → whether there was any. A run prepared after it is given the +/// typed text; one prepared before it is prepared again. +pub fn keep_unapplied_typing(s: &mut Session) -> Result { + if !unapplied_typing(s) { + return Ok(false); + } + super::settle_interaction(s)?; + Ok(true) +} + /// `plugin.run`: runs filter `id` on `ids` (else the selected paths and compound paths) with its /// parameters and `_context` (what it keeps with the document included), and applies its output as /// one undo step ([`objects::apply_output`]; effect records as [`admit_effects`] admits them), with @@ -464,6 +520,8 @@ fn run(s: &mut Session, p: &Value) -> Result { let r = if super::plugin_call::settle(s)? { FilterRun::prepare(s, p)? } else { r }; return r.run_with_calls(s); } + // Typing Real-time Drawing off left out of the document is kept first, so the plug-in is given it. + let r = if keep_unapplied_typing(s)? { FilterRun::prepare(s, p)? } else { r }; // Handed in for this very run (the app ran it in the background), it is what running the // plug-in again would return. let handed = handed.filter(|h| (h.serial, &h.input, &h.params) == (r.plugin.serial(), &r.input, &r.params)); @@ -887,6 +945,13 @@ pub(crate) fn run_command(s: &mut Session, id: &str, p: &Value) -> Result }; return r.run_with_calls(s).map_err(failed); } + let r = match keep_unapplied_typing(s)? { + true => { + let (plugin, command) = command_of(id).ok_or_else(|| EngineError::UnknownCommand(id.into()))?; + FilterRun::prepare_with(s, plugin, Some(command), id, p)? + } + false => r, + }; let output = r.run().map_err(&failed)?; r.finish(s, &output).map_err(failed) } @@ -1860,7 +1925,7 @@ pub fn specs() -> Vec { "List Plug-ins", [], None, - "{} → {plugins: [{id, name, version, kind: \"filter\"|\"effect\"|\"exporter\"|\"importer\", author, description, params (doc), paramsSchema, effect? (the effect id of a live effect: plugin.), format? and extensions? (an exporter's or importer's format id, plugin., for document.export or document.open's importer, and its file extensions), place?: true (an importer whose files file.place also reads, see file.place's importer), budget?: \"heavy\" (a filter that may compute for longer, see plugin.install's allowHeavy), inputs?: [\"type\"|\"image\"|\"symbolInstance\"] (the objects besides paths a filter reads, see plugin.run), context?: [\"settings\"|\"artboards\"|\"layers\"|\"swatches\"] (the parts of the active document a filter's runs and its or a live effect's commands are given in _context.document, with or without a selection, see docs/plugins.md), size, source, permissions: [name] (what it may do: the ones its manifest lists, else the ones its kind implies; progress: it may report its progress, see Cancel and write log lines; settings: it may keep settings of its own; cache: it may keep a cache of its own; commands: a filter may run the commands its commandAllowlist names, see docs/plugins.md), commandAllowlist?: [command id] (the commands a filter with the commands permission may run while it runs, with vc_call), hash (the module's SHA-256), api (the plug-in API level it was built for, 1, 2 or 3), paintOutput?: true (a live effect whose pieces have paints of their own, see docs/plugins.md), cacheBytes (the bytes its cache holds; see plugin.clearCache), commands?: [{id, command (its command id, plugin.., which runs it), label, params (doc), paramsSchema, menu?: {path: [menu label], after?: item label (escaped), placed?: false (it stays in its plug-in's submenu: its label reads like a built-in item or submenu of that menu or another plug-in command placed there)} (the menu its manifest places it in, see docs/plugins.md)}] (the menu commands a filter or live effect adds)}], folder: the Additional Plug-ins Folder load report {folder, loaded, failed: [{file, error}], leftOut} | null (under automation read roots, a folder outside them is null, and a failed file and a plug-in's source outside them are named by their file name), safeMode: bool (no plug-in loads or runs, see plugin.safeMode), disabled: [{id, file, name, label}] (turned off for the next launch, see plugin.setEnabled)}", + "{} → {plugins: [{id, name, version, kind: \"filter\"|\"effect\"|\"exporter\"|\"importer\", author, description, params (doc), paramsSchema, effect? (the effect id of a live effect: plugin.), format? and extensions? (an exporter's or importer's format id, plugin., for document.export or document.open's importer, and its file extensions), place?: true (an importer whose files file.place also reads, see file.place's importer), budget?: \"heavy\" (a filter that may compute for longer, see plugin.install's allowHeavy), inputs?: [\"type\"|\"image\"|\"symbolInstance\"] (the objects besides paths a filter reads, see plugin.run), writes?: [\"type\"|\"image\"|\"symbolInstance\"] (the kinds among inputs a filter may change, see plugin.run), context?: [\"settings\"|\"artboards\"|\"layers\"|\"swatches\"] (the parts of the active document a filter's runs and its or a live effect's commands are given in _context.document, with or without a selection, see docs/plugins.md), size, source, permissions: [name] (what it may do: the ones its manifest lists, else the ones its kind implies; progress: it may report its progress, see Cancel and write log lines; settings: it may keep settings of its own; cache: it may keep a cache of its own; commands: a filter may run the commands its commandAllowlist names, see docs/plugins.md), commandAllowlist?: [command id] (the commands a filter with the commands permission may run while it runs, with vc_call), hash (the module's SHA-256), api (the plug-in API level it was built for, 1, 2 or 3), paintOutput?: true (a live effect whose pieces have paints of their own, see docs/plugins.md), cacheBytes (the bytes its cache holds; see plugin.clearCache), commands?: [{id, command (its command id, plugin.., which runs it), label, params (doc), paramsSchema, menu?: {path: [menu label], after?: item label (escaped), placed?: false (it stays in its plug-in's submenu: its label reads like a built-in item or submenu of that menu or another plug-in command placed there)} (the menu its manifest places it in, see docs/plugins.md)}] (the menu commands a filter or live effect adds)}], folder: the Additional Plug-ins Folder load report {folder, loaded, failed: [{file, error}], leftOut} | null (under automation read roots, a folder outside them is null, and a failed file and a plug-in's source outside them are named by their file name), safeMode: bool (no plug-in loads or runs, see plugin.safeMode), disabled: [{id, file, name, label}] (turned off for the next launch, see plugin.setEnabled)}", always, list ), @@ -1878,7 +1943,7 @@ pub fn specs() -> Vec { "Run Plug-in", [], None, - "{id, params?: {…} (the plug-in's parameters; or give them as top-level keys; missing ones take their defaults, see plugin.info), ids?: [object id] (left out or null: the selection), …the plug-in's parameters as top-level keys} run an object filter on the selected paths and compound paths (inside selected groups and layers too; hidden, locked, guide and clipping paths, compound paths that clip a clip group and paths inside a group that clips one are left out): it may change, delete or add objects, as one undo step (an output that changes no object and no kept data records none and leaves the document unmodified); the result is selected, except the objects it locked or made guides. A filter whose manifest lists inputs (type, image, symbolInstance; it lists doc.read in permissions, so plugin.install needs grant) is also given the selected objects of those kinds to read, in paint order from the bottom, with at most 16 MiB of pixels and 16 MiB of type runs per run (an object that doesn't fit what the objects before it left comes with pixelsOmitted or truncated; an image that reaches the decoder counts toward the pixels even when decoding fails); every object counts toward the input's half of the plug-in's memory cap, ids, bounds, transforms and names included, and an object whose fields besides its pixels and runs don't fit fails the run with a memory-budget error naming it and its size (a path or compound path fails it with the memory-budget error for a selection too large to hand over), and more than 100,000 of these objects fail it with an object-budget error: its output returns each as {id} or exactly as given, or the run is refused and nothing changes. With nothing selected it gets no objects (generators add theirs to the current layer). A filter with a commandAllowlist runs the commands it names while it runs (vc_call, see docs/plugins.md): its calls and its output are one undo step, and a run that fails or makes a call that fails changes nothing → {plugin, ids, notice?, pluginName?} (notice: the text the output reports in its notice key once applied, escaped and cut at 200 characters; pluginName: the plug-in's name, with it)", + "{id, params?: {…} (the plug-in's parameters; or give them as top-level keys; missing ones take their defaults, see plugin.info), ids?: [object id] (left out or null: the selection), …the plug-in's parameters as top-level keys} run an object filter on the selected paths and compound paths (inside selected groups and layers too; hidden, locked, guide and clipping paths, compound paths that clip a clip group and paths inside a group that clips one are left out): it may change, delete or add objects, as one undo step (an output that changes no object and no kept data records none and leaves the document unmodified); the result is selected, except the objects it locked or made guides. A filter whose manifest lists inputs (type, image, symbolInstance; it lists doc.read in permissions, so plugin.install needs grant) is also given the selected objects of those kinds to read, in paint order from the bottom, with at most 16 MiB of pixels and 16 MiB of type runs per run (an object that doesn't fit what the objects before it left comes with pixelsOmitted or truncated; an image that reaches the decoder counts toward the pixels even when decoding fails); every object counts toward the input's half of the plug-in's memory cap, ids, bounds, transforms and names included, and an object whose fields besides its pixels and runs don't fit fails the run with a memory-budget error naming it and its size (a path or compound path fails it with the memory-budget error for a selection too large to hand over), and more than 100,000 of these objects fail it with an object-budget error: its output returns each as {id} or exactly as given (an image may leave out opacity), or the run is refused and nothing changes. A filter at api 3 whose manifest lists some of those kinds in writes (with doc.write) may return an object of such a kind with only the fields it changes: name and transform (6 numbers within ±4,000,000 that don't flatten it), type's text.runs ({text, style, inline?} with the native character attributes; inline graphics stay as they were; at most 4,096 runs, 4,096 paragraphs and 256 KiB of text; every number of every run's style in the range charStyle.new takes, fills and strokes with only the keys their type reads, and a style of its own needs a font family) and text.paragraphs (one style per paragraph, also when given as they were next to changed runs, each number in the range paraStyle.new takes, a custom Kinsoku set only one of the document's by name), an image's opacity (0 to 1), an instance's symbolId (a symbol in the document); any other field changed, or a value out of range, refuses the run naming the object and the field, and nothing changes. With nothing selected it gets no objects (generators add theirs to the current layer). A filter with a commandAllowlist runs the commands it names while it runs (vc_call, see docs/plugins.md): its calls and its output are one undo step, and a run that fails or makes a call that fails changes nothing → {plugin, ids, notice?, pluginName?} (notice: the text the output reports in its notice key once applied, escaped and cut at 200 characters; pluginName: the plug-in's name, with it)", has_doc, run ), diff --git a/crates/engine/src/cmd/textstyles.rs b/crates/engine/src/cmd/textstyles.rs index cde1456589..1d3c8f7d7b 100644 --- a/crates/engine/src/cmd/textstyles.rs +++ b/crates/engine/src/cmd/textstyles.rs @@ -157,13 +157,13 @@ pub fn specs() -> Vec { "charStyle", "Character Styles", "Character", - "; changed numeric attrs: size 0.1..=1296 pt, explicit leading 0.1..=5000 pt, h/v scale 1..=10000%, baseline shift and Tate-chu-yoko offsets -1296..=1296 pt" + "; changed numeric attrs: size 0.1..=1296 pt, explicit leading 0.1..=5000 pt, h/v scale 1..=10000%, baseline shift and Tate-chu-yoko offsets -1296..=1296 pt, tracking and kerning -1000..=10000, rotation -360..=360°, stroke miter limit 1..=500, Small Caps 1..=200%, finite stroke dashes and variable font axis settings" ); v.push(spec( "charStyle.edit", "Edit Character Style", &[], - "{name, to, attrs: {…}} replace name and sparse attributes in one undo step; users keep local overrides; changed numeric attrs: size 0.1..=1296 pt, explicit leading 0.1..=5000 pt, h/v scale 1..=10000%, baseline shift and Tate-chu-yoko offsets -1296..=1296 pt", + "{name, to, attrs: {…}} replace name and sparse attributes in one undo step; users keep local overrides; changed numeric attrs: size 0.1..=1296 pt, explicit leading 0.1..=5000 pt, h/v scale 1..=10000%, baseline shift and Tate-chu-yoko offsets -1296..=1296 pt, tracking and kerning -1000..=10000, rotation -360..=360°, stroke miter limit 1..=500, Small Caps 1..=200%, finite stroke dashes and variable font axis settings", |s, p| edit_style(s, p, Kind::Char), true, )); @@ -636,52 +636,7 @@ fn attrs_param(d: &Document, p: &Value, kind: Kind, verb: &str, kept: Option<&Ma } let mut st = with_attrs(&CharStyle::default(), m, &c)?; let changed = |key: &str| m.contains_key(key) && kept.and_then(|k| k.get(key)) != m.get(key); - for (key, value, lo, hi) in - [("size", st.size, 0.1, 1296.0), ("h_scale", st.h_scale, 1.0, 10000.0), ("v_scale", st.v_scale, 1.0, 10000.0)] - { - if changed(key) && !(lo..=hi).contains(&value) { - return Err(bad(&c, format!("`{key}` must be from {lo} to {hi}"))); - } - } - if changed("leading") && st.leading.is_some_and(|value| !(0.1..=5000.0).contains(&value)) { - return Err(bad(&c, "`leading` must be from 0.1 to 5000, or null for Auto")); - } - let shift_max = 1296.0; - for (key, value) in [("baseline_shift", st.baseline_shift), ("tcyUpDown", st.tcy_up_down), ("tcyLeftRight", st.tcy_left_right)] { - if changed(key) && !(-shift_max..=shift_max).contains(&value) { - return Err(bad(&c, format!("`{key}` must be from {} to {shift_max}", -shift_max))); - } - } - let (lo, hi) = (0.0, vectorcraft_doc::text::MAX_AKI); - for (key, value) in [("akiLeft", st.aki_left), ("akiRight", st.aki_right)] { - if changed(key) && !(lo..=hi).contains(&value) { - return Err(bad(&c, format!("`{key}` must be from {lo} to {hi}"))); - } - } - let (key, lo, hi) = ("tsume", 0.0, vectorcraft_doc::text::MAX_TSUME); - if changed(key) && !(lo..=hi).contains(&st.tsume) { - return Err(bad(&c, format!("`{key}` must be from {lo} to {hi}"))); - } - let hi = vectorcraft_doc::text::MAX_DIACRITIC_POSITION; - let lo = -hi; - for (key, value) in [("diacriticHorizontal", st.diacritic_horizontal), ("diacriticVertical", st.diacritic_vertical)] { - if changed(key) && !(lo..=hi).contains(&value) { - return Err(bad(&c, format!("`{key}` must be from {lo} to {hi}"))); - } - } - let lines = vectorcraft_doc::text::WARICHU_LINES; - if changed("warichuLines") && !lines.contains(&st.warichu_lines) { - return Err(bad(&c, format!("`warichuLines` must be a whole number from {} to {}", lines.start(), lines.end()))); - } - let scale = vectorcraft_doc::text::WARICHU_SCALE; - for (key, value, lo, hi) in [ - ("warichuGap", st.warichu_gap, 0.0, vectorcraft_doc::text::MAX_WARICHU_GAP), - ("warichuScale", st.warichu_scale, *scale.start(), *scale.end()), - ] { - if changed(key) && !(lo..=hi).contains(&value) { - return Err(bad(&c, format!("`{key}` must be from {lo} to {hi}"))); - } - } + st.check_ranges(changed).map_err(|e| bad(&c, e.message))?; // A language of the list, stored as its tag (as text.setFormat takes it). if let Some(l) = &st.language && kept.and_then(|k| k.get("language")) != m.get("language") @@ -693,10 +648,6 @@ fn attrs_param(d: &Document, p: &Value, kind: Kind, verb: &str, kept: Option<&Ma style_paint(d, paint, key, &c)?; } } - let (key, lo, hi) = ("stroke_width", 0.0, vectorcraft_doc::MAX_COORD); - if changed(key) && !(lo..=hi).contains(&st.stroke_width) { - return Err(bad(&c, format!("`{key}` must be from {lo} to {hi}"))); - } if changed("features") { style_features(&st.features, kept, &c)?; } @@ -753,85 +704,20 @@ fn attrs_param(d: &Document, p: &Value, kind: Kind, verb: &str, kept: Option<&Ma } } -/// The range of a paragraph style's indents, space before and space after, and Hyphenation Zone (pt), -/// as `text.setFormat` keeps them. -const PARA_DISTANCE: f64 = 1296.0; - /// Check the paragraph attributes of `st` (read from `attrs`) that differ from `kept` against the -/// ranges `text.setFormat` keeps them to: the indents and the space before and after, each -/// Hyphenation option, each Justification option (Minimum, Desired and Maximum in order, as -/// `attrs` gives them), and the number of tab stops with the position and leader of each stop -/// `kept` does not hold. A value `kept` has is not checked. +/// ranges `text.setFormat` keeps them to ([`ParaStyle::check_ranges`]), the Justification options +/// as `attrs` gives them. A value `kept` has is not checked. fn para_ranges(st: &ParaStyle, attrs: &Map, kept: Option<&Map>, c: &str) -> Result<()> { - let within = |key: &str, value: f64, lo: f64, hi: f64| { - if (lo..=hi).contains(&value) { Ok(()) } else { Err(bad(c, format!("`{key}` must be from {lo} to {hi}"))) } - }; let changed = |key: &str| attrs.contains_key(key) && kept.and_then(|k| k.get(key)) != attrs.get(key); - let nested_changed = |key: &str, field: &str| { - changed(key) && attrs.get(key).and_then(|v| v.get(field)) != kept.and_then(|k| k.get(key)).and_then(|v| v.get(field)) + let check = |key: &str, field: Option<&str>| match field { + None => changed(key), + Some(field) => changed(key) && attrs.get(key).and_then(|v| v.get(field)) != kept.and_then(|k| k.get(key)).and_then(|v| v.get(field)), }; - for (key, value) in [ - ("left_indent", st.left_indent), - ("right_indent", st.right_indent), - ("first_line_indent", st.first_line_indent), - ("space_before", st.space_before), - ("space_after", st.space_after), - ] { - if changed(key) { - within(key, value, -PARA_DISTANCE, PARA_DISTANCE)?; - } - } - let h = &st.hyphenation; - for (field, value, lo, hi) in [ - ("words_longer_than", f64::from(h.words_longer_than), 1.0, 25.0), - ("after_first", f64::from(h.after_first), 1.0, 15.0), - ("before_last", f64::from(h.before_last), 1.0, 15.0), - ("hyphen_limit", f64::from(h.hyphen_limit), 0.0, 25.0), - ("zone", h.zone, 0.0, PARA_DISTANCE), - ] { - if nested_changed("hyphenation", field) { - within(&format!("hyphenation.{field}"), value, lo, hi)?; - } - } // Read as given: a paragraph's attributes keep justification options in range as they load. - if let Some(given) = attrs.get("justification").filter(|_| changed("justification")) { - let j: vectorcraft_doc::JustificationOptions = serde_json::from_value(given.clone()).map_err(|e| bad(c, e.to_string()))?; - for (field, values, (lo, hi)) in [ - ("word_spacing", j.word_spacing, vectorcraft_doc::JustificationOptions::WORD_SPACING), - ("letter_spacing", j.letter_spacing, vectorcraft_doc::JustificationOptions::LETTER_SPACING), - ("glyph_scaling", j.glyph_scaling, vectorcraft_doc::JustificationOptions::GLYPH_SCALING), - ] { - if !nested_changed("justification", field) { - continue; - } - let name = format!("justification.{field}"); - for value in values { - within(&name, value, lo, hi)?; - } - if !(values[0] <= values[1] && values[1] <= values[2]) { - return Err(bad(c, format!("`{name}`: Minimum must not exceed Desired, nor Desired Maximum"))); - } - } - if nested_changed("justification", "auto_leading") { - let (lo, hi) = vectorcraft_doc::JustificationOptions::AUTO_LEADING; - within("justification.auto_leading", j.auto_leading, lo, hi)?; - } - } - if changed("tabs") { - let kept_tabs = kept_tab_stops(kept); - let max = TabStop::MAX_STOPS; - if st.tabs.len() > max.max(kept_tabs.len()) { - return Err(bad(c, format!("at most {max} tab stops"))); - } - for stop in st.tabs.iter().filter(|stop| !kept_tabs.contains(stop)) { - within("tabs.position", stop.position, 0.0, TabStop::MAX_POSITION)?; - let (label, max) = ("`tabs.leader`", TabStop::MAX_LEADER); - if stop.leader.chars().count() > max { - return Err(bad(c, format!("{label} must be at most {max} characters"))); - } - } - } - Ok(()) + let given = attrs.get("justification").filter(|_| changed("justification")); + let justification: Option = + given.map(|g| serde_json::from_value(g.clone())).transpose().map_err(|e| bad(c, e.to_string()))?; + st.check_ranges(justification.as_ref(), &kept_tab_stops(kept), check).map_err(|e| bad(c, e.message)) } /// The tab stops `kept` holds, each as it reads (a stop that does not read is left out). @@ -1204,17 +1090,22 @@ fn unused(s: &mut Session, kind: Kind) -> Result { /// The styles of `kind` in `src` that load, with their source names so that art in the file keeps /// referring to them: not the Normal style, and not one whose attributes don't read, whose sizes, -/// scales, leading, shifts, Insert Aki, Tsume, diacritic positions, Warichu Settings or stroke width are out of the range `charStyle.new` takes, whose +/// scales, leading, tracking, kerning, shifts, rotation, Insert Aki, Tsume, diacritic positions, Warichu Settings, Small Caps, +/// variable font axes or stroke weight, miter limit or dashes are out of the range `charStyle.new` takes ([`CharStyle::check_ranges`]), whose /// indents, spacing, Hyphenation or Justification options or tab stops are out of the range /// `paraStyle.new` takes, or whose name is empty, which are skipped. → (the styles, the names in /// `src` of those skipped) fn loadable(src: &Document, kind: Kind) -> (Vec, Vec) { - const RANGED: [&str; 24] = [ + const RANGED: [&str; 32] = [ "size", "h_scale", "v_scale", "leading", + "tracking", + "kerning", + "kerningBefore", "baseline_shift", + "rotation", "akiLeft", "akiRight", "tsume", @@ -1226,6 +1117,10 @@ fn loadable(src: &Document, kind: Kind) -> (Vec, Vec) { "warichuGap", "warichuScale", "stroke_width", + "stroke_miter_limit", + "stroke_dash", + "small_caps", + "fontAxes", "left_indent", "right_indent", "first_line_indent", diff --git a/crates/engine/src/cmd/textstyles/tests.rs b/crates/engine/src/cmd/textstyles/tests.rs index e8f57aa14f..c0a92a20e3 100644 --- a/crates/engine/src/cmd/textstyles/tests.rs +++ b/crates/engine/src/cmd/textstyles/tests.rs @@ -401,6 +401,11 @@ fn character_style_dimensions_are_checked_before_a_definition_changes() { json!({"tsume": 100.1}), json!({"diacriticHorizontal": -1000.1}), json!({"diacriticVertical": 1000.1}), + json!({"tracking": -1000.1}), + json!({"kerning": 10000.1}), + json!({"rotation": 360.1}), + json!({"stroke_miter_limit": 0.9}), + json!({"small_caps": 200.1}), ] { let key = attrs.as_object().unwrap().keys().next().unwrap(); for cmd in ["charStyle.edit", "charStyle.setAttrs", "charStyle.new"] { @@ -425,7 +430,9 @@ fn character_style_dimensions_are_checked_before_a_definition_changes() { "tcyUpDown": 1296.0, "tcyLeftRight": -1296.0, "akiLeft": 0.0, "akiRight": 1000.0, "tsume": 100.0, - "diacriticHorizontal": -1000.0, "diacriticVertical": 1000.0 + "diacriticHorizontal": -1000.0, "diacriticVertical": 1000.0, + "tracking": 10000.0, "kerning": -1000.0, "rotation": -360.0, + "stroke_miter_limit": 500.0, "small_caps": 200.0 }}), ) .unwrap(); @@ -830,8 +837,8 @@ fn load_all_styles_loads_both_kinds_in_one_step() { assert_eq!(s.doc().unwrap().doc, before); } -/// A loaded character style whose size, scale, leading, shift, warichu Line Gap or stroke width is -/// out of the range `charStyle.new` takes is skipped. +/// A loaded character style whose size, scale, leading, shift, warichu Line Gap, stroke width or +/// miter limit, tracking, kerning or rotation is out of the range `charStyle.new` takes is skipped. #[test] fn loaded_styles_out_of_range_are_skipped() { let (mut s, _) = session_with_text("Title"); @@ -841,11 +848,17 @@ fn loaded_styles_out_of_range_are_skipped() { ("Shifted", json!({"baseline_shift": 5000.0})), ("Thick", json!({"stroke_width": -2.0})), ("Gapped", json!({"warichuGap": 500.0})), + ("Spun", json!({"rotation": 720.0})), + ("Tracked", json!({"tracking": 50000.0})), + ("Kerned", json!({"kerning": -5000.0})), + ("Before", json!({"kerningBefore": 50000.0})), + ("Mitered", json!({"stroke_miter_limit": 0.5})), ("Fine", json!({"size": 12.0, "h_scale": 50.0})), ]; let data = styles_file(&file, &[]); let r = s.execute("charStyle.load", &json!({"dataBase64": data, "name": "Other.vectorcraft"})).unwrap(); - assert_eq!(r, json!({"added": ["Fine"], "existing": [], "skipped": ["Huge", "Flat", "Shifted", "Thick", "Gapped"]})); + let skipped = ["Huge", "Flat", "Shifted", "Thick", "Gapped", "Spun", "Tracked", "Kerned", "Before", "Mitered"]; + assert_eq!(r, json!({"added": ["Fine"], "existing": [], "skipped": skipped})); assert_eq!(listed(&mut s, "charStyle"), [NORMAL_CHAR, "Fine"]); } diff --git a/crates/engine/src/tests/plugins.rs b/crates/engine/src/tests/plugins.rs index 0a255fb3a3..b82b16f272 100644 --- a/crates/engine/src/tests/plugins.rs +++ b/crates/engine/src/tests/plugins.rs @@ -4718,6 +4718,118 @@ fn read_only_kind_field_and_omission_refuse_without_undo() { assert!(e.contains("`inputs` needs `api` 2"), "{e}"); } +/// A filter at `api` 3 that lists type, images and symbol instances in `writes` changes a type +/// object's characters, an image's transform and opacity and the symbol an instance shows, as one +/// undo step that undo takes back and redo gives again, and the changes are kept when the document +/// is saved and opened. An echo records no undo step; a refused write, and a write by a filter that +/// lists the kinds in `inputs` alone, leave the document and the history as they were. +#[test] +fn a_filter_that_writes_type_images_and_instances_is_one_undo_step() { + use std::sync::Arc; + use vectorcraft_doc::{Appearance, Node, NodeKind, Symbol}; + use vectorcraft_geom::Affine; + let mut s = session(); + let r = rect(&mut s, 10.0, "#ff0000"); + let t = NodeId(run(&mut s, "text.create", json!({"x": 10, "y": 80, "text": "Hi"}))["id"].as_u64().unwrap()); + let (mut image, mut inst) = (NodeId(0), NodeId(0)); + s.edit("Set up", |d, _| { + for name in ["Sun", "Moon"] { + let art = Arc::new(Node::path(d.alloc_id(), triangle(), Appearance::default())); + d.symbols.push(Symbol { name: name.into(), art, dynamic: false }); + } + let layer = d.layers[0].id; + let im = vectorcraft_doc::ImageObject { + key: "none".into(), + width: 4, + height: 2, + xf: Affine::translate((100.0, 20.0)), + link: None, + placement: Default::default(), + pixels: None, + }; + let n = Node::new(d.alloc_id(), NodeKind::Image(Box::new(im))); + image = d.insert(Some(layer), usize::MAX, n).unwrap(); + let n = Node::new(d.alloc_id(), NodeKind::SymbolInstance { symbol: "Sun".into(), xf: Affine::translate((200.0, 20.0)) }); + inst = d.insert(Some(layer), usize::MAX, n).unwrap(); + Ok(()) + }) + .unwrap(); + let manifest = |id: &str, writes: &str| { + format!( + r#"{{"id":"{id}","name":"Revise","kind":"filter","api":3,"permissions":["doc.read","doc.write"],"inputs":["type","image","symbolInstance"]{writes}}}"# + ) + }; + let all = r#","writes":["type","image","symbolInstance"]"#; + let put = |s: &mut Session, src: &str| { + let data = vectorcraft_format::base64_encode(&wat::parse_str(src).unwrap()); + run(s, "plugin.install", json!({"dataBase64": data, "grant": ["doc.read", "doc.write"], "replace": true})) + }; + let p = |id: &str| json!({"id": id, "ids": [r.0, t.0, image.0, inst.0]}); + let style = match &node(&s, t).kind { + NodeKind::Text(x) => serde_json::to_value(&x.runs[0].style).unwrap(), + _ => panic!("type"), + }; + let edits = json!({"objects": [ + {"id": r.0}, + {"id": t.0, "text": {"runs": [{"text": "Bye now", "style": style}]}}, + {"id": image.0, "transform": [2, 0, 0, 2, 50, 60], "opacity": 0.25}, + {"id": inst.0, "symbolId": "Moon"}, + ]}); + let writer = "test.engine.writes.revise"; + let listed = put(&mut s, &tpl::returning(&manifest(writer, all), &edits.to_string())); + assert_eq!((&listed["api"], &listed["writes"]), (&json!(3), &json!(["type", "image", "symbolInstance"]))); + let (before, undo) = (s.doc().unwrap().doc.clone(), s.doc().unwrap().history.undo.len()); + assert_eq!(run(&mut s, "plugin.run", p(writer))["ids"], json!([r.0, t.0, image.0, inst.0])); + assert_eq!(s.doc().unwrap().history.undo.len(), undo + 1, "one undo step"); + let check = |d: &vectorcraft_doc::Document| { + let NodeKind::Text(x) = &d.node(t).unwrap().kind else { panic!("type") }; + assert_eq!(x.plain_text(), "Bye now"); + let NodeKind::Image(im) = &d.node(image).unwrap().kind else { panic!("image") }; + assert_eq!((im.xf, d.node(image).unwrap().opacity), (Affine::new([2.0, 0.0, 0.0, 2.0, 50.0, 60.0]), 0.25)); + assert!( + matches!(&d.node(inst).unwrap().kind, NodeKind::SymbolInstance { symbol, xf } if symbol == "Moon" && *xf == Affine::translate((200.0, 20.0))) + ); + }; + let after = s.doc().unwrap().doc.clone(); + check(&after); + assert!(matches!(&after.node(t).unwrap().kind, NodeKind::Text(x) if x.cached_bounds.is_some()), "the type is laid out again"); + assert_eq!(s.doc().unwrap().selection.objects, [r, t, image, inst]); + run(&mut s, "edit.undo", json!({})); + assert_eq!(s.doc().unwrap().doc.layers, before.layers); + run(&mut s, "edit.redo", json!({})); + assert_eq!(s.doc().unwrap().doc.layers, after.layers); + check(&vectorcraft_format::load(&vectorcraft_format::save(&after, false)).unwrap()); + // An echo changes nothing and records no undo step. + let echo = "test.engine.writes.echo"; + put(&mut s, &tpl::module(&manifest(echo, all), tpl::ECHO, "", 1)); + let (doc, undo) = (s.doc().unwrap().doc.clone(), s.doc().unwrap().history.undo.len()); + run(&mut s, "plugin.run", p(echo)); + assert_eq!((&s.doc().unwrap().doc, s.doc().unwrap().history.undo.len()), (&doc, undo), "an echo records no undo step"); + // Refused writes leave the document and the history as they were, also when a valid change + // comes before the refused one. + let bad = "test.engine.writes.bad"; + let retyped = json!({"id": t.0, "text": {"runs": [{"text": "Hello again", "style": style}]}}); + for (writes, output, says) in [ + ( + all, + json!({"objects": [{"id": r.0}, retyped, {"id": image.0}, {"id": inst.0, "symbolId": "Nowhere"}]}), + format!("objects[3] (id {}).symbolId: 'Nowhere' is not a symbol in this document", inst.0), + ), + ( + all, + json!({"objects": [{"id": r.0}, {"id": t.0}, {"id": image.0, "opacity": 1.5}, {"id": inst.0}]}), + format!("objects[2] (id {}).opacity: must be a number from 0 to 1", image.0), + ), + ("", edits.clone(), format!("objects[1] (id {}): read-only field 'text.kind' changed", t.0)), + ] { + put(&mut s, &tpl::returning(&manifest(bad, writes), &output.to_string())); + let (doc, undo) = (s.doc().unwrap().doc.clone(), s.doc().unwrap().history.undo.len()); + let e = s.execute("plugin.run", &p(bad)).unwrap_err().to_string(); + assert!(e.contains(&says), "{says}: {e}"); + assert_eq!((&s.doc().unwrap().doc, s.doc().unwrap().history.undo.len()), (&doc, undo), "{output}"); + } +} + /// The manifest of a filter at `api` 3 with id `id` that asks for the document information /// `context` (a JSON list), with `doc.read` and `doc.write`, and `rest` (keys after a comma, or /// nothing). @@ -4880,6 +4992,73 @@ fn the_document_context_is_capped_and_its_rows_cost_instructions() { refused(&mut s); } +/// A filter that writes type, run while typing is in progress: the plug-in is given the typed +/// text, so an echo keeps it, with Real-time Drawing on and off. An output that is refused leaves +/// the document and the history as they were; with Real-time Drawing on the typing stays in +/// progress, and off it is kept as its own step before the plug-in is given its input. +#[test] +fn a_filter_that_writes_type_is_given_the_typing_in_progress() { + use vectorcraft_doc::NodeKind; + use vectorcraft_tools::{PointerEvent, PointerKind}; + let manifest = |id: &str| { + format!( + r#"{{"id":"{id}","name":"Retype","kind":"filter","api":3,"permissions":["doc.read","doc.write"],"inputs":["type"],"writes":["type"]}}"# + ) + }; + let put = |s: &mut Session, src: &str| { + let data = vectorcraft_format::base64_encode(&wat::parse_str(src).unwrap()); + run(s, "plugin.install", json!({"dataBase64": data, "grant": ["doc.read", "doc.write"], "replace": true})) + }; + let plain = |s: &Session, t: NodeId| match &node(s, t).kind { + NodeKind::Text(x) => x.plain_text(), + _ => panic!("type"), + }; + let labels = |s: &Session| s.doc().unwrap().history.undo.iter().map(|e| e.label.clone()).collect::>(); + let typing = |real_time: bool| { + let mut s = session(); + s.prefs.real_time_drawing = real_time; + let v = ViewInfo::default(); + let t = NodeId(run(&mut s, "text.create", json!({"x": 100, "y": 100, "text": "A", "size": 20}))["id"].as_u64().unwrap()); + s.select_tool("type", v).unwrap(); + let b = s.doc().unwrap().doc.bounds_of(&[t], false).unwrap(); + for k in [PointerKind::Down, PointerKind::Up] { + s.pointer(&PointerEvent::new(k, b.x1 - 1.0, b.center().y), v).unwrap(); + } + s.tool_text("B", v).unwrap(); + assert_eq!(plain(&s, t), if real_time { "AB" } else { "A" }, "real time {real_time}"); + (s, t) + }; + let bang = "test.engine.writes.typing.bang"; + let bad = "test.engine.writes.typing.bad"; + for real_time in [false, true] { + // The plug-in adds "!" to the text it is given: "AB" or, given only "A", "A". + let (mut s, t) = typing(real_time); + let style = match &node(&s, t).kind { + NodeKind::Text(x) => serde_json::to_value(&x.runs[0].style).unwrap(), + _ => panic!("type"), + }; + let retyped = |text: &str| json!({"objects": [{"id": t.0, "text": {"runs": [{"text": text, "style": style}]}}]}).to_string(); + put(&mut s, &tpl::when_given_else(&manifest(bang), tpl::Given::Input, r#""AB""#, &retyped("AB!"), &retyped("A!"))); + run(&mut s, "plugin.run", json!({"id": bang, "ids": [t.0]})); + assert_eq!(plain(&s, t), "AB!", "real time {real_time}: the plug-in is given the typed text"); + let steps = labels(&s); + assert_eq!(steps[steps.len() - 2..], ["Typing", "Retype"], "real time {real_time}"); + + let (mut s, t) = typing(real_time); + put(&mut s, &tpl::returning(&manifest(bad), &json!({"objects": [{"id": t.0, "transform": [0, 0, 0, 0, 0, 0]}]}).to_string())); + let undo = labels(&s); + let e = s.execute("plugin.run", &json!({"id": bad, "ids": [t.0]})).unwrap_err().to_string(); + assert!(e.contains("transform: flattens the object to a line or a point"), "{e}"); + assert_eq!(plain(&s, t), "AB", "real time {real_time}"); + if real_time { + assert_eq!(labels(&s), undo, "the refused output leaves the history as it was"); + assert!(s.in_interaction(), "and the typing in progress"); + } else { + assert_eq!(labels(&s)[undo.len()..], ["Typing"], "only the typing is kept"); + } + } +} + /// A run past its memory budget fails before the plug-in starts, with the document and undo /// history as they were: a read-only object whose other fields don't fit, a path and a compound /// path that don't fit, and parameters past the input's half of the cap, with objects selected or @@ -6397,12 +6576,14 @@ fn deferred_move(s: &mut Session) -> NodeId { r } -/// The rectangle a run that hands back what it is given left during [`deferred_move`]: moved, with -/// the interaction ended and the move the last undo step, since the run changed nothing. +/// The rectangle an echoing run during [`deferred_move`] left: moved, with the interaction ended and +/// the move the last undo step, since the run handed the rectangle back as it was and so records +/// none. fn assert_moved_once(s: &Session, r: NodeId) { assert!(!s.in_interaction()); assert_eq!(node(s, r).geometric_bounds().unwrap().x0, 17.0, "the filter was given the moved rectangle"); - assert_eq!(s.doc().unwrap().history.undo.last().map(|e| e.label.as_str()), Some("Move")); + let labels: Vec<&str> = s.doc().unwrap().history.undo.iter().rev().take(2).map(|e| e.label.as_str()).collect(); + assert_eq!(labels, ["Move", "Rectangle"]); } /// With Real-time Drawing off, `plugin.run` of a filter that calls commands during a drag applies diff --git a/crates/plugins/src/manifest.rs b/crates/plugins/src/manifest.rs index ddbcb86582..e4274fc716 100644 --- a/crates/plugins/src/manifest.rs +++ b/crates/plugins/src/manifest.rs @@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize}; use serde_json::{Map, Value, json}; use crate::dialog::ParamUi; -use crate::permissions::{self, API_LEVEL, CONTEXT_API, INPUTS_API, PROGRESS_API, Permission}; +use crate::permissions::{self, API_LEVEL, CONTEXT_API, INPUTS_API, PROGRESS_API, Permission, WRITES_API}; use crate::{Error, Result}; /// Longest manifest the host reads. @@ -456,6 +456,11 @@ pub struct Manifest { /// lists them. Left out or empty, it is given paths and compound paths alone. #[serde(default, skip_serializing_if = "Vec::is_empty", deserialize_with = "input_names")] pub inputs: Vec, + /// The kinds among `inputs` the filter may change, by [`InputKind::name`]: only a filter at + /// `api` 3 or later whose `permissions` list `doc.read` and `doc.write` lists them. Left out or + /// empty, every kind it reads stays read-only. + #[serde(default, skip_serializing_if = "Vec::is_empty", deserialize_with = "write_names")] + pub writes: Vec, /// The parts of the document a run is given in `_context.document`, by /// [`ContextSection::name`]: only a filter, or a live effect with `commands` (for its command /// runs), at `api` 3 or later whose `permissions` list `doc.read` lists them. Left out or empty, @@ -519,6 +524,7 @@ impl Manifest { api: 1, permissions: None, inputs: Vec::new(), + writes: Vec::new(), context: Vec::new(), params: Vec::new(), extensions: Vec::new(), @@ -591,6 +597,7 @@ impl Manifest { return Err(Error::Manifest(format!("permission `{permission}` needs plug-in API level {PROGRESS_API}: give `api` {PROGRESS_API}"))); } self.validate_inputs()?; + self.validate_writes()?; self.validate_context()?; if self.paint_output && (self.kind != Kind::Effect || self.api < 2) { return Err(Error::Manifest("`paintOutput` is only for a live effect (`kind` \"effect\") at `api` 2".into())); @@ -691,6 +698,37 @@ impl Manifest { Ok(()) } + /// `writes` names each [`InputKind`] at most once, each one `inputs` lists, and only a filter at + /// `api` 3 or later lists any, with a `permissions` list that holds `doc.read` and `doc.write`. + fn validate_writes(&self) -> Result<()> { + if self.writes.is_empty() { + return Ok(()); + } + if self.kind != Kind::Filter { + return Err(Error::Manifest("only a filter declares `writes`".into())); + } + for (i, name) in self.writes.iter().enumerate() { + let shown = permissions::display_text(name, permissions::MAX_SHOWN_FIELD); + if InputKind::parse(name).is_none() { + return Err(Error::Manifest(format!("`writes` names an unknown object kind `{shown}`: use type, image or symbolInstance"))); + } + if self.writes.get(..i).is_some_and(|before| before.contains(name)) { + return Err(Error::Manifest(format!("`writes` lists `{shown}` twice"))); + } + if !self.inputs.contains(name) { + return Err(Error::Manifest(format!("`writes` lists `{shown}`, which `inputs` doesn't list"))); + } + } + if self.api < WRITES_API { + return Err(Error::Manifest(format!("`writes` needs `api` {WRITES_API} or later"))); + } + let listed = |p: Permission| self.permissions.as_ref().is_some_and(|names| names.iter().any(|n| n == p.name())); + if !listed(Permission::DocWrite) { + return Err(Error::Manifest("`writes` needs the permission `doc.write`".into())); + } + Ok(()) + } + /// `context` names each [`ContextSection`] at most once, and only a filter, or a live effect /// with commands, at `api` 3 or later lists any, with a `permissions` list that holds /// `doc.read`: installing it then asks the user to grant it ([`Manifest::asks_permissions`]). @@ -764,6 +802,11 @@ impl Manifest { self.inputs.iter().filter_map(|n| InputKind::parse(n)).collect() } + /// The kinds among those it reads that it may change (`writes`). + pub fn write_kinds(&self) -> Vec { + self.writes.iter().filter_map(|n| InputKind::parse(n)).collect() + } + /// An exporter or an importer lists 1 to [`MAX_EXTENSIONS`] distinct extensions of 1 to 16 /// lower-case letters and digits; other kinds list none. fn validate_extensions(&self) -> Result<()> { @@ -933,6 +976,16 @@ fn input_names<'de, D: serde::Deserializer<'de>>(d: D) -> std::result::Result>(d: D) -> std::result::Result, D::Error> { + let wrong = || serde::de::Error::custom("`writes` must be a list of object kinds: type, image or symbolInstance"); + match Value::deserialize(d)? { + Value::Null => Ok(Vec::new()), + Value::Array(names) => names.into_iter().map(|n| if let Value::String(s) = n { Ok(s) } else { Err(wrong()) }).collect(), + _ => Err(wrong()), + } +} + /// Reads `context`: a list of names (`null`: none). Anything else is the error /// [`Manifest::validate_context`] gives a wrong entry. fn context_names<'de, D: serde::Deserializer<'de>>(d: D) -> std::result::Result, D::Error> { @@ -1419,6 +1472,64 @@ mod tests { assert!(Manifest::parse(long.as_bytes()).unwrap_err().to_string().contains("twice")); } + /// A filter at `api` 3 may change the kinds it reads that it lists in `writes`, each once, with + /// `doc.read` and `doc.write`. Left out or empty, everything it reads stays read-only and the key + /// isn't written back. Anything else is refused naming `writes`. + #[test] + fn a_filter_at_api_3_lists_the_kinds_it_writes() { + let m = Manifest::parse( + br#"{"id":"org.example.revise","name":"Revise","kind":"filter","api":3,"permissions":["doc.read","doc.write"],"inputs":["type","image","symbolInstance"],"writes":["type","image","symbolInstance"]}"#, + ) + .unwrap(); + assert_eq!(m.write_kinds(), InputKind::ALL); + assert_eq!(serde_json::to_value(&m).unwrap()["writes"], json!(["type", "image", "symbolInstance"])); + let some = Manifest::parse( + br#"{"id":"a","name":"x","kind":"filter","api":3,"permissions":["doc.read","doc.write"],"inputs":["image","type"],"writes":["image"]}"#, + ) + .unwrap(); + assert_eq!((some.input_kinds(), some.write_kinds()), (vec![InputKind::Image, InputKind::Type], vec![InputKind::Image])); + for none in [ + r#"{"id":"a","name":"x","kind":"filter","api":2,"permissions":["doc.read"],"inputs":["type"]}"#, + r#"{"id":"a","name":"x","kind":"filter","api":3,"permissions":["doc.read"],"inputs":["type"],"writes":[]}"#, + r#"{"id":"a","name":"x","kind":"filter","writes":null}"#, + ] { + let m = Manifest::parse(none.as_bytes()).unwrap(); + assert!(m.write_kinds().is_empty(), "{none}"); + assert!(serde_json::to_value(&m).unwrap().get("writes").is_none(), "{none}"); + } + let rw = r#""permissions":["doc.read","doc.write"]"#; + for (bad, says) in [ + ( + format!(r#"{{"id":"a","name":"x","kind":"filter","api":3,{rw},"inputs":["type"],"writes":["text"]}}"#), + "`writes` names an unknown object kind `text`", + ), + ( + format!(r#"{{"id":"a","name":"x","kind":"filter","api":3,{rw},"inputs":["type"],"writes":["type","type"]}}"#), + "`writes` lists `type` twice", + ), + ( + format!(r#"{{"id":"a","name":"x","kind":"filter","api":3,{rw},"inputs":["type"],"writes":["image"]}}"#), + "`writes` lists `image`, which `inputs` doesn't list", + ), + (format!(r#"{{"id":"a","name":"x","kind":"filter","api":3,{rw},"writes":["image"]}}"#), "which `inputs` doesn't list"), + (format!(r#"{{"id":"a","name":"x","kind":"filter","api":3,{rw},"inputs":["type"],"writes":"type"}}"#), "`writes` must be a list"), + (format!(r#"{{"id":"a","name":"x","kind":"filter","api":3,{rw},"inputs":["type"],"writes":[1]}}"#), "`writes` must be a list"), + (format!(r#"{{"id":"a","name":"x","kind":"filter","api":2,{rw},"inputs":["type"],"writes":["type"]}}"#), "`writes` needs `api` 3"), + ( + r#"{"id":"a","name":"x","kind":"filter","api":3,"permissions":["doc.read"],"inputs":["type"],"writes":["type"]}"#.into(), + "`writes` needs the permission `doc.write`", + ), + ( + r#"{"id":"a","name":"x","kind":"filter","api":3,"permissions":["doc.write"],"inputs":["type"],"writes":["type"]}"#.into(), + "`inputs` needs the permission `doc.read`", + ), + (r#"{"id":"a","name":"x","kind":"effect","api":3,"writes":["type"]}"#.into(), "only a filter declares `writes`"), + ] { + let e = Manifest::parse(bad.as_bytes()).unwrap_err().to_string(); + assert!(e.contains(says), "{bad}: {e}"); + } + } + /// A filter, or a live effect with commands, at `api` 3 may ask for parts of the document /// (`context`), each once, with a `permissions` list holding `doc.read`, so installing it asks /// for approval. Left out or empty, it asks for none and isn't written back. Anything else is diff --git a/crates/plugins/src/objects.rs b/crates/plugins/src/objects.rs index 4057af3eda..4b0a528703 100644 --- a/crates/plugins/src/objects.rs +++ b/crates/plugins/src/objects.rs @@ -82,6 +82,10 @@ pub struct OutObject { /// A read-only input object (type, an image or a symbol instance) returned as it was given: /// it stays as it is, and new objects listed after it go above it. pub kept: bool, + /// A type object, an image or a symbol instance of a kind the filter may change (`writes`) + /// returned with changes: the fields it changes, by their names in the input, checked when + /// they are applied ([`apply_output`]). + pub edit: Option>, } /// One stroke of an [`OutObject`]. `None` fields keep the stroke's value (a new stroke's @@ -295,7 +299,7 @@ fn affine_json(xf: Affine) -> Value { /// paragraphs: [style]}` with the native character and paragraph attributes, one paragraph style /// for each paragraph, and `truncated`: true, with no runs or paragraphs, past [`MAX_INPUT_TEXT`] /// or [`MAX_INPUT_RUNS`]; -/// - an image (`"image"`): `pixelSize: [w, h]`, `colorMode: "rgb"|"cmyk"|"gray"|"unknown"`, +/// - an image (`"image"`): `opacity` (0 to 1), `pixelSize: [w, h]`, `colorMode: "rgb"|"cmyk"|"gray"|"unknown"`, /// `linked`, `pixelsOmitted`, and for an embedded image of at most [`MAX_INPUT_PIXELS`] /// `pixelsBase64`: straight RGBA, 8 bits a channel, row by row from the top (a CMYK image's inks /// through the working CMYK profile, as sRGB). A linked image's file and path are never read or @@ -332,6 +336,7 @@ fn encode_read_only_within(doc: &Document, n: &Node, symbols: &SymbolBoxes, left if let Some(q) = n.image_quad() { o["corners"] = json!(q.map(|p| [p.x, p.y])); } + o["opacity"] = json!(n.opacity); o["pixelSize"] = json!([im.width, im.height]); o["colorMode"] = json!(doc.image_blob(im).map_or("unknown", color_mode)); o["linked"] = json!(im.link.is_some()); @@ -672,6 +677,15 @@ fn decode_paint(v: &Value, at: &str) -> Result { Ok(p) } +/// An object's name from plug-in output (`null`: no name), without control characters and at most +/// 256 of them. +fn decode_name(n: &Value, at: &str) -> Result { + Ok(match n { + Value::Null => String::new(), + n => n.as_str().ok_or_else(|| out_err(at, "`name` must be a string"))?.chars().filter(|c| !c.is_control()).take(256).collect(), + }) +} + fn opt<'a>(o: &'a serde_json::Map, key: &str) -> Option<&'a Value> { o.get(key).filter(|v| !v.is_null()) } @@ -693,11 +707,7 @@ fn decode_object(v: &Value, at: &str, anchors: &mut usize) -> Result }); } if let Some(n) = o.get("name") { - let name = match n { - Value::Null => String::new(), - n => n.as_str().ok_or_else(|| out_err(at, "`name` must be a string"))?.chars().filter(|c| !c.is_control()).take(256).collect(), - }; - out.name = Some(name); + out.name = Some(decode_name(n, at)?); } if let Some(p) = opt(o, "path") { out.path = Some(decode_path(p, &format!("{at}.path"), anchors)?); @@ -813,8 +823,18 @@ pub fn decode_output(bytes: &[u8]) -> Result { /// differs, before anything changes. Each object is parsed from `input` only to compare it, one at /// a time, and an object that can't be read from there is an error. pub fn decode_output_with(bytes: &[u8], input: &[u8], read_only: &ReadOnlySpans) -> Result { + decode_output_writing(bytes, input, read_only, &[]) +} + +/// [`decode_output_with`] for a filter that may change the objects of kinds `writes` among them +/// (its manifest's `writes`): such an object is still listed exactly once, and an entry for it may +/// leave fields out, which keep their values, and give its name, its transform, and type's +/// `text.runs` and `text.paragraphs`, an image's `opacity` or an instance's `symbolId` changed. +/// Such an entry is [`OutObject::edit`] with the fields it changes; one that changes nothing is +/// [`OutObject::kept`]. Any other field must be as given, and the error names the first that isn't. +pub fn decode_output_writing(bytes: &[u8], input: &[u8], read_only: &ReadOnlySpans, writes: &[InputKind]) -> Result { let mut v: Value = serde_json::from_slice(bytes).map_err(|e| Error::Output(format!("not JSON: {e}")))?; - let objects = decode_objects(&v, input, read_only)?; + let objects = decode_objects(&v, input, read_only, writes)?; let document_data = match v.get_mut("documentData").map(Value::take) { None => None, Some(Value::Null) => Some(None), @@ -896,12 +916,12 @@ fn draws_nothing(c: char) -> bool { /// declined (the message reaches the user). A live effect's other keys don't matter. pub fn decode(bytes: &[u8]) -> Result> { let v: Value = serde_json::from_slice(bytes).map_err(|e| Error::Output(format!("not JSON: {e}")))?; - decode_objects(&v, &[], &HashMap::new()) + decode_objects(&v, &[], &HashMap::new(), &[]) } /// The objects of output `v`, or its decline; entries for `read_only` objects as -/// [`decode_output_with`] reads them. -fn decode_objects(v: &Value, input: &[u8], read_only: &ReadOnlySpans) -> Result> { +/// [`decode_output_writing`] reads them, those of kinds `writes` changeable. +fn decode_objects(v: &Value, input: &[u8], read_only: &ReadOnlySpans, writes: &[InputKind]) -> Result> { if let Some(e) = declined(v) { return Err(e); } @@ -910,6 +930,8 @@ fn decode_objects(v: &Value, input: &[u8], read_only: &ReadOnlySpans) -> Result< return Err(Error::Output(format!("{} objects (limit {MAX_OBJECTS})", objects.len()))); } let mut anchors = 0; + // Bytes of type text the output writes, over all its objects. + let mut text = 0; let mut returned: HashSet = HashSet::new(); let out = objects .iter() @@ -920,12 +942,19 @@ fn decode_objects(v: &Value, input: &[u8], read_only: &ReadOnlySpans) -> Result< if !returned.insert(id) { return Err(out_err(&at, "is listed twice")); } + let kept = OutObject { id: Some(id), kept: true, ..OutObject::default() }; // `{"id": …}` alone keeps the object, so there is nothing to compare it with. - if o.as_object().is_none_or(|m| m.len() != 1) { - let given = serde_json::from_slice(input.get(span.clone()).unwrap_or_default()).map_err(|e| Error::Io(e.to_string()))?; + let Some(entry) = o.as_object().filter(|m| m.len() != 1) else { return Ok(kept) }; + let given: Value = serde_json::from_slice(input.get(span.clone()).unwrap_or_default()).map_err(|e| Error::Io(e.to_string()))?; + let kind = given.get("type").and_then(Value::as_str).and_then(InputKind::parse).filter(|k| writes.contains(k)); + let Some(kind) = kind else { check_unchanged(o, &given, &at)?; - } - Ok(OutObject { id: Some(id), kept: true, ..OutObject::default() }) + return Ok(kept); + }; + Ok(match writes::changes(entry, &given, kind, &at, &mut text)? { + Some(edit) => OutObject { id: Some(id), edit: Some(edit), ..OutObject::default() }, + None => kept, + }) } None => decode_object(o, &format!("objects[{i}]"), &mut anchors), }) @@ -951,28 +980,40 @@ fn output_id(o: &Value) -> Option { /// numbers compared by value. Otherwise the error names the first field that differs /// (`text.runs[0].text`): a field the entry gives before one it leaves out, shown as /// [`crate::permissions::display_text`] shows a manifest string, since the entry's keys are the -/// plug-in's. +/// plug-in's. An image's `opacity`, which filters are given from plug-in API level 3, may be left +/// out, so an entry that a filter built for level 2 writes as it was given there still matches. fn check_unchanged(o: &Value, given: &Value, at: &str) -> Result<()> { let changed = match (o, given) { (Value::Object(x), Value::Object(y)) => { let mut keys: Vec<&String> = x.keys().collect(); keys.sort(); - keys.into_iter().find_map(|k| match y.get(k) { - Some(q) => first_difference(&x[k], q, k), - None => Some(k.clone()), - }) + keys.into_iter() + .find_map(|k| match y.get(k) { + Some(q) => first_difference(&x[k], q, k), + None => Some(k.clone()), + }) + .or_else(|| { + let image = y.get("type").and_then(Value::as_str) == Some(InputKind::Image.name()); + let mut missing: Vec<&String> = y.keys().filter(|k| !x.contains_key(*k) && !(image && *k == "opacity")).collect(); + missing.sort(); + missing.first().map(|k| (*k).clone()) + }) } - _ => None, + _ => first_difference(o, given, ""), }; - match changed.or_else(|| first_difference(o, given, "")) { + match changed { None => Ok(()), - Some(field) => { - let field = crate::permissions::display_text(&field, crate::permissions::MAX_SHOWN_FIELD); - Err(out_err(at, format!("read-only field '{field}' changed"))) - } + Some(field) => Err(read_only_changed(at, &field)), } } +/// The error for an entry at `at` that changes read-only `field`, which is shown as +/// [`crate::permissions::display_text`] shows a manifest string. +fn read_only_changed(at: &str, field: &str) -> Error { + let field = crate::permissions::display_text(field, crate::permissions::MAX_SHOWN_FIELD); + out_err(at, format!("read-only field '{field}' changed")) +} + /// The path of the first place `a` and `b` differ (`""`: they differ as a whole), `None` when they /// are the same JSON with numbers compared by value. fn first_difference(a: &Value, b: &Value, at: &str) -> Option { @@ -1328,7 +1369,9 @@ impl Plan { /// input object, just below the first one listed after them (at the first input object's place /// when the output keeps none; on top of `parent` when there were no inputs). Input objects missing /// from the output are deleted. An object's effect records replace its own once `admit` lets them -/// in. Returns the resulting objects in output order (to select). +/// in. Type, images and symbol instances stay as they are, or take the changes of their +/// [`OutObject::edit`] once each value is checked. Returns the resulting objects in output order +/// (to select). pub fn apply_output(doc: &mut Document, inputs: &[NodeId], out: Vec, parent: Option, admit: AdmitEffects) -> Result> { let wanted: HashSet = inputs.iter().copied().collect(); let mut originals: HashMap = HashMap::new(); @@ -1353,12 +1396,15 @@ pub fn apply_output(doc: &mut Document, inputs: &[NodeId], out: Vec, out_err(&at, format!("{} is not the id of an input object", id.0)) } })?; - // Type, images and symbol instances are only read: writing one would make it a path. - if input_kind(&n).is_some() && !o.kept { - return Err(out_err(&at, format!("{} is read-only", id.0))); - } + // Type, images and symbol instances change only through the fields a filter that + // may write them returns: writing one as a path would make it a path. let kept = o.kept; - if !kept { + if input_kind(&n).is_some() && !kept { + let Some(edit) = &o.edit else { return Err(out_err(&at, format!("{} is read-only", id.0))) }; + writes::apply(doc, &mut n, edit, &format!("{at} (id {})", id.0))?; + } else if o.edit.is_some() { + return Err(out_err(&at, format!("{} is not type, an image or a symbol instance", id.0))); + } else if !kept { write(doc, &mut n, o, &at, admit)?; } if !run.is_empty() { @@ -1415,5 +1461,7 @@ pub fn output_geometry(objects: Vec) -> PathData { PathData::new(objects.into_iter().filter_map(|o| o.path).flat_map(|p| p.subpaths).collect()) } +mod writes; + #[cfg(test)] mod tests; diff --git a/crates/plugins/src/objects/tests.rs b/crates/plugins/src/objects/tests.rs index 39d2d78776..5bfa28215d 100644 --- a/crates/plugins/src/objects/tests.rs +++ b/crates/plugins/src/objects/tests.rs @@ -1066,7 +1066,8 @@ fn a_changed_field_is_named_escaped_and_short() { } /// A filter given read-only objects returns each one as `{"id": …}` or exactly as given (numbers by -/// value), and they stay as they are, new objects listed after one going just above it. Any change, +/// value; an image may leave out its `opacity`), and they stay as they are, new objects listed +/// after one going just above it. Any change, /// an object left out or listed twice, and a new object of such a kind are refused before anything /// changes. #[test] @@ -1087,6 +1088,14 @@ fn read_only_kind_field_and_omission_refuse() { let mut echo = input.clone(); echo["objects"][3]["transform"] = json!([1, 0, 0, 1, 5, 50]); assert!(decode_output_with(echo.to_string().as_bytes(), &bytes, &read_only).is_ok()); + // An image without `opacity`, as plug-in API level 2 gave it, is the image as given. + let mut echo = input.clone(); + for i in [4, 5] { + assert_eq!(echo["objects"][i]["type"], json!("image")); + echo["objects"][i].as_object_mut().unwrap().remove("opacity"); + } + let out = decode_output_with(echo.to_string().as_bytes(), &bytes, &read_only).unwrap(); + assert_eq!(out.objects.iter().filter(|o| o.kept).count(), 5); // So is an id written as a float; a fractional one names no object. let id = input["objects"][3]["id"].as_u64().unwrap(); let mut echo = input.clone(); @@ -1151,6 +1160,486 @@ fn read_only_kind_field_and_omission_refuse() { assert_eq!(d, before); } +/// [`mixed`] with a second symbol, "Moon", and its targets and input for a filter that reads and may +/// change every kind. +fn writable() -> (Document, Vec, Vec, ReadOnlySpans, [NodeId; 5]) { + let (mut d, _, layer, extra) = mixed(); + let art = Arc::new(Node::path(d.alloc_id(), square(5.0), Appearance::default())); + d.symbols.push(vectorcraft_doc::Symbol { name: "Moon".into(), art, dynamic: false }); + let targets = filter_targets_with(&d, &[layer], &InputKind::ALL); + let (bytes, read_only) = encode_input_with(&d, &targets, &InputKind::ALL, usize::MAX).unwrap(); + (d, targets, bytes, read_only, extra) +} + +/// Decodes `out` for [`writable`]'s input with `writes` and applies it to `d`. +fn write_out( + d: &mut Document, + targets: &[NodeId], + bytes: &[u8], + read_only: &ReadOnlySpans, + writes: &[InputKind], + out: &Value, +) -> Result> { + let out = decode_output_writing(out.to_string().as_bytes(), bytes, read_only, writes)?; + apply_output(d, targets, out.objects, None, &keep) +} + +/// A filter that may write type, images and symbol instances changes type's runs and character +/// attributes, an image's transform and opacity, and the symbol and transform of an instance, +/// with entries that give only the fields they change. What it writes reads back the same. An +/// exact echo, `{"id": …}` alone and fields given as they were (numbers by value) change nothing. +#[test] +fn writable_kinds_take_type_runs_image_placement_and_instance_symbols() { + use vectorcraft_doc::{CharStyle, ParaStyle}; + let (mut d, targets, bytes, read_only, [text, embedded, linked, star, ghost]) = writable(); + let before = d.clone(); + let all = &InputKind::ALL; + let echo = decode_output_writing(&bytes, &bytes, &read_only, all).unwrap(); + assert!(echo.objects.iter().all(|o| o.edit.is_none())); + apply_output(&mut d, &targets, echo.objects, None, &keep).unwrap(); + assert_eq!(d, before, "an exact echo changes nothing"); + let ro = |id: NodeId| json!({"id": id.0}); + let paths: Vec = targets.iter().filter(|id| !read_only.contains_key(id)).map(|id| ro(*id)).collect(); + let with = |entries: Vec| { + let objects = [paths.clone(), entries].concat(); + json!({ "objects": objects }) + }; + let same = with(vec![ + json!({"id": text.0, "transform": [1, 0, 0, 1, 5, 50], "name": "T"}), + json!({"id": embedded.0, "opacity": 1}), + ro(linked), + json!({"id": star.0, "symbolId": "Star"}), + ro(ghost), + ]); + let out = decode_output_writing(same.to_string().as_bytes(), &bytes, &read_only, all).unwrap(); + assert!(out.objects.iter().all(|o| o.edit.is_none())); + assert_eq!(out.objects.iter().filter(|o| o.kept).count(), 5, "fields given as they were change nothing"); + // The changes, each entry giving only what it changes. + let big = CharStyle { size: 24.0, ..CharStyle::default() }; + let runs = json!([{"text": "Bye\n", "style": CharStyle::default()}, {"text": "now", "style": big}]); + let out = with(vec![ + json!({"id": text.0, "name": "Renamed", "text": {"runs": runs}}), + json!({"id": embedded.0, "transform": [1, 0, 0, 1, 10, 20], "opacity": 0.5}), + ro(linked), + json!({"id": star.0, "symbolId": "Moon", "transform": [1, 0, 0, 1, 50, 0]}), + ro(ghost), + ]); + let made = write_out(&mut d, &targets, &bytes, &read_only, all, &out).unwrap(); + assert_eq!(made.len(), targets.len()); + let node = |id: NodeId| d.node(id).unwrap().clone(); + let NodeKind::Text(t) = &node(text).kind else { panic!("type") }; + assert_eq!((t.plain_text().as_str(), t.runs[1].style.size), ("Bye\nnow", 24.0)); + assert_eq!(t.para_at(1).space_before, 6.0, "paragraphs keep their styles"); + assert_eq!(t.para_at(0), &ParaStyle::default()); + assert_eq!(node(text).name.as_deref(), Some("Renamed")); + let NodeKind::Image(im) = &node(embedded).kind else { panic!("image") }; + assert_eq!((im.xf, node(embedded).opacity), (Affine::new([1.0, 0.0, 0.0, 1.0, 10.0, 20.0]), 0.5)); + assert_eq!(node(star).kind, NodeKind::SymbolInstance { symbol: "Moon".into(), xf: Affine::translate((50.0, 0.0)) }); + for id in [linked, ghost] { + assert_eq!(d.node(id), before.node(id), "objects returned by id stay as they were"); + } + // Read again, the changed objects give what was written. + let read = |id: NodeId| encode_read_only(&d, d.node(id).unwrap()).unwrap(); + assert_eq!(read(text)["text"]["runs"], runs); + assert_eq!((&read(embedded)["transform"], &read(embedded)["opacity"]), (&json!([1.0, 0.0, 0.0, 1.0, 10.0, 20.0]), &json!(0.5))); + assert_eq!((&read(star)["symbolId"], &read(star)["transform"]), (&json!("Moon"), &json!([1.0, 0.0, 0.0, 1.0, 50.0, 0.0]))); + assert!(read(star).get("missing").is_none()); + // An instance of a symbol the document lacks can point to one it has. + let mut d = before.clone(); + let out = with(vec![ro(text), ro(embedded), ro(linked), ro(star), json!({"id": ghost.0, "symbolId": "Star"})]); + write_out(&mut d, &targets, &bytes, &read_only, all, &out).unwrap(); + assert!(matches!(&d.node(ghost).unwrap().kind, NodeKind::SymbolInstance { symbol, .. } if symbol == "Star")); +} + +/// An entry that changes a field its kind can't change, a kind the manifest doesn't list in +/// `writes`, or gives a value out of range is refused naming the object and the field, before +/// anything changes. +#[test] +fn bad_writes_are_refused_naming_the_object_and_the_field() { + use vectorcraft_doc::CharStyle; + let (d, targets, bytes, read_only, [text, embedded, linked, star, ghost]) = writable(); + let input: Value = serde_json::from_slice(&bytes).unwrap(); + let at = |id: NodeId| input["objects"].as_array().unwrap().iter().position(|o| o["id"] == json!(id.0)).unwrap(); + let style = serde_json::to_value(CharStyle::default()).unwrap(); + let styled = |f: &dyn Fn(&mut Value)| { + let mut s = style.clone(); + f(&mut s); + json!([{"text": "Hi\nthere", "style": s}]) + }; + let (t, e, l, s) = (text.0, embedded.0, linked.0, star.0); + let (ti, ei, si) = (at(text), at(embedded), at(star)); + let cases: Vec<(NodeId, Value, &[InputKind], String)> = vec![ + (text, json!({"text": {"kind": "area"}}), &InputKind::ALL, format!("objects[{ti}] (id {t}): read-only field 'text.kind' changed")), + (text, json!({"text": {"x": 1}}), &InputKind::ALL, format!("(id {t}): read-only field 'text.x' changed")), + (text, json!({"bounds": [0, 0, 1, 1]}), &InputKind::ALL, format!("(id {t}): read-only field 'bounds[0]' changed")), + (text, json!({"opacity": 0.5}), &InputKind::ALL, format!("(id {t}): read-only field 'opacity' changed")), + (text, json!({"text": {"runs": []}}), &InputKind::ALL, "text.runs: type needs at least one run".into()), + ( + text, + json!({"text": {"runs": styled(&|s| s["fontSzie"] = json!(9))}}), + &InputKind::ALL, + "text.runs[0].style: unknown key 'fontSzie'".into(), + ), + ( + text, + json!({"text": {"runs": styled(&|s| s["size"] = json!(5000))}}), + &InputKind::ALL, + "text.runs[0].style.size: `size` must be from 0.1 to 1296".into(), + ), + (text, json!({"text": {"runs": styled(&|s| s["size"] = json!("big"))}}), &InputKind::ALL, "text.runs[0].style:".into()), + ( + text, + json!({"text": {"runs": styled(&|s| s["font_family"] = json!(" "))}}), + &InputKind::ALL, + "font_family: must be 1-256 printable characters".into(), + ), + ( + text, + json!({"text": {"runs": styled(&|s| s["font_family"] = json!(format!(" {}", "a".repeat(256))))}}), + &InputKind::ALL, + "font_family: must be 1-256 printable characters".into(), + ), + ( + text, + json!({"text": {"runs": styled(&|s| s["fill"] = json!({"type": "solid", "color": s["fill"]["color"], "tintt": 0.5}))}}), + &InputKind::ALL, + "text.runs[0].style.fill: unknown key 'tintt'".into(), + ), + ( + text, + json!({"text": {"runs": styled(&|s| s["stroke"] = json!({"type": "none", "pattern": "Dots"}))}}), + &InputKind::ALL, + "text.runs[0].style.stroke: unknown key 'pattern'".into(), + ), + ( + text, + json!({"text": {"runs": [{"text": "A\nB\nC", "style": style}], "paragraphs": input["objects"][at(text)]["text"]["paragraphs"]}}), + &InputKind::ALL, + "text.paragraphs: expected 3 paragraph styles, one per paragraph".into(), + ), + (text, json!({"text": {"runs": [{"text": "Hi", "style": style, "color": 1}]}}), &InputKind::ALL, "text.runs[0]: unknown key 'color'".into()), + (text, json!({"text": 5}), &InputKind::ALL, format!("objects[{ti}] (id {t}): `text` must be an object")), + (text, json!({"text": {"runs": [{"text": 5, "style": style}]}}), &InputKind::ALL, "text.runs[0]: `text` must be a string".into()), + (text, json!({"text": {"runs": [{"text": "Hi", "style": 5}]}}), &InputKind::ALL, "text.runs[0]: `style` must be an object".into()), + (text, json!({"text": {"paragraphs": [5, {}]}}), &InputKind::ALL, "text: `paragraphs[0]` must be an object".into()), + (text, json!({"text": {"paragraphs": [{"spaceBefor": 1}, {}]}}), &InputKind::ALL, "text.paragraphs[0]: unknown key 'spaceBefor'".into()), + ( + text, + json!({"text": {"paragraphs": [{"hyphenation": {"wordLongerThen": 3}}, {}]}}), + &InputKind::ALL, + "text.paragraphs[0].hyphenation: unknown key 'wordLongerThen'".into(), + ), + ( + text, + json!({"text": {"paragraphs": [{"justification": {"wordSpacng": [80, 100, 133]}}, {}]}}), + &InputKind::ALL, + "text.paragraphs[0].justification: unknown key 'wordSpacng'".into(), + ), + ( + text, + json!({"text": {"paragraphs": [{}, {"tabs": [{"position": 36}, {"position": 72, "aling": "center"}]}]}}), + &InputKind::ALL, + "text.paragraphs[1].tabs[1]: unknown key 'aling'".into(), + ), + (text, json!({"text": {"paragraphs": [{"list": {"levl": 2}}, {}]}}), &InputKind::ALL, "text.paragraphs[0].list: unknown key 'levl'".into()), + ( + text, + json!({"text": {"runs": styled(&|s| s["stroke_dash"] = json!({"pattern": [2, 2], "ofset": 1}))}}), + &InputKind::ALL, + "text.runs[0].style.stroke_dash: unknown key 'ofset'".into(), + ), + ( + text, + json!({"text": {"runs": [{"text": "Hi\u{FFFC}", "style": style}]}}), + &InputKind::ALL, + "holds the character of an inline graphic".into(), + ), + (text, json!({"text": {"paragraphs": [{}]}}), &InputKind::ALL, "text.paragraphs: expected 2 paragraph styles, one per paragraph".into()), + (text, json!({"transform": [1, 0, 0, 0, 0, 0]}), &InputKind::ALL, format!("objects[{ti}] (id {t}).transform: flattens the object")), + (text, json!({"transform": [1, 0, 0, 1, 1e9, 0]}), &InputKind::ALL, "transform: a number is out of range".into()), + (text, json!({"transform": [1, 0, null, 0, 1, 10, 20]}), &InputKind::ALL, "transform: must be a list of 6 numbers".into()), + (text, json!({"transform": [1, 0, 0, 1, 10]}), &InputKind::ALL, "transform: must be a list of 6 numbers".into()), + (text, json!({"transform": [1, 0, 0, 1]}), &InputKind::ALL, "transform: must be a list of 6 numbers".into()), + (embedded, json!({"pixelSize": [3, 1]}), &InputKind::ALL, format!("(id {e}): read-only field 'pixelSize[0]' changed")), + (embedded, json!({"opacity": 2}), &InputKind::ALL, format!("objects[{ei}] (id {e}).opacity: must be a number from 0 to 1")), + (embedded, json!({"opacity": "half"}), &InputKind::ALL, "opacity: must be a number from 0 to 1".into()), + (linked, json!({"linked": false}), &InputKind::ALL, format!("(id {l}): read-only field 'linked' changed")), + (embedded, json!({"opacity": 0.5}), &[InputKind::Type, InputKind::SymbolInstance], format!("(id {e}): read-only field 'opacity' changed")), + ( + star, + json!({"symbolId": "Nowhere"}), + &InputKind::ALL, + format!("objects[{si}] (id {s}).symbolId: 'Nowhere' is not a symbol in this document"), + ), + (star, json!({"symbolId": 7}), &InputKind::ALL, "symbolId: must be the name of a symbol".into()), + (star, json!({"overrides": {"a": 1}}), &InputKind::ALL, format!("(id {s}): read-only field 'overrides.a' changed")), + (ghost, json!({"missing": false}), &InputKind::ALL, "read-only field 'missing' changed".into()), + (star, json!({"symbolId": "Moon"}), &[InputKind::Type], format!("(id {s}): read-only field 'symbolId' changed")), + ]; + for (id, entry, writes, says) in cases { + let mut out = input.clone(); + let mut e = entry.clone(); + e["id"] = json!(id.0); + out["objects"][at(id)] = e; + let mut doc = d.clone(); + let err = write_out(&mut doc, &targets, &bytes, &read_only, writes, &out).unwrap_err().to_string(); + assert!(err.contains(&says), "{entry}: {says}: {err}"); + assert_eq!(doc, d, "{entry}: nothing changed"); + } + // Leaving a writable object out is still refused: it isn't deleted. + let mut out = input.clone(); + out["objects"].as_array_mut().unwrap().remove(at(star)); + let e = write_out(&mut d.clone(), &targets, &bytes, &read_only, &InputKind::ALL, &out).unwrap_err().to_string(); + assert!(e.contains(&format!("objects (id {s}): a read-only object was left out")), "{e}"); +} + +/// The text a filter writes to one type object is held to [`MAX_INPUT_TEXT`] bytes and +/// [`MAX_INPUT_RUNS`] runs and paragraphs, as the text it is given; type given as `truncated` +/// keeps its text, though it can still move. +#[test] +fn written_text_is_held_to_the_input_limits_and_truncated_type_keeps_its_text() { + use vectorcraft_doc::{CharStyle, TextObject}; + let (mut d, _, layer, [text, ..]) = mixed(); + let long = Node::new( + d.alloc_id(), + NodeKind::Text(Box::new(TextObject::point(Point::new(0.0, 0.0), &"x".repeat(MAX_INPUT_TEXT + 1), CharStyle::default()))), + ); + let long = d.insert(Some(layer), usize::MAX, long).unwrap(); + let targets = filter_targets_with(&d, &[layer], &[InputKind::Type]); + let (bytes, read_only) = encode_input_with(&d, &targets, &[InputKind::Type], usize::MAX).unwrap(); + let input: Value = serde_json::from_slice(&bytes).unwrap(); + let at = |id: NodeId| input["objects"].as_array().unwrap().iter().position(|o| o["id"] == json!(id.0)).unwrap(); + assert_eq!(input["objects"][at(long)]["truncated"], json!(true)); + let style = serde_json::to_value(CharStyle::default()).unwrap(); + let run = |s: String| json!({"text": s, "style": style}); + let writes = &[InputKind::Type]; + for (id, text_v, says) in [ + (text, json!({"runs": [run("x".repeat(MAX_INPUT_TEXT + 1))]}), format!("bytes of text (limit {MAX_INPUT_TEXT})")), + (text, json!({"runs": vec![run("x".into()); MAX_INPUT_RUNS + 1]}), format!("must be a list of at most {MAX_INPUT_RUNS} entries")), + (text, json!({"runs": [run("\n".repeat(MAX_INPUT_RUNS))]}), format!("{} paragraphs (limit {MAX_INPUT_RUNS})", MAX_INPUT_RUNS + 1)), + (text, json!({"paragraphs": vec![json!({}); MAX_INPUT_RUNS + 1]}), format!("must be a list of at most {MAX_INPUT_RUNS} entries")), + (long, json!({"runs": [run("short".into())]}), "the text of type given as `truncated` can't be changed".to_string()), + ] { + let mut out = input.clone(); + out["objects"][at(id)] = json!({"id": id.0, "text": text_v}); + let mut doc = d.clone(); + let e = write_out(&mut doc, &targets, &bytes, &read_only, writes, &out).unwrap_err().to_string(); + assert!(e.contains(&says), "{says}: {e}"); + assert_eq!(doc, d); + } + // At the limit the text is written; truncated type still moves. + let mut out = input.clone(); + out["objects"][at(text)] = json!({"id": text.0, "text": {"runs": [run("x".repeat(MAX_INPUT_TEXT))]}}); + out["objects"][at(long)] = json!({"id": long.0, "transform": [1, 0, 0, 1, 3, 4]}); + write_out(&mut d, &targets, &bytes, &read_only, writes, &out).unwrap(); + assert!(matches!(&d.node(text).unwrap().kind, NodeKind::Text(t) if t.plain_text().len() == MAX_INPUT_TEXT)); + assert!( + matches!(&d.node(long).unwrap().kind, NodeKind::Text(t) if t.xf == Affine::translate((3.0, 4.0)) && t.plain_text().len() == MAX_INPUT_TEXT + 1) + ); +} + +/// An inline graphic in type stays as it was, in its place among the inline graphics: the runs +/// around it can change, and adding, removing or changing one is refused. +#[test] +fn inline_graphics_in_written_type_stay_as_they_were() { + use vectorcraft_doc::{CharStyle, InlineArt, TextObject, TextRun}; + let (mut d, _, layer, _) = mixed(); + let mut t = TextObject::point(Point::new(0.0, 0.0), "A", CharStyle::default()); + t.runs = vec![ + TextRun::new("A", CharStyle::default()), + TextRun::inline(InlineArt::new("Star"), CharStyle::default()), + TextRun::new("B", CharStyle::default()), + ]; + let n = Node::new(d.alloc_id(), NodeKind::Text(Box::new(t))); + let id = d.insert(Some(layer), usize::MAX, n).unwrap(); + let targets = vec![id]; + let (bytes, read_only) = encode_input_with(&d, &targets, &[InputKind::Type], usize::MAX).unwrap(); + let input: Value = serde_json::from_slice(&bytes).unwrap(); + let runs = input["objects"][0]["text"]["runs"].clone(); + let writes = &[InputKind::Type]; + let with = |runs: Value| json!({"objects": [{"id": id.0, "text": {"runs": runs}}]}); + let mut changed = runs.clone(); + changed[0]["text"] = json!("Before "); + changed[2]["text"] = json!(" after"); + let mut doc = d.clone(); + write_out(&mut doc, &targets, &bytes, &read_only, writes, &with(changed)).unwrap(); + let NodeKind::Text(t) = &doc.node(id).unwrap().kind else { panic!("type") }; + assert_eq!(t.plain_text(), "Before \u{FFFC} after"); + assert_eq!(t.runs[1].inline.as_ref().map(|a| a.symbol.as_str()), Some("Star")); + let mut moved = runs.clone(); + moved[1]["inline"]["symbol"] = json!("Moon"); + let without = json!([runs[0], runs[2]]); + let doubled = json!([runs[0], runs[1], runs[1], runs[2]]); + for bad in [moved, without, doubled] { + let mut doc = d.clone(); + let e = write_out(&mut doc, &targets, &bytes, &read_only, writes, &with(bad.clone())).unwrap_err().to_string(); + assert!(e.contains("inline graphics can't be added, removed, reordered or changed"), "{bad}: {e}"); + assert_eq!(doc, d); + } +} + +/// Runs written without `paragraphs` keep each paragraph's style when the number of paragraphs +/// stays the same, and otherwise the styles follow the paragraphs' text: a paragraph whose text +/// stays keeps its style, also when changes are made at two places, a paragraph added at the start +/// takes the style of the next one and one added later the style of the one before it, and joining +/// two paragraphs keeps the first one's style. +#[test] +fn written_runs_without_paragraphs_keep_each_paragraph_s_style() { + use vectorcraft_doc::{CharStyle, Justify, ParaStyle, TextObject}; + let (mut d, _, layer, _) = mixed(); + let mut t = TextObject::point(Point::new(0.0, 0.0), "A\nB\nC", CharStyle::default()); + let styled = |justify| ParaStyle { justify, ..ParaStyle::default() }; + t.set_paragraph_styles(vec![styled(Justify::Left), styled(Justify::Center), styled(Justify::Right)]); + let n = Node::new(d.alloc_id(), NodeKind::Text(Box::new(t))); + let id = d.insert(Some(layer), usize::MAX, n).unwrap(); + let targets = vec![id]; + let (bytes, read_only) = encode_input_with(&d, &targets, &[InputKind::Type], usize::MAX).unwrap(); + let justified = |text: &str| { + let out = json!({"objects": [{"id": id.0, "text": {"runs": [{"text": text, "style": CharStyle::default()}]}}]}); + let mut doc = d.clone(); + write_out(&mut doc, &targets, &bytes, &read_only, &[InputKind::Type], &out).unwrap(); + let NodeKind::Text(t) = &doc.node(id).unwrap().kind else { panic!("type") }; + assert_eq!(t.plain_text(), text); + (0..t.paragraph_count()).map(|i| t.para_at(i).justify).collect::>() + }; + assert_eq!(justified("X\nA\nB\nC"), [Justify::Left, Justify::Left, Justify::Center, Justify::Right]); + assert_eq!(justified("A\nBé\nC"), [Justify::Left, Justify::Center, Justify::Right]); + assert_eq!(justified("One\nTwo\nThree"), [Justify::Left, Justify::Center, Justify::Right]); + assert_eq!(justified("AB\nC"), [Justify::Left, Justify::Right]); + assert_eq!(justified("A\nB\nC\nD"), [Justify::Left, Justify::Center, Justify::Right, Justify::Right]); + // Two separate changes: B and C keep their styles. + assert_eq!(justified("X\nA\nB\nC\nY"), [Justify::Left, Justify::Left, Justify::Center, Justify::Right, Justify::Right]); + assert_eq!(justified("A\nX\nB\nC\nY"), [Justify::Left, Justify::Left, Justify::Center, Justify::Right, Justify::Right]); + // A changed paragraph takes the style of the one it replaces; the one added after it, that style. + assert_eq!(justified("A\nB2\nB3\nC"), [Justify::Left, Justify::Center, Justify::Center, Justify::Right]); + assert_eq!(justified("A2\nC"), [Justify::Left, Justify::Right]); +} + +/// A paragraph that a change adds next to a numbered one takes its style without the number, and +/// the numbered paragraph keeps it. +#[test] +fn written_runs_give_an_added_paragraph_no_list_number() { + use vectorcraft_doc::text::ParaList; + use vectorcraft_doc::{CharStyle, ParaStyle, TextObject}; + let (mut d, _, layer, _) = mixed(); + let mut t = TextObject::point(Point::new(0.0, 0.0), "A\nB", CharStyle::default()); + let numbered = ParaStyle { list: Some(ParaList { start: Some(5), ..ParaList::default() }), ..ParaStyle::default() }; + t.set_paragraph_styles(vec![ParaStyle::default(), numbered]); + let n = Node::new(d.alloc_id(), NodeKind::Text(Box::new(t))); + let id = d.insert(Some(layer), usize::MAX, n).unwrap(); + let targets = vec![id]; + let (bytes, read_only) = encode_input_with(&d, &targets, &[InputKind::Type], usize::MAX).unwrap(); + let out = json!({"objects": [{"id": id.0, "text": {"runs": [{"text": "X\nA\nB\nY", "style": CharStyle::default()}]}}]}); + write_out(&mut d, &targets, &bytes, &read_only, &[InputKind::Type], &out).unwrap(); + let NodeKind::Text(t) = &d.node(id).unwrap().kind else { panic!("type") }; + let starts: Vec<_> = (0..t.paragraph_count()).map(|i| t.para_at(i).list.map(|l| l.start)).collect(); + assert_eq!(starts, [None, None, Some(Some(5)), Some(None)]); +} + +/// Past 262,144 pairs of old and new paragraphs to compare, the paragraphs are paired in order. +#[test] +fn written_runs_pair_paragraphs_in_order_past_the_compare_limit() { + use vectorcraft_doc::{CharStyle, Justify, ParaStyle, TextObject}; + let (mut d, _, layer, _) = mixed(); + let paras: Vec = (0..600).map(|i| format!("p{i}")).collect(); + let mut t = TextObject::point(Point::new(0.0, 0.0), ¶s.join("\n"), CharStyle::default()); + let styled = |i: usize| ParaStyle { justify: if i.is_multiple_of(2) { Justify::Left } else { Justify::Right }, ..ParaStyle::default() }; + t.set_paragraph_styles((0..600).map(styled).collect()); + let n = Node::new(d.alloc_id(), NodeKind::Text(Box::new(t))); + let id = d.insert(Some(layer), usize::MAX, n).unwrap(); + let targets = vec![id]; + let (bytes, read_only) = encode_input_with(&d, &targets, &[InputKind::Type], usize::MAX).unwrap(); + // 600 old paragraphs times 602 new ones: none starts or ends both texts. + let text = format!("X\n{}\nY", paras.join("\n")); + let out = json!({"objects": [{"id": id.0, "text": {"runs": [{"text": text, "style": CharStyle::default()}]}}]}); + write_out(&mut d, &targets, &bytes, &read_only, &[InputKind::Type], &out).unwrap(); + let NodeKind::Text(t) = &d.node(id).unwrap().kind else { panic!("type") }; + assert_eq!(t.paragraph_count(), 602); + let got: Vec<_> = (0..602).map(|i| t.para_at(i).justify).collect(); + let want: Vec<_> = (0..602).map(|i| styled(i.min(599)).justify).collect(); + assert_eq!(got, want); +} + +/// Every number in the character and paragraph styles a filter writes is checked against the range +/// the style commands keep it to, in a style of the filter's own and in one the type already has, +/// and a custom Kinsoku set must be one of the document's. Each bad value is refused naming the +/// object and the field, and the document stays as it was. A set of the document's, given by +/// name, takes the document's characters. +#[test] +fn written_style_numbers_are_checked_even_in_a_style_the_type_has() { + use vectorcraft_doc::{CharStyle, KinsokuSet, ParaStyle, TabAlign, TabStop, TextObject}; + let (mut d, _, layer, _) = mixed(); + d.kinsoku_sets.push(KinsokuSet { name: "Mine".into(), cannot_start: vec!['、'], ..KinsokuSet::default() }); + let stop = TabStop { position: 10.0, align: TabAlign::Left, leader: String::new(), align_on: '.' }; + let outside = KinsokuSet { name: "Elsewhere".into(), ..KinsokuSet::default() }; + let bad_chars: [(&str, CharStyle, &str); 5] = [ + ("leading 1e9", CharStyle { leading: Some(1e9), ..CharStyle::default() }, "style.leading: `leading` must be from 0.1 to 5000"), + ("scale 0", CharStyle { h_scale: 0.0, ..CharStyle::default() }, "style.h_scale: `h_scale` must be from 1 to 10000"), + ("baseline shift", CharStyle { baseline_shift: 1e9, ..CharStyle::default() }, "style.baseline_shift: `baseline_shift` must be from"), + ("tracking", CharStyle { tracking: -5000.0, ..CharStyle::default() }, "style.tracking: `tracking` must be from -1000 to 10000"), + ("aki", CharStyle { aki_left: 2000.0, ..CharStyle::default() }, "style.akiLeft: `akiLeft` must be from 0 to 1000"), + ]; + let hard = |set: KinsokuSet| ParaStyle { kinsoku: vectorcraft_doc::Kinsoku::Hard, kinsoku_set: Some(Arc::new(set)), ..ParaStyle::default() }; + let bad_paras: [(&str, ParaStyle, &str); 4] = [ + ("100000 tabs", ParaStyle { tabs: vec![stop.clone(); 100_000], ..ParaStyle::default() }, "paragraphs[0].tabs: at most 256 tab stops"), + ("indent", ParaStyle { left_indent: 1e9, ..ParaStyle::default() }, "paragraphs[0].left_indent: `left_indent` must be from -1296 to 1296"), + ( + "hyphenation", + ParaStyle { hyphenation: vectorcraft_doc::HyphenationOptions { after_first: 0, ..Default::default() }, ..ParaStyle::default() }, + "paragraphs[0].hyphenation.after_first", + ), + ("unknown kinsoku set", hard(outside.clone()), "paragraphs[0].kinsoku_set: the document has no Kinsoku set named 'Elsewhere'"), + ]; + // `own`: the type already has the bad style, and the filter changes only its other run or + // paragraph; otherwise the bad style is the filter's own. + let run = |id: NodeId, own: bool, bad: &CharStyle| { + let mut t = TextObject::point(Point::new(0.0, 0.0), "A\nB", CharStyle::default()); + if own { + t.runs = vec![vectorcraft_doc::TextRun::new("A\n", bad.clone()), vectorcraft_doc::TextRun::new("B", CharStyle::default())]; + } + let mut doc = d.clone(); + let n = Node::new(id, NodeKind::Text(Box::new(t))); + let id = doc.insert(Some(layer), usize::MAX, n).unwrap(); + (doc, id) + }; + let check = |doc: &Document, id: NodeId, entry: Value, says: &str, what: &str| { + let (bytes, read_only) = encode_input_with(doc, &[id], &[InputKind::Type], usize::MAX).unwrap(); + let mut entry = entry; + entry["id"] = json!(id.0); + let mut changed = doc.clone(); + let e = write_out(&mut changed, &[id], &bytes, &read_only, &[InputKind::Type], &json!({"objects": [entry]})).unwrap_err().to_string(); + assert!(e.contains(&format!("(id {}).text.", id.0)) && e.contains(says), "{what}: {says}: {e}"); + assert_eq!(&changed, doc, "{what}: nothing changed"); + }; + let fresh = d.clone().alloc_id(); + for (what, bad, says) in &bad_chars { + let (doc, id) = run(fresh, false, bad); + let runs = json!([{"text": "A\n", "style": bad}, {"text": "B", "style": CharStyle::default()}]); + check(&doc, id, json!({"text": {"runs": runs}}), says, what); + let (doc, id) = run(fresh, true, bad); + let runs = json!([{"text": "A\n", "style": bad}, {"text": "Be", "style": CharStyle::default()}]); + check(&doc, id, json!({"text": {"runs": runs}}), says, &format!("{what}, a style the type has")); + } + let centered = ParaStyle { justify: vectorcraft_doc::Justify::Center, ..ParaStyle::default() }; + for (what, bad, says) in &bad_paras { + let (doc, id) = run(fresh, false, &CharStyle::default()); + check(&doc, id, json!({"text": {"paragraphs": [bad, ParaStyle::default()]}}), says, what); + let mut doc = doc; + if let Some(Node { kind: NodeKind::Text(t), .. }) = doc.node_mut(id) { + t.set_paragraph_styles(vec![bad.clone(), ParaStyle::default()]); + } + check(&doc, id, json!({"text": {"paragraphs": [bad, centered]}}), says, &format!("{what}, a style the type has")); + } + // A set the document has, by name, takes the document's characters. + let (mut doc, id) = run(fresh, false, &CharStyle::default()); + let (bytes, read_only) = encode_input_with(&doc, &[id], &[InputKind::Type], usize::MAX).unwrap(); + let named = hard(KinsokuSet { name: "Mine".into(), cannot_start: vec!['x'; 3], ..KinsokuSet::default() }); + let out = json!({"objects": [{"id": id.0, "text": {"paragraphs": [named, ParaStyle::default()]}}]}); + write_out(&mut doc, &[id], &bytes, &read_only, &[InputKind::Type], &out).unwrap(); + let NodeKind::Text(t) = &doc.node(id).unwrap().kind else { panic!("type") }; + assert_eq!(t.para_at(0).kinsoku_set.as_deref().map(|s| s.cannot_start.clone()), Some(vec!['、'])); +} + /// A filter's `documentData`: absent keeps what the plug-in keeps, `null` forgets it, any other JSON /// of at most [`MAX_DOCUMENT_DATA`] bytes is kept, and more refuses the whole output. #[test] diff --git a/crates/plugins/src/objects/writes.rs b/crates/plugins/src/objects/writes.rs new file mode 100644 index 0000000000..574ebb6216 --- /dev/null +++ b/crates/plugins/src/objects/writes.rs @@ -0,0 +1,526 @@ +//! What a filter whose manifest lists `writes` may change about the type, images and symbol +//! instances it was given: each one's name and transform; type's runs, with their character +//! attributes, and its paragraph styles; an image's opacity; and the symbol an instance shows. +//! Every other field stays read-only, and every value is checked before anything changes. + +use std::collections::HashSet; + +use serde::de::DeserializeOwned; +use serde_json::{Map, Value}; +use vectorcraft_doc::text::{AttrRangeError, INLINE_CHAR}; +use vectorcraft_doc::{CharStyle, Document, JustificationOptions, KinsokuSet, Node, NodeKind, ParaStyle, TextObject, TextRun}; +use vectorcraft_geom::Affine; + +use super::{ + MAX_COORD, MAX_INPUT_RUNS, MAX_INPUT_TEXT, MAX_INPUT_TEXT_TOTAL, admit_paint, decode_name, decode_paint, first_difference, out_err, + read_only_changed, +}; +use crate::{Error, InputKind, Result}; + +/// The longest font family name a filter may set, in characters. +const MAX_FAMILY: usize = 256; +/// The smallest determinant a transform a filter sets may have: a smaller one flattens the object. +const MIN_DETERMINANT: f64 = 1e-12; +/// The most pairs of an old and a new paragraph, past those both texts start and end with, that a +/// change of the paragraph count compares by their text ([`moved_para_styles`]). +const MAX_MATCHED_PAIRS: usize = 1 << 18; + +/// The fields of an object of `kind` a filter that lists the kind in `writes` may change. +fn writable(kind: InputKind) -> &'static [&'static str] { + match kind { + InputKind::Type => &["name", "transform", "text"], + InputKind::Image => &["name", "transform", "opacity"], + InputKind::SymbolInstance => &["name", "transform", "symbolId"], + } +} + +/// The changes entry `o` of a filter's output makes to object `given` of `kind` (as the input gave +/// it), `None` when it changes nothing. Fields it leaves out keep their values; a field it gives +/// that isn't [`writable`] must be as given. Changed type text counts toward `text`, the bytes of +/// text written over the whole output. The changes are keyed `name`, `transform`, `opacity`, +/// `symbolId`, `runs` and `paragraphs`; their values are checked when they are applied ([`apply`]). +pub(super) fn changes(o: &Map, given: &Value, kind: InputKind, at: &str, text: &mut usize) -> Result>> { + let mut keys: Vec<&String> = o.keys().filter(|k| *k != "id").collect(); + keys.sort(); + let mut out = Map::new(); + for k in keys { + let v = &o[k]; + let was = given.get(k); + if !writable(kind).contains(&k.as_str()) { + if let Some(field) = was.map_or_else(|| Some(k.clone()), |w| first_difference(v, w, k)) { + return Err(read_only_changed(at, &field)); + } + continue; + } + match (k.as_str(), was) { + ("text", Some(was)) => text_changes(k, v, was, given.get("truncated") == Some(&Value::Bool(true)), at, text, &mut out)?, + ("name", None) if v.is_null() => {} + (_, Some(was)) if first_difference(v, was, "").is_none() => {} + _ => { + out.insert(k.clone(), v.clone()); + } + } + } + Ok((!out.is_empty()).then_some(out)) +} + +/// The `runs` and `paragraphs` of type text `v`, the output's field `key`, that differ from `was` +/// (the text the input gave), into `out`; its other fields must be as given, and type given as +/// `truncated` keeps its text. A changed list is held to [`MAX_INPUT_RUNS`] entries, and changed +/// runs to [`MAX_INPUT_TEXT`] bytes of text, which count toward `total`, held to +/// [`MAX_INPUT_TEXT_TOTAL`], and to [`MAX_INPUT_RUNS`] paragraphs. With changed runs, `paragraphs` +/// given as they were go into `out` too, to be checked against the new paragraphs. +fn text_changes(key: &str, v: &Value, was: &Value, truncated: bool, at: &str, total: &mut usize, out: &mut Map) -> Result<()> { + let t = v.as_object().ok_or_else(|| out_err(at, format!("`{key}` must be an object")))?; + let mut keys: Vec<&String> = t.keys().collect(); + keys.sort(); + for k in keys { + let field = format!("{key}.{k}"); + let given = was.get(k); + let differs = given.is_none_or(|g| first_difference(&t[k], g, "").is_some()); + if !matches!(k.as_str(), "runs" | "paragraphs") { + if differs { + let shown = given.and_then(|g| first_difference(&t[k], g, &field)).unwrap_or_else(|| field.clone()); + return Err(read_only_changed(at, &shown)); + } + continue; + } + if !differs { + continue; + } + if truncated { + return Err(out_err(&format!("{at}.{field}"), "the text of type given as `truncated` can't be changed")); + } + let list = t[k].as_array().filter(|l| l.len() <= MAX_INPUT_RUNS); + let list = list.ok_or_else(|| out_err(&format!("{at}.{field}"), format!("must be a list of at most {MAX_INPUT_RUNS} entries")))?; + if k == "runs" { + if list.is_empty() { + return Err(out_err(&format!("{at}.{field}"), "type needs at least one run")); + } + let bytes = list.iter().fold(0usize, |n, r| n.saturating_add(r.get("text").and_then(Value::as_str).map_or(0, str::len))); + if bytes > MAX_INPUT_TEXT { + return Err(out_err(&format!("{at}.{field}"), format!("{bytes} bytes of text (limit {MAX_INPUT_TEXT})"))); + } + // Each paragraph gets a paragraph style; the text holds at most as many paragraphs as runs. + let breaks = |r: &Value| r.get("text").and_then(Value::as_str).map_or(0, |s| s.bytes().filter(|&b| b == b'\n').count()); + let paragraphs = list.iter().fold(1usize, |n, r| n.saturating_add(breaks(r))); + if paragraphs > MAX_INPUT_RUNS { + return Err(out_err(&format!("{at}.{field}"), format!("{paragraphs} paragraphs (limit {MAX_INPUT_RUNS})"))); + } + *total = total.saturating_add(bytes); + if *total > MAX_INPUT_TEXT_TOTAL { + return Err(out_err(&format!("{at}.{field}"), format!("more than {MAX_INPUT_TEXT_TOTAL} bytes of text over the output"))); + } + } + out.insert(k.clone(), t[k].clone()); + } + // Paragraph styles given as they were still need one per paragraph of the new runs. + if out.contains_key("runs") + && !out.contains_key("paragraphs") + && let Some(p) = t.get("paragraphs") + { + out.insert("paragraphs".into(), p.clone()); + } + Ok(()) +} + +/// Every attribute name `T` reads, including those its JSON leaves out at their defaults: the field +/// names serde's derive hands `deserialize_struct`. +fn attr_names() -> &'static [&'static str] { + use serde::de::{Error as _, Visitor, value::Error}; + + struct Names<'a>(&'a mut &'static [&'static str]); + impl<'de> serde::Deserializer<'de> for Names<'_> { + type Error = Error; + fn deserialize_any>(self, _: V) -> std::result::Result { + Err(Error::custom("not a struct")) + } + fn deserialize_struct>(self, _: &'static str, fields: &'static [&'static str], _: V) -> std::result::Result { + *self.0 = fields; + Err(Error::custom("field names only")) + } + serde::forward_to_deserialize_any! { + bool i8 i16 i32 i64 i128 u8 u16 u32 u64 u128 f32 f64 char str string bytes byte_buf option unit + unit_struct newtype_struct seq tuple tuple_struct map enum identifier ignored_any + } + } + + let mut fields: &'static [&'static str] = &[]; + // Always an error: the probe only records the names. + let _ = T::deserialize(Names(&mut fields)); + fields +} + +/// `v`, the field `key` of the entry at `parent`, as a `T` whose attributes are all ones `T` reads: +/// a value that isn't an object is an error at `parent`, and an unknown key, as an ill-typed value, +/// an error at `parent.key`. +fn strict(v: &Value, parent: &str, key: &str) -> Result { + let o = v.as_object().ok_or_else(|| out_err(parent, format!("`{key}` must be an object")))?; + let at = format!("{parent}.{key}"); + let names = attr_names::(); + if let Some(k) = o.keys().find(|k| !names.contains(&k.as_str())) { + let k = crate::permissions::display_text(k, crate::permissions::MAX_SHOWN_FIELD); + return Err(out_err(&at, format!("unknown key '{k}'"))); + } + serde_json::from_value(v.clone()).map_err(|e| out_err(&at, e)) +} + +/// The field `key` of `v`, the style at `at`, holds only attributes `T` reads: an object, or each +/// object of a list. An unknown key is an error at `at.key` (or `at.key[i]`); other values are left +/// to the style's own checks. +fn known_keys(v: &Value, at: &str, key: &str) -> Result<()> { + let names = attr_names::(); + let check = |o: &Map, at: &str| match o.keys().find(|k| !names.contains(&k.as_str())) { + Some(k) => { + let k = crate::permissions::display_text(k, crate::permissions::MAX_SHOWN_FIELD); + Err(out_err(at, format!("unknown key '{k}'"))) + } + None => Ok(()), + }; + match v.get(key) { + Some(Value::Object(o)) => check(o, &format!("{at}.{key}")), + Some(Value::Array(list)) => list.iter().enumerate().try_for_each(|(i, e)| match e { + Value::Object(o) => check(o, &format!("{at}.{key}[{i}]")), + _ => Ok(()), + }), + _ => Ok(()), + } +} + +/// A transform from a filter's output: six finite numbers, each within ±[`MAX_COORD`], that don't +/// flatten the object. +fn decode_transform(v: &Value, at: &str) -> Result { + let c: Option> = v.as_array().and_then(|a| a.iter().map(Value::as_f64).collect()); + let c: [f64; 6] = c.and_then(|c| c.try_into().ok()).ok_or_else(|| out_err(at, "must be a list of 6 numbers"))?; + if !c.iter().all(|x| x.is_finite() && x.abs() <= MAX_COORD) { + return Err(out_err(at, format!("a number is out of range (limit ±{MAX_COORD})"))); + } + let xf = Affine::new(c); + if xf.determinant().abs() < MIN_DETERMINANT { + return Err(out_err(at, "flattens the object to a line or a point")); + } + Ok(xf) +} + +/// The transform object `n` is given with: type's and an instance's own, an image's (for a +/// distorted image, the placement nearest its corners at its middle). +fn given_transform(n: &Node) -> Option { + match &n.kind { + NodeKind::Text(t) => Some(t.xf), + NodeKind::Image(im) => Some(vectorcraft_doc::image_quad::nearest_affine(n).unwrap_or(im.xf)), + NodeKind::SymbolInstance { xf, .. } => Some(*xf), + _ => None, + } +} + +/// Applies `changes` ([`changes`]) to `n`, an input object of `doc`; `at` names it in errors. Each +/// value is checked first, and an error leaves `n` to be dropped. +pub(super) fn apply(doc: &Document, n: &mut Node, changes: &Map, at: &str) -> Result<()> { + if let Some(v) = changes.get("transform") { + let at = format!("{at}.transform"); + let new = decode_transform(v, &at)?; + let old = given_transform(n).filter(|xf| xf.determinant().abs() >= MIN_DETERMINANT); + let old = old.ok_or_else(|| out_err(&at, "an object flattened to a line or a point can't be placed again"))?; + // Everything the object carries moves with it: a distorted image's corners, its gradients. + n.transform(new * old.inverse(), false); + let distorted = n.is_distorted_image(); + match &mut n.kind { + NodeKind::Text(t) => t.xf = new, + NodeKind::SymbolInstance { xf, .. } => *xf = new, + NodeKind::Image(im) if !distorted => im.xf = new, + _ => {} + } + } + if let Some(v) = changes.get("opacity") { + let op = v.as_f64().filter(|o| (0.0..=1.0).contains(o)); + n.opacity = op.ok_or_else(|| out_err(&format!("{at}.opacity"), "must be a number from 0 to 1"))? as f32; + } + if let Some(v) = changes.get("symbolId") { + let at = format!("{at}.symbolId"); + let name = v.as_str().ok_or_else(|| out_err(&at, "must be the name of a symbol"))?; + if !doc.symbols.iter().any(|s| s.name == name) { + let shown = crate::permissions::display_text(name, crate::permissions::MAX_SHOWN_FIELD); + return Err(out_err(&at, format!("'{shown}' is not a symbol in this document"))); + } + let other = matches!(&n.kind, NodeKind::SymbolInstance { symbol, .. } if symbol != name); + if let NodeKind::SymbolInstance { symbol, .. } = &mut n.kind { + *symbol = name.to_string(); + } + // An edited part's path names an object of the old symbol's art, as Replace Symbol finds. + if other && !n.extras().symbol_overrides.is_empty() { + n.extras_mut().symbol_overrides.clear(); + } + } + if changes.contains_key("runs") || changes.contains_key("paragraphs") { + let story = doc.story_of(n.id).len(); + let NodeKind::Text(t) = &mut n.kind else { return Err(read_only_changed(at, "text")) }; + set_text(doc, t, story > 1, changes.get("runs"), changes.get("paragraphs"), at)?; + } + if let Some(v) = changes.get("name") { + n.name = Some(decode_name(v, at)?).filter(|s| !s.trim().is_empty()); + } + Ok(()) +} + +/// Gives type `t` the runs `runs` and paragraph styles `paragraphs` a filter returned (`threaded`: +/// it is a frame of a story that flows through others). Each run has `text`, `style` and, for an +/// inline graphic, `inline`; each attribute is one the type reads. Inline graphics stay as they +/// were, in the same order, and the characters of threaded type or type with ruby stay as they +/// were. Every number of every run's style is in the range the character style commands keep it +/// to ([`CharStyle::check_ranges`]), and a run whose style isn't one of the type's own has a font +/// family, and its paints are checked as an object's are. Paragraph styles are one per paragraph +/// ([`para_style`]). With runs alone, each paragraph keeps its style when the number of paragraphs stays +/// the same, and otherwise the styles follow the paragraphs' text ([`moved_para_styles`]). +fn set_text(doc: &Document, t: &mut TextObject, threaded: bool, runs: Option<&Value>, paragraphs: Option<&Value>, at: &str) -> Result<()> { + if let Some(runs) = runs { + let at = format!("{at}.text.runs"); + let list = runs.as_array().map(Vec::as_slice).unwrap_or_default(); + // The type's own styles, as JSON text, to look each run's style up once. + let own: HashSet = t.runs.iter().filter_map(|r| serde_json::to_string(&r.style).ok()).collect(); + let mut new = Vec::with_capacity(list.len()); + for (i, v) in list.iter().enumerate() { + let at = format!("{at}[{i}]"); + let o = v.as_object().ok_or_else(|| out_err(&at, "a run must be {\"text\", \"style\", \"inline\"?}"))?; + if let Some(k) = o.keys().find(|k| !matches!(k.as_str(), "text" | "style" | "inline")) { + let k = crate::permissions::display_text(k, crate::permissions::MAX_SHOWN_FIELD); + return Err(out_err(&at, format!("unknown key '{k}'"))); + } + let key = "text"; + let text = o.get(key).and_then(Value::as_str).ok_or_else(|| out_err(&at, format!("`{key}` must be a string")))?; + let style_v = o.get("style").unwrap_or(&Value::Null); + let mut style: CharStyle = strict(style_v, &at, "style")?; + known_keys::(style_v, &format!("{at}.style"), "stroke_dash")?; + let inline = match o.get("inline") { + None | Some(Value::Null) => None, + Some(v) => Some(serde_json::from_value(v.clone()).map_err(|e| out_err(&format!("{at}.inline"), e))?), + }; + if inline.is_none() { + if text.contains(INLINE_CHAR) { + return Err(out_err(&at, "`text` holds the character of an inline graphic")); + } + // Every number goes to the layout, so it is checked even in a style the type has. + style.check_ranges(|_| true).map_err(|e| range_err(&format!("{at}.style"), &e))?; + for key in ["fill", "stroke"] { + if let Some(p) = style_v.get(key) { + check_paint_keys(p, &format!("{at}.style.{key}"))?; + } + } + if !serde_json::to_string(&style).is_ok_and(|s| own.contains(&s)) { + check_style(doc, &mut style, t.runs.get(i).map(|r| &r.style), &format!("{at}.style"))?; + } + } + new.push(TextRun { text: text.to_string(), style, inline }); + } + // Inline graphics are compared as saved (their measured bounds aren't), and keep those. + let saved = |r: &&TextRun| serde_json::to_value(r).ok(); + let old_inline: Vec<&TextRun> = t.runs.iter().filter(|r| r.inline.is_some()).collect(); + let new_inline: Vec<&TextRun> = new.iter().filter(|r| r.inline.is_some()).collect(); + if old_inline.len() != new_inline.len() || old_inline.iter().zip(&new_inline).any(|(a, b)| saved(a) != saved(b)) { + return Err(out_err(&at, "inline graphics can't be added, removed, reordered or changed")); + } + let mut kept = old_inline.into_iter().cloned().collect::>().into_iter(); + for r in new.iter_mut().filter(|r| r.inline.is_some()) { + if let Some(old) = kept.next() { + *r = old; + } + } + let plain: String = new.iter().map(|r| r.text.as_str()).collect(); + let old = t.plain_text(); + let mut moved = None; + if plain != old { + if threaded { + return Err(out_err(&at, "the characters of threaded type can't be changed")); + } + if !t.ruby.is_empty() { + return Err(out_err(&at, "the characters of type with ruby can't be changed")); + } + let breaks = |s: &str| s.bytes().filter(|&b| b == b'\n').count(); + if paragraphs.is_none() && breaks(&plain) != breaks(&old) { + // Paragraphs added or joined: the styles follow the paragraphs' text. With as many + // paragraphs as before, each keeps its style. + moved = Some(moved_para_styles(&t.paragraph_styles(), &old, &plain)); + } + } + t.runs = new; + if let Some(styles) = moved { + t.set_paragraph_styles(styles); + } + } + match paragraphs { + Some(v) => { + let text = format!("{at}.text"); + let list = v.as_array().map(Vec::as_slice).unwrap_or_default(); + let count = t.paragraph_count(); + if list.len() != count { + return Err(out_err(&format!("{text}.paragraphs"), format!("expected {count} paragraph styles, one per paragraph"))); + } + let styles = list.iter().enumerate().map(|(i, p)| para_style(doc, p, &text, &format!("paragraphs[{i}]"))).collect::>()?; + t.set_paragraph_styles(styles); + } + None => t.normalize_paras(), + } + // The layout is measured again before the type is drawn. + t.cached_bounds = None; + t.cached_baselines.clear(); + t.cached_ink = None; + Ok(()) +} + +/// The paragraph styles of text `new` that replaced `old`, whose paragraphs had `styles` (one per +/// paragraph). The paragraphs, split at `\n`, are matched as a longest common subsequence of their +/// texts after the paragraphs both start and end with are set aside; when the paragraphs left in +/// the old text times those left in the new pass [`MAX_MATCHED_PAIRS`], they are paired in order +/// instead. A +/// matched paragraph keeps its style. Between two matched paragraphs, the changed ones take the +/// styles of the old paragraphs there in order, and the last of those past their count; paragraphs +/// added where there were none take the style of the paragraph before them, or of the next one at +/// the start. A style copied to a paragraph that was not there loses its list number +/// ([`vectorcraft_doc::text::ParaList::start`]). +fn moved_para_styles(styles: &[ParaStyle], old: &str, new: &str) -> Vec { + let a: Vec<&str> = old.split('\n').collect(); + let b: Vec<&str> = new.split('\n').collect(); + let pre = a.iter().zip(&b).take_while(|(x, y)| x == y).count(); + let (a_rest, b_rest) = (a.get(pre..).unwrap_or_default(), b.get(pre..).unwrap_or_default()); + let suf = a_rest.iter().rev().zip(b_rest.iter().rev()).take_while(|(x, y)| x == y).count(); + // `matched[j]`: the old paragraph that new paragraph `j` is, if any. + let mut matched: Vec> = vec![None; b.len()]; + for (j, m) in matched.iter_mut().enumerate().take(pre) { + *m = Some(j); + } + for k in 0..suf { + if let Some(m) = matched.get_mut(b.len() - 1 - k) { + *m = Some(a.len() - 1 - k); + } + } + let (am, bm) = (a_rest.get(..a_rest.len() - suf).unwrap_or_default(), b_rest.get(..b_rest.len() - suf).unwrap_or_default()); + if !am.is_empty() && !bm.is_empty() && am.len().saturating_mul(bm.len()) <= MAX_MATCHED_PAIRS { + let mut ids = std::collections::HashMap::new(); + let mut id = |s: &str| { + let next = ids.len(); + *ids.entry(s.to_string()).or_insert(next) + }; + let ai: Vec = am.iter().map(|s| id(s)).collect(); + let bi: Vec = bm.iter().map(|s| id(s)).collect(); + // `len[i * w + j]`: the length of the longest common subsequence of `ai[i..]` and `bi[j..]`. + let w = bi.len() + 1; + let mut len = vec![0u32; (ai.len() + 1) * w]; + for i in (0..ai.len()).rev() { + for j in (0..bi.len()).rev() { + let at = |i: usize, j: usize| len.get(i * w + j).copied().unwrap_or(0); + let v = if ai.get(i) == bi.get(j) { at(i + 1, j + 1) + 1 } else { at(i + 1, j).max(at(i, j + 1)) }; + if let Some(c) = len.get_mut(i * w + j) { + *c = v; + } + } + } + let at = |i: usize, j: usize| len.get(i * w + j).copied().unwrap_or(0); + let (mut i, mut j) = (0, 0); + while i < ai.len() && j < bi.len() { + if ai.get(i) == bi.get(j) { + if let Some(m) = matched.get_mut(pre + j) { + *m = Some(pre + i); + } + (i, j) = (i + 1, j + 1); + } else if at(i + 1, j) >= at(i, j + 1) { + i += 1; + } else { + j += 1; + } + } + } + let style = |i: usize, numbered: bool| { + let mut s = styles.get(i).or(styles.last()).cloned().unwrap_or_default(); + if !numbered && let Some(l) = s.list.as_mut() { + l.start = None; + } + s + }; + let mut out = Vec::with_capacity(b.len()); + let (mut next_old, mut j) = (0, 0); + while j < b.len() { + if let Some(&Some(i)) = matched.get(j) { + out.push(style(i, true)); + (next_old, j) = (i + 1, j + 1); + continue; + } + // New paragraphs `j..end` stand where old paragraphs `next_old..old_end` were. + let end = (j..b.len()).find(|&k| matched.get(k).is_some_and(Option::is_some)).unwrap_or(b.len()); + let old_end = matched.get(end).copied().flatten().unwrap_or(a.len()); + for g in 0..end - j { + out.push(if next_old < old_end { + style((next_old + g).min(old_end - 1), next_old + g < old_end) + } else { + style(next_old.checked_sub(1).unwrap_or(old_end), false) + }); + } + j = end; + } + out +} + +/// An attribute of the style at `at` out of its range, naming the attribute. +fn range_err(at: &str, e: &AttrRangeError) -> Error { + out_err(&format!("{at}.{}", e.key), &e.message) +} + +/// Paragraph style `v` from a filter's output, the entry `key` of the text at `parent`: each +/// attribute one a paragraph reads, each number in the range the paragraph style commands keep it +/// to ([`ParaStyle::check_ranges`], the Justification options as given), and a custom Kinsoku set +/// one of `doc`'s, by name, whose characters it takes. +fn para_style(doc: &Document, v: &Value, parent: &str, key: &str) -> Result { + let mut st: ParaStyle = strict(v, parent, key)?; + let at = format!("{parent}.{key}"); + known_keys::(v, &at, "hyphenation")?; + known_keys::(v, &at, "justification")?; + known_keys::(v, &at, "tabs")?; + known_keys::(v, &at, "list")?; + let justification = match v.get("justification") { + None | Some(Value::Null) => None, + Some(j) => Some(serde_json::from_value::(j.clone()).map_err(|e| out_err(&format!("{at}.justification"), e))?), + }; + st.check_ranges(justification.as_ref(), &[], |_, _| true).map_err(|e| range_err(&at, &e))?; + if let Some(set) = &st.kinsoku_set { + let found = KinsokuSet::named(&doc.kinsoku_sets, &set.name).ok_or_else(|| { + let shown = crate::permissions::display_text(&set.name, crate::permissions::MAX_SHOWN_FIELD); + out_err(&format!("{at}.kinsoku_set"), format!("the document has no Kinsoku set named '{shown}'")) + })?; + st.kinsoku_set = Some(std::sync::Arc::new(found.clone())); + } + Ok(st) +} + +/// Checks character style `s`, a filter's own (`was`: the style of the run in its place before): +/// its font family is 1 to [`MAX_FAMILY`] printable characters, counted as given, and its fill and +/// stroke are admitted as an object's paints are. Its numbers and its paints' keys are checked for +/// every run ([`set_text`]). +fn check_style(doc: &Document, s: &mut CharStyle, was: Option<&CharStyle>, at: &str) -> Result<()> { + let family = s.font_family.trim(); + if family.is_empty() || s.font_family.chars().count() > MAX_FAMILY || s.font_family.chars().any(char::is_control) { + return Err(out_err(&format!("{at}.font_family"), format!("must be 1-{MAX_FAMILY} printable characters"))); + } + let paint = |p: &vectorcraft_color::Paint, was: Option<&vectorcraft_color::Paint>, key: &str| { + let at = format!("{at}.{key}"); + let v = serde_json::to_value(p).map_err(|e| out_err(&at, e))?; + admit_paint(doc, decode_paint(&v, &at)?, was, &at) + }; + s.fill = paint(&s.fill, was.map(|w| &w.fill), "fill")?; + s.stroke = paint(&s.stroke, was.map(|w| &w.stroke), "stroke")?; + Ok(()) +} + +/// Checks that paint `v` of a style, at `at`, has no key besides `type` and those its `type` +/// reads; a key of another paint, or an unknown one, is an error naming it. +fn check_paint_keys(v: &Value, at: &str) -> Result<()> { + let Some(o) = v.as_object() else { return Ok(()) }; + let known: &[&str] = match o.get("type").and_then(Value::as_str) { + Some("solid") => &["color", "swatch", "tint"], + Some("gradient") => attr_names::(), + Some("pattern") => &["pattern", "xf"], + _ => &[], + }; + if let Some(k) = o.keys().find(|k| *k != "type" && !known.contains(&k.as_str())) { + let k = crate::permissions::display_text(k, crate::permissions::MAX_SHOWN_FIELD); + return Err(out_err(at, format!("unknown key '{k}'"))); + } + Ok(()) +} diff --git a/crates/plugins/src/permissions.rs b/crates/plugins/src/permissions.rs index 82f8db8641..5fda6fb896 100644 --- a/crates/plugins/src/permissions.rs +++ b/crates/plugins/src/permissions.rs @@ -15,7 +15,8 @@ use crate::{Error, Kind, Result}; /// The plug-in API level this host implements. A manifest's `api` (1 when left out) may be at most /// this. Level 2 adds the host imports ([`PROGRESS_API`]) and a live effect's `paintOutput` -/// ([`crate::painted`]); level 3 adds a manifest's `context` ([`CONTEXT_API`]). +/// ([`crate::painted`]); level 3 adds a filter's `writes` ([`WRITES_API`]) and a manifest's +/// `context` ([`CONTEXT_API`]). pub const API_LEVEL: u32 = 3; /// The API level that adds the host imports ([`crate::host::IMPORTS`]) and the `progress`, @@ -25,6 +26,9 @@ pub const PROGRESS_API: u32 = 2; /// The API level that adds a filter's `inputs` ([`crate::InputKind`]). pub const INPUTS_API: u32 = 2; +/// The API level that adds a filter's `writes`: the kinds among its `inputs` it may change. +pub const WRITES_API: u32 = 3; + /// The API level that reads a command's `menu` ([`crate::manifest::MenuPlace`]); below it the key /// is ignored. pub const MENU_API: u32 = 2; diff --git a/crates/ui-egui/src/i18n/ca.tsv b/crates/ui-egui/src/i18n/ca.tsv index 87f76147b6..e17017d95b 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -7929,6 +7929,35 @@ variable-list-end {0}, {1} {0} i {1} @msg `inputs` lists `{shown}` twice `inputs` inclou `{shown}` dues vegades @msg `inputs` needs `api` 2 or later `inputs` requereix `api` 2 o posterior @msg `inputs` needs the permission `doc.read` `inputs` requereix el permís `doc.read` +@msg only a filter declares `writes` només un filtre declara `writes` +@msg `writes` names an unknown object kind `{shown}`: use type, image or symbolInstance `writes` anomena un tipus d’objecte desconegut `{shown}`: feu servir type, image o symbolInstance +@msg `writes` lists `{shown}` twice `writes` inclou `{shown}` dues vegades +@msg `writes` lists `{shown}`, which `inputs` doesn't list `writes` inclou `{shown}`, que `inputs` no inclou +@msg `writes` needs `api` {WRITES_API} or later `writes` requereix `api` {WRITES_API} o posterior +@msg `writes` needs the permission `doc.write` `writes` requereix el permís `doc.write` +@msg {_1} is not type, an image or a symbol instance {_1} no és text, ni una imatge ni una instància de símbol +@msg the text of type given as `truncated` can't be changed no es pot canviar el text d’un text donat com a `truncated` +@msg must be a list of at most {MAX_INPUT_RUNS} entries ha de ser una llista d’un màxim de {MAX_INPUT_RUNS} entrades +@msg type needs at least one run el text necessita almenys un tram +@msg {bytes} bytes of text (limit {MAX_INPUT_TEXT}) {bytes} bytes de text (límit {MAX_INPUT_TEXT}) +@msg {paragraphs} paragraphs (limit {MAX_INPUT_RUNS}) {paragraphs} paràgrafs (límit {MAX_INPUT_RUNS}) +@msg more than {MAX_INPUT_TEXT_TOTAL} bytes of text over the output més de {MAX_INPUT_TEXT_TOTAL} bytes de text en tota la sortida +@msg unknown key '{k}' clau desconeguda '{k}' +@msg must be a list of 6 numbers ha de ser una llista de 6 nombres +@msg a number is out of range (limit ±{MAX_COORD}) un nombre és fora de l’interval (límit ±{MAX_COORD}) +@msg flattens the object to a line or a point redueix l’objecte a una línia o un punt +@msg an object flattened to a line or a point can't be placed again un objecte reduït a una línia o un punt no es pot tornar a col·locar +@msg must be a number from 0 to 1 ha de ser un nombre de 0 a 1 +@msg must be the name of a symbol ha de ser el nom d’un símbol +@msg '{shown}' is not a symbol in this document '{shown}' no és un símbol d’aquest document +@msg a run must be {{"text", "style", "inline"?}} un tram ha de ser {{"text", "style", "inline"?}} +@msg `text` holds the character of an inline graphic `text` conté el caràcter d’un gràfic en línia +@msg inline graphics can't be added, removed, reordered or changed els gràfics en línia no es poden afegir, eliminar, reordenar ni canviar +@msg the characters of threaded type can't be changed els caràcters del text enllaçat no es poden canviar +@msg the characters of type with ruby can't be changed els caràcters del text amb rubí no es poden canviar +@msg expected {count} paragraph styles, one per paragraph s’esperaven {count} estils de paràgraf, un per paràgraf +@msg the document has no Kinsoku set named '{shown}' el document no té cap conjunt Kinsoku anomenat '{shown}' +@msg must be 1-{MAX_FAMILY} printable characters ha de tenir 1-{MAX_FAMILY} caràcters imprimibles Read the objects it is given, and the document's settings, artboards, layers and swatches Llegir els objectes que rep, i la configuració, els taulers, les capes i les mostres del document @msg `context` must list distinct sections: settings, artboards, layers or swatches `context` ha de llistar seccions diferents: settings, artboards, layers o swatches @msg `context` is for a filter, or a live effect with `commands`, at `api` 3 or later with the permission `doc.read` `context` és per a un filtre, o un efecte dinàmic amb `commands`, amb `api` 3 o posterior i el permís `doc.read` diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index 13129a99a0..2433a0b12e 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -7542,6 +7542,35 @@ axis Y Axis osa Y @msg `inputs` lists `{shown}` twice `inputs` uvádí `{shown}` dvakrát @msg `inputs` needs `api` 2 or later `inputs` vyžaduje `api` 2 nebo vyšší @msg `inputs` needs the permission `doc.read` `inputs` vyžaduje oprávnění `doc.read` +@msg only a filter declares `writes` `writes` deklaruje pouze filtr +@msg `writes` names an unknown object kind `{shown}`: use type, image or symbolInstance `writes` uvádí neznámý druh objektu `{shown}`: použijte type, image nebo symbolInstance +@msg `writes` lists `{shown}` twice `writes` uvádí `{shown}` dvakrát +@msg `writes` lists `{shown}`, which `inputs` doesn't list `writes` uvádí `{shown}`, který `inputs` neuvádí +@msg `writes` needs `api` {WRITES_API} or later `writes` vyžaduje `api` {WRITES_API} nebo vyšší +@msg `writes` needs the permission `doc.write` `writes` vyžaduje oprávnění `doc.write` +@msg {_1} is not type, an image or a symbol instance {_1} není text, obraz ani instance symbolu +@msg the text of type given as `truncated` can't be changed text objektu předaného jako `truncated` nelze změnit +@msg must be a list of at most {MAX_INPUT_RUNS} entries musí být seznam nejvýše {MAX_INPUT_RUNS} položek +@msg type needs at least one run text potřebuje alespoň jeden úsek +@msg {bytes} bytes of text (limit {MAX_INPUT_TEXT}) {bytes} bajtů textu (limit {MAX_INPUT_TEXT}) +@msg {paragraphs} paragraphs (limit {MAX_INPUT_RUNS}) {paragraphs} odstavců (limit {MAX_INPUT_RUNS}) +@msg more than {MAX_INPUT_TEXT_TOTAL} bytes of text over the output více než {MAX_INPUT_TEXT_TOTAL} bajtů textu v celém výstupu +@msg unknown key '{k}' neznámý klíč '{k}' +@msg must be a list of 6 numbers musí být seznam 6 čísel +@msg a number is out of range (limit ±{MAX_COORD}) číslo je mimo rozsah (limit ±{MAX_COORD}) +@msg flattens the object to a line or a point zplošťuje objekt na čáru nebo bod +@msg an object flattened to a line or a point can't be placed again objekt zploštělý na čáru nebo bod nelze znovu umístit +@msg must be a number from 0 to 1 musí být číslo od 0 do 1 +@msg must be the name of a symbol musí být název symbolu +@msg '{shown}' is not a symbol in this document '{shown}' není symbol v tomto dokumentu +@msg a run must be {{"text", "style", "inline"?}} úsek musí být {{"text", "style", "inline"?}} +@msg `text` holds the character of an inline graphic `text` obsahuje znak vložené grafiky +@msg inline graphics can't be added, removed, reordered or changed vloženou grafiku nelze přidávat, odebírat, přeřazovat ani měnit +@msg the characters of threaded type can't be changed znaky zřetězeného textu nelze změnit +@msg the characters of type with ruby can't be changed znaky textu s ruby nelze změnit +@msg expected {count} paragraph styles, one per paragraph očekáváno {count} stylů odstavců, jeden na každý odstavec +@msg the document has no Kinsoku set named '{shown}' dokument nemá sadu Kinsoku s názvem '{shown}' +@msg must be 1-{MAX_FAMILY} printable characters musí mít 1-{MAX_FAMILY} tisknutelných znaků Read the objects it is given, and the document's settings, artboards, layers and swatches Číst objekty, které dostane, a nastavení, pracovní plochy, vrstvy a vzorky dokumentu @msg `context` must list distinct sections: settings, artboards, layers or swatches `context` musí uvádět různé oddíly: settings, artboards, layers nebo swatches @msg `context` is for a filter, or a live effect with `commands`, at `api` 3 or later with the permission `doc.read` `context` je pro filtr nebo živý efekt s `commands`, s `api` 3 nebo vyšším a s oprávněním `doc.read` diff --git a/crates/ui-egui/src/i18n/da.tsv b/crates/ui-egui/src/i18n/da.tsv index 94df1eb83e..4fbda43ec7 100644 --- a/crates/ui-egui/src/i18n/da.tsv +++ b/crates/ui-egui/src/i18n/da.tsv @@ -722,6 +722,35 @@ liquify-list-end {0}, {1} {0} og {1} @msg `inputs` lists `{shown}` twice `inputs` angiver `{shown}` to gange @msg `inputs` needs `api` 2 or later `inputs` kræver `api` 2 eller nyere @msg `inputs` needs the permission `doc.read` `inputs` kræver tilladelsen `doc.read` +@msg only a filter declares `writes` kun et filter angiver `writes` +@msg `writes` names an unknown object kind `{shown}`: use type, image or symbolInstance `writes` angiver en ukendt objekttype `{shown}`: brug type, image eller symbolInstance +@msg `writes` lists `{shown}` twice `writes` angiver `{shown}` to gange +@msg `writes` lists `{shown}`, which `inputs` doesn't list `writes` angiver `{shown}`, som `inputs` ikke angiver +@msg `writes` needs `api` {WRITES_API} or later `writes` kræver `api` {WRITES_API} eller nyere +@msg `writes` needs the permission `doc.write` `writes` kræver tilladelsen `doc.write` +@msg {_1} is not type, an image or a symbol instance {_1} er hverken tekst, et billede eller en symbolforekomst +@msg the text of type given as `truncated` can't be changed teksten i et tekstobjekt givet som `truncated` kan ikke ændres +@msg must be a list of at most {MAX_INPUT_RUNS} entries skal være en liste med højst {MAX_INPUT_RUNS} elementer +@msg type needs at least one run tekst skal have mindst ét tekststykke +@msg {bytes} bytes of text (limit {MAX_INPUT_TEXT}) {bytes} byte tekst (grænse {MAX_INPUT_TEXT}) +@msg {paragraphs} paragraphs (limit {MAX_INPUT_RUNS}) {paragraphs} afsnit (grænse {MAX_INPUT_RUNS}) +@msg more than {MAX_INPUT_TEXT_TOTAL} bytes of text over the output mere end {MAX_INPUT_TEXT_TOTAL} byte tekst i hele outputtet +@msg unknown key '{k}' ukendt nøgle '{k}' +@msg must be a list of 6 numbers skal være en liste med 6 tal +@msg a number is out of range (limit ±{MAX_COORD}) et tal er uden for området (grænse ±{MAX_COORD}) +@msg flattens the object to a line or a point gør objektet fladt til en linje eller et punkt +@msg an object flattened to a line or a point can't be placed again et objekt, der er gjort fladt til en linje eller et punkt, kan ikke placeres igen +@msg must be a number from 0 to 1 skal være et tal fra 0 til 1 +@msg must be the name of a symbol skal være navnet på et symbol +@msg '{shown}' is not a symbol in this document '{shown}' er ikke et symbol i dette dokument +@msg a run must be {{"text", "style", "inline"?}} et tekststykke skal være {{"text", "style", "inline"?}} +@msg `text` holds the character of an inline graphic `text` indeholder tegnet for en indlejret grafik +@msg inline graphics can't be added, removed, reordered or changed indlejrede grafikker kan ikke tilføjes, fjernes, omarrangeres eller ændres +@msg the characters of threaded type can't be changed tegnene i sammenkædet tekst kan ikke ændres +@msg the characters of type with ruby can't be changed tegnene i tekst med ruby kan ikke ændres +@msg expected {count} paragraph styles, one per paragraph forventede {count} afsnitsstile, én pr. afsnit +@msg the document has no Kinsoku set named '{shown}' dokumentet har intet Kinsoku-sæt med navnet '{shown}' +@msg must be 1-{MAX_FAMILY} printable characters skal være 1-{MAX_FAMILY} tegn, der kan udskrives Read the objects it is given, and the document's settings, artboards, layers and swatches Læse de objekter, den får, og dokumentets indstillinger, tegneflader, lag og farveprøver @msg `context` must list distinct sections: settings, artboards, layers or swatches `context` skal angive forskellige afsnit: settings, artboards, layers eller swatches @msg `context` is for a filter, or a live effect with `commands`, at `api` 3 or later with the permission `doc.read` `context` er til et filter eller en live-effekt med `commands`, ved `api` 3 eller senere og med tilladelsen `doc.read` diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index 0fb57437c4..7d788abf48 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -7125,6 +7125,35 @@ axis Y Axis Y-Achse @msg `inputs` lists `{shown}` twice `inputs` führt `{shown}` doppelt auf @msg `inputs` needs `api` 2 or later `inputs` erfordert `api` 2 oder höher @msg `inputs` needs the permission `doc.read` `inputs` erfordert die Berechtigung `doc.read` +@msg only a filter declares `writes` nur ein Filter deklariert `writes` +@msg `writes` names an unknown object kind `{shown}`: use type, image or symbolInstance `writes` nennt eine unbekannte Objektart `{shown}`: verwenden Sie type, image oder symbolInstance +@msg `writes` lists `{shown}` twice `writes` führt `{shown}` doppelt auf +@msg `writes` lists `{shown}`, which `inputs` doesn't list `writes` führt `{shown}` auf, das `inputs` nicht aufführt +@msg `writes` needs `api` {WRITES_API} or later `writes` erfordert `api` {WRITES_API} oder höher +@msg `writes` needs the permission `doc.write` `writes` erfordert die Berechtigung `doc.write` +@msg {_1} is not type, an image or a symbol instance {_1} ist weder Text noch ein Bild noch eine Symbolinstanz +@msg the text of type given as `truncated` can't be changed der Text eines als `truncated` übergebenen Textobjekts kann nicht geändert werden +@msg must be a list of at most {MAX_INPUT_RUNS} entries muss eine Liste mit höchstens {MAX_INPUT_RUNS} Einträgen sein +@msg type needs at least one run Text braucht mindestens einen Abschnitt +@msg {bytes} bytes of text (limit {MAX_INPUT_TEXT}) {bytes} Byte Text (Grenze {MAX_INPUT_TEXT}) +@msg {paragraphs} paragraphs (limit {MAX_INPUT_RUNS}) {paragraphs} Absätze (Grenze {MAX_INPUT_RUNS}) +@msg more than {MAX_INPUT_TEXT_TOTAL} bytes of text over the output mehr als {MAX_INPUT_TEXT_TOTAL} Byte Text in der gesamten Ausgabe +@msg unknown key '{k}' unbekannter Schlüssel '{k}' +@msg must be a list of 6 numbers muss eine Liste von 6 Zahlen sein +@msg a number is out of range (limit ±{MAX_COORD}) eine Zahl liegt außerhalb des Bereichs (Grenze ±{MAX_COORD}) +@msg flattens the object to a line or a point macht das Objekt zu einer Linie oder einem Punkt +@msg an object flattened to a line or a point can't be placed again ein zu einer Linie oder einem Punkt zusammengefallenes Objekt kann nicht neu platziert werden +@msg must be a number from 0 to 1 muss eine Zahl von 0 bis 1 sein +@msg must be the name of a symbol muss der Name eines Symbols sein +@msg '{shown}' is not a symbol in this document '{shown}' ist kein Symbol in diesem Dokument +@msg a run must be {{"text", "style", "inline"?}} ein Abschnitt muss {{"text", "style", "inline"?}} sein +@msg `text` holds the character of an inline graphic `text` enthält das Zeichen einer eingebundenen Grafik +@msg inline graphics can't be added, removed, reordered or changed eingebundene Grafiken können nicht hinzugefügt, entfernt, umgeordnet oder geändert werden +@msg the characters of threaded type can't be changed die Zeichen von verkettetem Text können nicht geändert werden +@msg the characters of type with ruby can't be changed die Zeichen von Text mit Ruby können nicht geändert werden +@msg expected {count} paragraph styles, one per paragraph {count} Absatzformate erwartet, eines pro Absatz +@msg the document has no Kinsoku set named '{shown}' das Dokument hat keinen Kinsoku-Satz namens '{shown}' +@msg must be 1-{MAX_FAMILY} printable characters muss 1-{MAX_FAMILY} druckbare Zeichen haben Read the objects it is given, and the document's settings, artboards, layers and swatches Die Objekte lesen, die es erhält, sowie die Einstellungen, Zeichenflächen, Ebenen und Farbfelder des Dokuments @msg `context` must list distinct sections: settings, artboards, layers or swatches `context` muss verschiedene Abschnitte aufführen: settings, artboards, layers oder swatches @msg `context` is for a filter, or a live effect with `commands`, at `api` 3 or later with the permission `doc.read` `context` gilt für einen Filter oder einen Live-Effekt mit `commands`, mit `api` 3 oder höher und der Berechtigung `doc.read` diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index 3bd10eceb1..2e7c180df4 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -7532,6 +7532,35 @@ axis Y Axis Άξονας Y @msg `inputs` lists `{shown}` twice το `inputs` αναφέρει το `{shown}` δύο φορές @msg `inputs` needs `api` 2 or later το `inputs` απαιτεί `api` 2 ή νεότερο @msg `inputs` needs the permission `doc.read` το `inputs` απαιτεί το δικαίωμα `doc.read` +@msg only a filter declares `writes` μόνο ένα φίλτρο δηλώνει `writes` +@msg `writes` names an unknown object kind `{shown}`: use type, image or symbolInstance το `writes` αναφέρει άγνωστο είδος αντικειμένου `{shown}`: χρησιμοποιήστε type, image ή symbolInstance +@msg `writes` lists `{shown}` twice το `writes` αναφέρει το `{shown}` δύο φορές +@msg `writes` lists `{shown}`, which `inputs` doesn't list το `writes` αναφέρει το `{shown}`, το οποίο δεν αναφέρει το `inputs` +@msg `writes` needs `api` {WRITES_API} or later το `writes` απαιτεί `api` {WRITES_API} ή νεότερο +@msg `writes` needs the permission `doc.write` το `writes` απαιτεί το δικαίωμα `doc.write` +@msg {_1} is not type, an image or a symbol instance το {_1} δεν είναι κείμενο, εικόνα ή στιγμιότυπο συμβόλου +@msg the text of type given as `truncated` can't be changed το κείμενο ενός αντικειμένου κειμένου που δόθηκε ως `truncated` δεν μπορεί να αλλάξει +@msg must be a list of at most {MAX_INPUT_RUNS} entries πρέπει να είναι λίστα με έως {MAX_INPUT_RUNS} στοιχεία +@msg type needs at least one run το κείμενο χρειάζεται τουλάχιστον ένα τμήμα +@msg {bytes} bytes of text (limit {MAX_INPUT_TEXT}) {bytes} byte κειμένου (όριο {MAX_INPUT_TEXT}) +@msg {paragraphs} paragraphs (limit {MAX_INPUT_RUNS}) {paragraphs} παράγραφοι (όριο {MAX_INPUT_RUNS}) +@msg more than {MAX_INPUT_TEXT_TOTAL} bytes of text over the output περισσότερα από {MAX_INPUT_TEXT_TOTAL} byte κειμένου σε όλη την έξοδο +@msg unknown key '{k}' άγνωστο κλειδί '{k}' +@msg must be a list of 6 numbers πρέπει να είναι λίστα 6 αριθμών +@msg a number is out of range (limit ±{MAX_COORD}) ένας αριθμός είναι εκτός εύρους (όριο ±{MAX_COORD}) +@msg flattens the object to a line or a point συμπιέζει το αντικείμενο σε γραμμή ή σημείο +@msg an object flattened to a line or a point can't be placed again ένα αντικείμενο που συμπιέστηκε σε γραμμή ή σημείο δεν μπορεί να τοποθετηθεί ξανά +@msg must be a number from 0 to 1 πρέπει να είναι αριθμός από 0 έως 1 +@msg must be the name of a symbol πρέπει να είναι το όνομα ενός συμβόλου +@msg '{shown}' is not a symbol in this document το '{shown}' δεν είναι σύμβολο σε αυτό το έγγραφο +@msg a run must be {{"text", "style", "inline"?}} ένα τμήμα πρέπει να είναι {{"text", "style", "inline"?}} +@msg `text` holds the character of an inline graphic το `text` περιέχει τον χαρακτήρα ενός ενσωματωμένου γραφικού +@msg inline graphics can't be added, removed, reordered or changed τα ενσωματωμένα γραφικά δεν μπορούν να προστεθούν, να αφαιρεθούν, να αναδιαταχθούν ή να αλλάξουν +@msg the characters of threaded type can't be changed οι χαρακτήρες συνδεδεμένου κειμένου δεν μπορούν να αλλάξουν +@msg the characters of type with ruby can't be changed οι χαρακτήρες κειμένου με ruby δεν μπορούν να αλλάξουν +@msg expected {count} paragraph styles, one per paragraph αναμένονταν {count} στυλ παραγράφων, ένα ανά παράγραφο +@msg the document has no Kinsoku set named '{shown}' το έγγραφο δεν έχει σύνολο Kinsoku με όνομα '{shown}' +@msg must be 1-{MAX_FAMILY} printable characters πρέπει να έχει 1-{MAX_FAMILY} εκτυπώσιμους χαρακτήρες Read the objects it is given, and the document's settings, artboards, layers and swatches Ανάγνωση των αντικειμένων που του δίνονται, καθώς και των ρυθμίσεων, των πινάκων σχεδίασης, των επιπέδων και των δειγμάτων χρωμάτων του εγγράφου @msg `context` must list distinct sections: settings, artboards, layers or swatches το `context` πρέπει να απαριθμεί διαφορετικές ενότητες: settings, artboards, layers ή swatches @msg `context` is for a filter, or a live effect with `commands`, at `api` 3 or later with the permission `doc.read` το `context` ισχύει για φίλτρο ή ζωντανό εφέ με `commands`, με `api` 3 ή νεότερο και το δικαίωμα `doc.read` diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index 7e71c1c191..37eea18b4c 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -7518,6 +7518,35 @@ axis Y Axis Eje Y @msg `inputs` lists `{shown}` twice `inputs` incluye `{shown}` dos veces @msg `inputs` needs `api` 2 or later `inputs` requiere `api` 2 o posterior @msg `inputs` needs the permission `doc.read` `inputs` requiere el permiso `doc.read` +@msg only a filter declares `writes` solo un filtro declara `writes` +@msg `writes` names an unknown object kind `{shown}`: use type, image or symbolInstance `writes` nombra un tipo de objeto desconocido `{shown}`: use type, image o symbolInstance +@msg `writes` lists `{shown}` twice `writes` incluye `{shown}` dos veces +@msg `writes` lists `{shown}`, which `inputs` doesn't list `writes` incluye `{shown}`, que `inputs` no incluye +@msg `writes` needs `api` {WRITES_API} or later `writes` requiere `api` {WRITES_API} o posterior +@msg `writes` needs the permission `doc.write` `writes` requiere el permiso `doc.write` +@msg {_1} is not type, an image or a symbol instance {_1} no es texto, ni una imagen ni una instancia de símbolo +@msg the text of type given as `truncated` can't be changed no se puede cambiar el texto de un objeto de texto dado como `truncated` +@msg must be a list of at most {MAX_INPUT_RUNS} entries debe ser una lista de {MAX_INPUT_RUNS} entradas como máximo +@msg type needs at least one run el texto necesita al menos un tramo +@msg {bytes} bytes of text (limit {MAX_INPUT_TEXT}) {bytes} bytes de texto (límite {MAX_INPUT_TEXT}) +@msg {paragraphs} paragraphs (limit {MAX_INPUT_RUNS}) {paragraphs} párrafos (límite {MAX_INPUT_RUNS}) +@msg more than {MAX_INPUT_TEXT_TOTAL} bytes of text over the output más de {MAX_INPUT_TEXT_TOTAL} bytes de texto en toda la salida +@msg unknown key '{k}' clave desconocida '{k}' +@msg must be a list of 6 numbers debe ser una lista de 6 números +@msg a number is out of range (limit ±{MAX_COORD}) un número está fuera de rango (límite ±{MAX_COORD}) +@msg flattens the object to a line or a point reduce el objeto a una línea o un punto +@msg an object flattened to a line or a point can't be placed again un objeto reducido a una línea o un punto no se puede volver a colocar +@msg must be a number from 0 to 1 debe ser un número de 0 a 1 +@msg must be the name of a symbol debe ser el nombre de un símbolo +@msg '{shown}' is not a symbol in this document '{shown}' no es un símbolo de este documento +@msg a run must be {{"text", "style", "inline"?}} un tramo debe ser {{"text", "style", "inline"?}} +@msg `text` holds the character of an inline graphic `text` contiene el carácter de un gráfico en línea +@msg inline graphics can't be added, removed, reordered or changed los gráficos en línea no se pueden añadir, quitar, reordenar ni cambiar +@msg the characters of threaded type can't be changed los caracteres del texto enlazado no se pueden cambiar +@msg the characters of type with ruby can't be changed los caracteres del texto con ruby no se pueden cambiar +@msg expected {count} paragraph styles, one per paragraph se esperaban {count} estilos de párrafo, uno por párrafo +@msg the document has no Kinsoku set named '{shown}' el documento no tiene ningún conjunto de kinsoku llamado '{shown}' +@msg must be 1-{MAX_FAMILY} printable characters debe tener 1-{MAX_FAMILY} caracteres imprimibles Read the objects it is given, and the document's settings, artboards, layers and swatches Leer los objetos que recibe, y los ajustes, las mesas de trabajo, las capas y las muestras del documento @msg `context` must list distinct sections: settings, artboards, layers or swatches `context` debe enumerar secciones distintas: settings, artboards, layers o swatches @msg `context` is for a filter, or a live effect with `commands`, at `api` 3 or later with the permission `doc.read` `context` es para un filtro, o un efecto dinámico con `commands`, con `api` 3 o posterior y el permiso `doc.read` diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index cc6e0d2fd2..c95d681244 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -7609,6 +7609,35 @@ axis Y Axis Y-akseli @msg `inputs` lists `{shown}` twice `inputs` luettelee kohteen `{shown}` kahdesti @msg `inputs` needs `api` 2 or later `inputs` edellyttää `api`-tasoa 2 tai uudempaa @msg `inputs` needs the permission `doc.read` `inputs` edellyttää käyttöoikeutta `doc.read` +@msg only a filter declares `writes` vain suodatin voi määrittää `writes`-avaimen +@msg `writes` names an unknown object kind `{shown}`: use type, image or symbolInstance `writes` nimeää tuntemattoman objektilajin `{shown}`: käytä arvoa type, image tai symbolInstance +@msg `writes` lists `{shown}` twice `writes` luettelee kohteen `{shown}` kahdesti +@msg `writes` lists `{shown}`, which `inputs` doesn't list `writes` luettelee kohteen `{shown}`, jota `inputs` ei luettele +@msg `writes` needs `api` {WRITES_API} or later `writes` edellyttää `api`-tasoa {WRITES_API} tai uudempaa +@msg `writes` needs the permission `doc.write` `writes` edellyttää käyttöoikeutta `doc.write` +@msg {_1} is not type, an image or a symbol instance {_1} ei ole teksti, kuva eikä symbolin ilmentymä +@msg the text of type given as `truncated` can't be changed `truncated`-merkinnällä annetun tekstiobjektin tekstiä ei voi muuttaa +@msg must be a list of at most {MAX_INPUT_RUNS} entries on oltava luettelo, jossa on enintään {MAX_INPUT_RUNS} kohdetta +@msg type needs at least one run tekstissä on oltava vähintään yksi tekstijakso +@msg {bytes} bytes of text (limit {MAX_INPUT_TEXT}) {bytes} tavua tekstiä (raja {MAX_INPUT_TEXT}) +@msg {paragraphs} paragraphs (limit {MAX_INPUT_RUNS}) {paragraphs} kappaletta (raja {MAX_INPUT_RUNS}) +@msg more than {MAX_INPUT_TEXT_TOTAL} bytes of text over the output yli {MAX_INPUT_TEXT_TOTAL} tavua tekstiä koko tulosteessa +@msg unknown key '{k}' tuntematon avain '{k}' +@msg must be a list of 6 numbers on oltava 6 luvun luettelo +@msg a number is out of range (limit ±{MAX_COORD}) luku on alueen ulkopuolella (raja ±{MAX_COORD}) +@msg flattens the object to a line or a point litistää objektin viivaksi tai pisteeksi +@msg an object flattened to a line or a point can't be placed again viivaksi tai pisteeksi litistynyttä objektia ei voi sijoittaa uudelleen +@msg must be a number from 0 to 1 on oltava luku väliltä 0-1 +@msg must be the name of a symbol on oltava symbolin nimi +@msg '{shown}' is not a symbol in this document '{shown}' ei ole symboli tässä dokumentissa +@msg a run must be {{"text", "style", "inline"?}} tekstijakson on oltava {{"text", "style", "inline"?}} +@msg `text` holds the character of an inline graphic `text` sisältää upotetun grafiikan merkin +@msg inline graphics can't be added, removed, reordered or changed upotettuja grafiikoita ei voi lisätä, poistaa, järjestää uudelleen eikä muuttaa +@msg the characters of threaded type can't be changed ketjutetun tekstin merkkejä ei voi muuttaa +@msg the characters of type with ruby can't be changed ruby-merkintöjä sisältävän tekstin merkkejä ei voi muuttaa +@msg expected {count} paragraph styles, one per paragraph odotettiin {count} kappaletyyliä, yksi kutakin kappaletta kohden +@msg the document has no Kinsoku set named '{shown}' dokumentissa ei ole Kinsoku-joukkoa nimeltä '{shown}' +@msg must be 1-{MAX_FAMILY} printable characters siinä on oltava 1-{MAX_FAMILY} tulostettavaa merkkiä Read the objects it is given, and the document's settings, artboards, layers and swatches Lukea sille annetut objektit sekä asiakirjan asetukset, piirtoalustat, tasot ja värimallit @msg `context` must list distinct sections: settings, artboards, layers or swatches `context`-avaimen on lueteltava eri osiot: settings, artboards, layers tai swatches @msg `context` is for a filter, or a live effect with `commands`, at `api` 3 or later with the permission `doc.read` `context` on suodattimelle tai reaaliaikaiselle tehosteelle, jolla on `commands`, tasolla `api` 3 tai uudempi ja käyttöoikeudella `doc.read` diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 6bcf110355..efab0b71ea 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -7539,6 +7539,35 @@ axis Y Axis Axe Y @msg `inputs` lists `{shown}` twice `inputs` mentionne `{shown}` deux fois @msg `inputs` needs `api` 2 or later `inputs` nécessite `api` 2 ou plus @msg `inputs` needs the permission `doc.read` `inputs` nécessite l’autorisation `doc.read` +@msg only a filter declares `writes` seul un filtre déclare `writes` +@msg `writes` names an unknown object kind `{shown}`: use type, image or symbolInstance `writes` désigne un type d’objet inconnu `{shown}` : utilisez type, image ou symbolInstance +@msg `writes` lists `{shown}` twice `writes` mentionne `{shown}` deux fois +@msg `writes` lists `{shown}`, which `inputs` doesn't list `writes` mentionne `{shown}`, que `inputs` ne mentionne pas +@msg `writes` needs `api` {WRITES_API} or later `writes` nécessite `api` {WRITES_API} ou plus +@msg `writes` needs the permission `doc.write` `writes` nécessite l’autorisation `doc.write` +@msg {_1} is not type, an image or a symbol instance {_1} n’est ni du texte, ni une image, ni une instance de symbole +@msg the text of type given as `truncated` can't be changed le texte d’un objet texte fourni comme `truncated` ne peut pas être modifié +@msg must be a list of at most {MAX_INPUT_RUNS} entries doit être une liste d’au plus {MAX_INPUT_RUNS} entrées +@msg type needs at least one run le texte doit compter au moins un segment +@msg {bytes} bytes of text (limit {MAX_INPUT_TEXT}) {bytes} octets de texte (limite {MAX_INPUT_TEXT}) +@msg {paragraphs} paragraphs (limit {MAX_INPUT_RUNS}) {paragraphs} paragraphes (limite {MAX_INPUT_RUNS}) +@msg more than {MAX_INPUT_TEXT_TOTAL} bytes of text over the output plus de {MAX_INPUT_TEXT_TOTAL} octets de texte sur l’ensemble de la sortie +@msg unknown key '{k}' clé inconnue '{k}' +@msg must be a list of 6 numbers doit être une liste de 6 nombres +@msg a number is out of range (limit ±{MAX_COORD}) un nombre est hors limites (limite ±{MAX_COORD}) +@msg flattens the object to a line or a point réduit l’objet à une ligne ou à un point +@msg an object flattened to a line or a point can't be placed again un objet réduit à une ligne ou à un point ne peut pas être replacé +@msg must be a number from 0 to 1 doit être un nombre de 0 à 1 +@msg must be the name of a symbol doit être le nom d’un symbole +@msg '{shown}' is not a symbol in this document '{shown}' n’est pas un symbole de ce document +@msg a run must be {{"text", "style", "inline"?}} un segment doit être {{"text", "style", "inline"?}} +@msg `text` holds the character of an inline graphic `text` contient le caractère d’un graphique incorporé +@msg inline graphics can't be added, removed, reordered or changed les graphiques incorporés ne peuvent pas être ajoutés, supprimés, réordonnés ni modifiés +@msg the characters of threaded type can't be changed les caractères d’un texte lié ne peuvent pas être modifiés +@msg the characters of type with ruby can't be changed les caractères d’un texte avec ruby ne peuvent pas être modifiés +@msg expected {count} paragraph styles, one per paragraph {count} styles de paragraphe attendus, un par paragraphe +@msg the document has no Kinsoku set named '{shown}' le document n’a aucun jeu de kinsoku nommé '{shown}' +@msg must be 1-{MAX_FAMILY} printable characters doit compter 1-{MAX_FAMILY} caractères imprimables Read the objects it is given, and the document's settings, artboards, layers and swatches Lire les objets qui lui sont transmis, ainsi que les paramètres, les plans de travail, les calques et les nuances du document @msg `context` must list distinct sections: settings, artboards, layers or swatches `context` doit lister des sections distinctes parmi settings, artboards, layers et swatches @msg `context` is for a filter, or a live effect with `commands`, at `api` 3 or later with the permission `doc.read` `context` est réservé à un filtre, ou à un effet dynamique avec `commands`, avec `api` 3 ou plus et l’autorisation `doc.read` diff --git a/crates/ui-egui/src/i18n/hi.tsv b/crates/ui-egui/src/i18n/hi.tsv index 986e007efc..082e4c8e03 100644 --- a/crates/ui-egui/src/i18n/hi.tsv +++ b/crates/ui-egui/src/i18n/hi.tsv @@ -6702,6 +6702,35 @@ arrowhead Feather पंख @msg `inputs` lists `{shown}` twice `inputs` में `{shown}` दो बार सूचीबद्ध है @msg `inputs` needs `api` 2 or later `inputs` के लिए `api` 2 या बाद का स्तर आवश्यक है @msg `inputs` needs the permission `doc.read` `inputs` के लिए अनुमति `doc.read` आवश्यक है +@msg only a filter declares `writes` केवल फ़िल्टर `writes` घोषित करता है +@msg `writes` names an unknown object kind `{shown}`: use type, image or symbolInstance `writes` में अज्ञात ऑब्जेक्ट प्रकार `{shown}` है: type, image या symbolInstance का उपयोग करें +@msg `writes` lists `{shown}` twice `writes` में `{shown}` दो बार सूचीबद्ध है +@msg `writes` lists `{shown}`, which `inputs` doesn't list `writes` में `{shown}` सूचीबद्ध है, जो `inputs` में सूचीबद्ध नहीं है +@msg `writes` needs `api` {WRITES_API} or later `writes` के लिए `api` {WRITES_API} या बाद का स्तर आवश्यक है +@msg `writes` needs the permission `doc.write` `writes` के लिए अनुमति `doc.write` आवश्यक है +@msg {_1} is not type, an image or a symbol instance {_1} न टेक्स्ट है, न इमेज, न सिंबल इंस्टेंस +@msg the text of type given as `truncated` can't be changed `truncated` के रूप में दिए गए टेक्स्ट ऑब्जेक्ट का टेक्स्ट बदला नहीं जा सकता +@msg must be a list of at most {MAX_INPUT_RUNS} entries अधिकतम {MAX_INPUT_RUNS} प्रविष्टियों की सूची होनी चाहिए +@msg type needs at least one run टेक्स्ट में कम से कम एक रन होना चाहिए +@msg {bytes} bytes of text (limit {MAX_INPUT_TEXT}) टेक्स्ट के {bytes} बाइट (सीमा {MAX_INPUT_TEXT}) +@msg {paragraphs} paragraphs (limit {MAX_INPUT_RUNS}) {paragraphs} अनुच्छेद (सीमा {MAX_INPUT_RUNS}) +@msg more than {MAX_INPUT_TEXT_TOTAL} bytes of text over the output पूरे आउटपुट में {MAX_INPUT_TEXT_TOTAL} बाइट से अधिक टेक्स्ट +@msg unknown key '{k}' अज्ञात कुंजी '{k}' +@msg must be a list of 6 numbers 6 संख्याओं की सूची होनी चाहिए +@msg a number is out of range (limit ±{MAX_COORD}) एक संख्या सीमा से बाहर है (सीमा ±{MAX_COORD}) +@msg flattens the object to a line or a point ऑब्जेक्ट को एक रेखा या बिंदु में चपटा कर देता है +@msg an object flattened to a line or a point can't be placed again रेखा या बिंदु में चपटे हुए ऑब्जेक्ट को फिर से रखा नहीं जा सकता +@msg must be a number from 0 to 1 0 से 1 तक की संख्या होनी चाहिए +@msg must be the name of a symbol किसी सिंबल का नाम होना चाहिए +@msg '{shown}' is not a symbol in this document '{shown}' इस दस्तावेज़ में कोई सिंबल नहीं है +@msg a run must be {{"text", "style", "inline"?}} रन {{"text", "style", "inline"?}} होना चाहिए +@msg `text` holds the character of an inline graphic `text` में इनलाइन ग्राफ़िक का वर्ण है +@msg inline graphics can't be added, removed, reordered or changed इनलाइन ग्राफ़िक जोड़े, हटाए, पुनः क्रमित या बदले नहीं जा सकते +@msg the characters of threaded type can't be changed थ्रेडेड टेक्स्ट के वर्ण बदले नहीं जा सकते +@msg the characters of type with ruby can't be changed रूबी वाले टेक्स्ट के वर्ण बदले नहीं जा सकते +@msg expected {count} paragraph styles, one per paragraph {count} पैराग्राफ़ स्टाइल अपेक्षित थे, हर पैराग्राफ़ के लिए एक +@msg the document has no Kinsoku set named '{shown}' दस्तावेज़ में '{shown}' नाम का कोई किनसोकू सेट नहीं है +@msg must be 1-{MAX_FAMILY} printable characters 1-{MAX_FAMILY} प्रिंट करने योग्य वर्ण होने चाहिए Read the objects it is given, and the document's settings, artboards, layers and swatches उसे दिए गए ऑब्जेक्ट्स, और डॉक्यूमेंट की सेटिंग्स, आर्टबोर्ड्स, लेयर्स और स्वॉचेस पढ़ना @msg `context` must list distinct sections: settings, artboards, layers or swatches `context` में अलग-अलग सेक्शन होने चाहिए: settings, artboards, layers या swatches @msg `context` is for a filter, or a live effect with `commands`, at `api` 3 or later with the permission `doc.read` `context` केवल फ़िल्टर, या `commands` वाले लाइव इफ़ेक्ट के लिए है, `api` 3 या उसके बाद और अनुमति `doc.read` के साथ diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index ec8a60deaf..669e5723c9 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -7527,6 +7527,35 @@ axis Y Axis Y tengely @msg `inputs` lists `{shown}` twice az `inputs` kétszer sorolja fel ezt: `{shown}` @msg `inputs` needs `api` 2 or later az `inputs` használatához `api` 2 vagy újabb szükséges @msg `inputs` needs the permission `doc.read` az `inputs` használatához a(z) `doc.read` engedély szükséges +@msg only a filter declares `writes` `writes` kulcsot csak szűrő adhat meg +@msg `writes` names an unknown object kind `{shown}`: use type, image or symbolInstance a `writes` ismeretlen objektumfajtát nevez meg: `{shown}`; használja a type, image vagy symbolInstance értéket +@msg `writes` lists `{shown}` twice a `writes` kétszer sorolja fel ezt: `{shown}` +@msg `writes` lists `{shown}`, which `inputs` doesn't list a `writes` felsorolja ezt: `{shown}`, de az `inputs` nem sorolja fel +@msg `writes` needs `api` {WRITES_API} or later a `writes` használatához `api` {WRITES_API} vagy újabb szükséges +@msg `writes` needs the permission `doc.write` a `writes` használatához a(z) `doc.write` engedély szükséges +@msg {_1} is not type, an image or a symbol instance {_1} nem szöveg, nem kép és nem szimbólumpéldány +@msg the text of type given as `truncated` can't be changed a `truncated` jelöléssel átadott szövegobjektum szövege nem módosítható +@msg must be a list of at most {MAX_INPUT_RUNS} entries legfeljebb {MAX_INPUT_RUNS} elemű lista legyen +@msg type needs at least one run a szövegnek legalább egy szakaszra van szüksége +@msg {bytes} bytes of text (limit {MAX_INPUT_TEXT}) {bytes} bájt szöveg (korlát: {MAX_INPUT_TEXT}) +@msg {paragraphs} paragraphs (limit {MAX_INPUT_RUNS}) {paragraphs} bekezdés (korlát: {MAX_INPUT_RUNS}) +@msg more than {MAX_INPUT_TEXT_TOTAL} bytes of text over the output több mint {MAX_INPUT_TEXT_TOTAL} bájt szöveg a teljes kimenetben +@msg unknown key '{k}' ismeretlen kulcs: '{k}' +@msg must be a list of 6 numbers 6 számból álló lista legyen +@msg a number is out of range (limit ±{MAX_COORD}) egy szám a tartományon kívül esik (korlát: ±{MAX_COORD}) +@msg flattens the object to a line or a point vonallá vagy ponttá lapítja az objektumot +@msg an object flattened to a line or a point can't be placed again a vonallá vagy ponttá lapított objektum nem helyezhető el újra +@msg must be a number from 0 to 1 0 és 1 közötti szám legyen +@msg must be the name of a symbol egy szimbólum neve legyen +@msg '{shown}' is not a symbol in this document '{shown}' nem szimbólum ebben a dokumentumban +@msg a run must be {{"text", "style", "inline"?}} egy szakasz formája {{"text", "style", "inline"?}} legyen +@msg `text` holds the character of an inline graphic a `text` egy szövegközi grafika karakterét tartalmazza +@msg inline graphics can't be added, removed, reordered or changed szövegközi grafikák nem adhatók hozzá, nem távolíthatók el, nem rendezhetők át és nem módosíthatók +@msg the characters of threaded type can't be changed a láncolt szöveg karakterei nem módosíthatók +@msg the characters of type with ruby can't be changed a rubyt tartalmazó szöveg karakterei nem módosíthatók +@msg expected {count} paragraph styles, one per paragraph {count} bekezdésstílus volt várható, bekezdésenként egy +@msg the document has no Kinsoku set named '{shown}' a dokumentumban nincs '{shown}' nevű Kinsoku-készlet +@msg must be 1-{MAX_FAMILY} printable characters 1-{MAX_FAMILY} nyomtatható karakter legyen Read the objects it is given, and the document's settings, artboards, layers and swatches Olvashatja a kapott objektumokat, valamint a dokumentum beállításait, rajztábláit, rétegeit és színmintáit @msg `context` must list distinct sections: settings, artboards, layers or swatches a `context` csak különböző szakaszokat sorolhat fel: settings, artboards, layers vagy swatches @msg `context` is for a filter, or a live effect with `commands`, at `api` 3 or later with the permission `doc.read` a `context` szűrőhöz vagy `commands` kulccsal rendelkező élő effektushoz való, `api` 3 vagy újabb mellett, a(z) `doc.read` engedéllyel diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index 3b3069e023..725ef12327 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -604,6 +604,35 @@ @msg `inputs` lists `{shown}` twice `inputs` mencantumkan `{shown}` dua kali @msg `inputs` needs `api` 2 or later `inputs` memerlukan `api` 2 atau lebih baru @msg `inputs` needs the permission `doc.read` `inputs` memerlukan izin `doc.read` +@msg only a filter declares `writes` hanya filter yang mendeklarasikan `writes` +@msg `writes` names an unknown object kind `{shown}`: use type, image or symbolInstance `writes` menyebut jenis objek yang tidak dikenal `{shown}`: gunakan type, image atau symbolInstance +@msg `writes` lists `{shown}` twice `writes` mencantumkan `{shown}` dua kali +@msg `writes` lists `{shown}`, which `inputs` doesn't list `writes` mencantumkan `{shown}`, yang tidak dicantumkan `inputs` +@msg `writes` needs `api` {WRITES_API} or later `writes` memerlukan `api` {WRITES_API} atau lebih baru +@msg `writes` needs the permission `doc.write` `writes` memerlukan izin `doc.write` +@msg {_1} is not type, an image or a symbol instance {_1} bukan teks, gambar, atau instans simbol +@msg the text of type given as `truncated` can't be changed teks dari objek teks yang diberikan sebagai `truncated` tidak dapat diubah +@msg must be a list of at most {MAX_INPUT_RUNS} entries harus berupa daftar berisi paling banyak {MAX_INPUT_RUNS} entri +@msg type needs at least one run teks memerlukan setidaknya satu potongan +@msg {bytes} bytes of text (limit {MAX_INPUT_TEXT}) {bytes} byte teks (batas {MAX_INPUT_TEXT}) +@msg {paragraphs} paragraphs (limit {MAX_INPUT_RUNS}) {paragraphs} paragraf (batas {MAX_INPUT_RUNS}) +@msg more than {MAX_INPUT_TEXT_TOTAL} bytes of text over the output lebih dari {MAX_INPUT_TEXT_TOTAL} byte teks di seluruh keluaran +@msg unknown key '{k}' kunci tidak dikenal '{k}' +@msg must be a list of 6 numbers harus berupa daftar 6 angka +@msg a number is out of range (limit ±{MAX_COORD}) sebuah angka di luar rentang (batas ±{MAX_COORD}) +@msg flattens the object to a line or a point memipihkan objek menjadi garis atau titik +@msg an object flattened to a line or a point can't be placed again objek yang dipipihkan menjadi garis atau titik tidak dapat ditempatkan lagi +@msg must be a number from 0 to 1 harus berupa angka dari 0 sampai 1 +@msg must be the name of a symbol harus berupa nama simbol +@msg '{shown}' is not a symbol in this document '{shown}' bukan simbol di dokumen ini +@msg a run must be {{"text", "style", "inline"?}} potongan harus berupa {{"text", "style", "inline"?}} +@msg `text` holds the character of an inline graphic `text` berisi karakter grafik sebaris +@msg inline graphics can't be added, removed, reordered or changed grafik sebaris tidak dapat ditambahkan, dihapus, diurutkan ulang, atau diubah +@msg the characters of threaded type can't be changed karakter teks beruntun tidak dapat diubah +@msg the characters of type with ruby can't be changed karakter teks dengan ruby tidak dapat diubah +@msg expected {count} paragraph styles, one per paragraph diharapkan {count} gaya paragraf, satu per paragraf +@msg the document has no Kinsoku set named '{shown}' dokumen tidak memiliki set Kinsoku bernama '{shown}' +@msg must be 1-{MAX_FAMILY} printable characters harus berupa 1-{MAX_FAMILY} karakter yang dapat dicetak Read the objects it is given, and the document's settings, artboards, layers and swatches Membaca objek yang diberikan kepadanya, serta pengaturan, artboard, lapisan, dan sampel warna dokumen @msg `context` must list distinct sections: settings, artboards, layers or swatches `context` harus mencantumkan bagian yang berbeda: settings, artboards, layers, atau swatches @msg `context` is for a filter, or a live effect with `commands`, at `api` 3 or later with the permission `doc.read` `context` untuk filter, atau efek langsung dengan `commands`, pada `api` 3 atau lebih baru dengan izin `doc.read` diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 8e7959999c..d00eb9be50 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -7164,6 +7164,35 @@ axis Y Axis Asse Y @msg `inputs` lists `{shown}` twice `inputs` elenca `{shown}` due volte @msg `inputs` needs `api` 2 or later `inputs` richiede `api` 2 o successivo @msg `inputs` needs the permission `doc.read` `inputs` richiede l’autorizzazione `doc.read` +@msg only a filter declares `writes` solo un filtro dichiara `writes` +@msg `writes` names an unknown object kind `{shown}`: use type, image or symbolInstance `writes` indica un tipo di oggetto sconosciuto `{shown}`: usa type, image o symbolInstance +@msg `writes` lists `{shown}` twice `writes` elenca `{shown}` due volte +@msg `writes` lists `{shown}`, which `inputs` doesn't list `writes` elenca `{shown}`, che `inputs` non elenca +@msg `writes` needs `api` {WRITES_API} or later `writes` richiede `api` {WRITES_API} o successivo +@msg `writes` needs the permission `doc.write` `writes` richiede l’autorizzazione `doc.write` +@msg {_1} is not type, an image or a symbol instance {_1} non è testo, né un’immagine né un’istanza di simbolo +@msg the text of type given as `truncated` can't be changed il testo di un oggetto di testo fornito come `truncated` non può essere modificato +@msg must be a list of at most {MAX_INPUT_RUNS} entries deve essere un elenco di al massimo {MAX_INPUT_RUNS} voci +@msg type needs at least one run il testo richiede almeno un segmento +@msg {bytes} bytes of text (limit {MAX_INPUT_TEXT}) {bytes} byte di testo (limite {MAX_INPUT_TEXT}) +@msg {paragraphs} paragraphs (limit {MAX_INPUT_RUNS}) {paragraphs} paragrafi (limite {MAX_INPUT_RUNS}) +@msg more than {MAX_INPUT_TEXT_TOTAL} bytes of text over the output più di {MAX_INPUT_TEXT_TOTAL} byte di testo nell’intero output +@msg unknown key '{k}' chiave sconosciuta '{k}' +@msg must be a list of 6 numbers deve essere un elenco di 6 numeri +@msg a number is out of range (limit ±{MAX_COORD}) un numero è fuori intervallo (limite ±{MAX_COORD}) +@msg flattens the object to a line or a point riduce l’oggetto a una linea o a un punto +@msg an object flattened to a line or a point can't be placed again un oggetto ridotto a una linea o a un punto non può essere ricollocato +@msg must be a number from 0 to 1 deve essere un numero da 0 a 1 +@msg must be the name of a symbol deve essere il nome di un simbolo +@msg '{shown}' is not a symbol in this document '{shown}' non è un simbolo di questo documento +@msg a run must be {{"text", "style", "inline"?}} un segmento deve essere {{"text", "style", "inline"?}} +@msg `text` holds the character of an inline graphic `text` contiene il carattere di una grafica in linea +@msg inline graphics can't be added, removed, reordered or changed le grafiche in linea non possono essere aggiunte, rimosse, riordinate o modificate +@msg the characters of threaded type can't be changed i caratteri del testo concatenato non possono essere modificati +@msg the characters of type with ruby can't be changed i caratteri del testo con ruby non possono essere modificati +@msg expected {count} paragraph styles, one per paragraph attesi {count} stili paragrafo, uno per paragrafo +@msg the document has no Kinsoku set named '{shown}' il documento non ha alcun set kinsoku denominato '{shown}' +@msg must be 1-{MAX_FAMILY} printable characters deve avere 1-{MAX_FAMILY} caratteri stampabili Read the objects it is given, and the document's settings, artboards, layers and swatches Leggere gli oggetti che riceve, e le impostazioni, le tavole da disegno, i livelli e i campioni del documento @msg `context` must list distinct sections: settings, artboards, layers or swatches `context` deve elencare sezioni distinte: settings, artboards, layers o swatches @msg `context` is for a filter, or a live effect with `commands`, at `api` 3 or later with the permission `doc.read` `context` vale per un filtro, o un effetto dinamico con `commands`, con `api` 3 o successiva e l’autorizzazione `doc.read` diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index d14fc0f723..8dba701981 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -7239,6 +7239,35 @@ axis Y Axis Y 軸 @msg `inputs` lists `{shown}` twice `inputs` に `{shown}` が 2 回指定されています @msg `inputs` needs `api` 2 or later `inputs` には `api` 2 以上が必要です @msg `inputs` needs the permission `doc.read` `inputs` には権限 `doc.read` が必要です +@msg only a filter declares `writes` `writes` を宣言できるのはフィルターだけです +@msg `writes` names an unknown object kind `{shown}`: use type, image or symbolInstance `writes` に不明なオブジェクトの種類 `{shown}` があります。type、image、symbolInstance のいずれかを使ってください +@msg `writes` lists `{shown}` twice `writes` に `{shown}` が 2 回指定されています +@msg `writes` lists `{shown}`, which `inputs` doesn't list `writes` に指定された `{shown}` は `inputs` に指定されていません +@msg `writes` needs `api` {WRITES_API} or later `writes` には `api` {WRITES_API} 以上が必要です +@msg `writes` needs the permission `doc.write` `writes` には権限 `doc.write` が必要です +@msg {_1} is not type, an image or a symbol instance {_1} はテキスト、画像、シンボルインスタンスのいずれでもありません +@msg the text of type given as `truncated` can't be changed `truncated` として渡されたテキストの文字列は変更できません +@msg must be a list of at most {MAX_INPUT_RUNS} entries {MAX_INPUT_RUNS} 項目以下のリストにしてください +@msg type needs at least one run テキストには 1 つ以上のランが必要です +@msg {bytes} bytes of text (limit {MAX_INPUT_TEXT}) テキストが {bytes} バイトあります (上限 {MAX_INPUT_TEXT}) +@msg {paragraphs} paragraphs (limit {MAX_INPUT_RUNS}) 段落が {paragraphs} 個あります (上限 {MAX_INPUT_RUNS}) +@msg more than {MAX_INPUT_TEXT_TOTAL} bytes of text over the output 出力全体のテキストが {MAX_INPUT_TEXT_TOTAL} バイトを超えています +@msg unknown key '{k}' 不明なキー '{k}' +@msg must be a list of 6 numbers 6 つの数値のリストにしてください +@msg a number is out of range (limit ±{MAX_COORD}) 数値が範囲外です (上限 ±{MAX_COORD}) +@msg flattens the object to a line or a point オブジェクトが線または点につぶれます +@msg an object flattened to a line or a point can't be placed again 線または点につぶれたオブジェクトは配置し直せません +@msg must be a number from 0 to 1 0 から 1 までの数値にしてください +@msg must be the name of a symbol シンボルの名前にしてください +@msg '{shown}' is not a symbol in this document '{shown}' はこのドキュメントのシンボルではありません +@msg a run must be {{"text", "style", "inline"?}} ランは {{"text", "style", "inline"?}} にしてください +@msg `text` holds the character of an inline graphic `text` にインライングラフィックの文字が含まれています +@msg inline graphics can't be added, removed, reordered or changed インライングラフィックは追加、削除、並べ替え、変更できません +@msg the characters of threaded type can't be changed スレッドテキストの文字は変更できません +@msg the characters of type with ruby can't be changed ルビのあるテキストの文字は変更できません +@msg expected {count} paragraph styles, one per paragraph 段落スタイルは段落ごとに 1 つ、計 {count} 個必要です +@msg the document has no Kinsoku set named '{shown}' ドキュメントに '{shown}' という名前の禁則処理セットはありません +@msg must be 1-{MAX_FAMILY} printable characters 印刷可能な 1-{MAX_FAMILY} 文字にしてください Read the objects it is given, and the document's settings, artboards, layers and swatches 渡されたオブジェクトと、ドキュメントの設定、アートボード、レイヤー、スウォッチの読み取り @msg `context` must list distinct sections: settings, artboards, layers or swatches `context` には重複しないセクションを指定してください: settings、artboards、layers、swatches @msg `context` is for a filter, or a live effect with `commands`, at `api` 3 or later with the permission `doc.read` `context` は、`api` 3 以降で権限 `doc.read` を持つフィルターまたは `commands` のあるライブ効果専用です diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index 1991d156eb..0a29222b28 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -9647,6 +9647,35 @@ axis Y Axis Y ღერძი @msg `inputs` lists `{shown}` twice `inputs`-ში `{shown}` ორჯერაა ჩამოთვლილი @msg `inputs` needs `api` 2 or later `inputs`-ს სჭირდება `api` 2 ან უფრო ახალი @msg `inputs` needs the permission `doc.read` `inputs`-ს სჭირდება ნებართვა `doc.read` +@msg only a filter declares `writes` `writes`-ის გამოცხადება მხოლოდ ფილტრს შეუძლია +@msg `writes` names an unknown object kind `{shown}`: use type, image or symbolInstance `writes` უცნობ ობიექტის სახეობას ასახელებს `{shown}`: გამოიყენეთ type, image ან symbolInstance +@msg `writes` lists `{shown}` twice `writes`-ში `{shown}` ორჯერაა ჩამოთვლილი +@msg `writes` lists `{shown}`, which `inputs` doesn't list `writes`-ში ჩამოთვლილია `{shown}`, რომელიც `inputs`-ში არ არის ჩამოთვლილი +@msg `writes` needs `api` {WRITES_API} or later `writes`-ს სჭირდება `api` {WRITES_API} ან უფრო ახალი +@msg `writes` needs the permission `doc.write` `writes`-ს სჭირდება ნებართვა `doc.write` +@msg {_1} is not type, an image or a symbol instance {_1} არც ტექსტია, არც გამოსახულება და არც სიმბოლოს ეგზემპლარი +@msg the text of type given as `truncated` can't be changed `truncated`-ად გადაცემული ტექსტური ობიექტის ტექსტის შეცვლა შეუძლებელია +@msg must be a list of at most {MAX_INPUT_RUNS} entries უნდა იყოს სია მაქსიმუმ {MAX_INPUT_RUNS} ჩანაწერით +@msg type needs at least one run ტექსტს სჭირდება მინიმუმ ერთი მონაკვეთი +@msg {bytes} bytes of text (limit {MAX_INPUT_TEXT}) ტექსტის {bytes} ბაიტი (ლიმიტი {MAX_INPUT_TEXT}) +@msg {paragraphs} paragraphs (limit {MAX_INPUT_RUNS}) {paragraphs} აბზაცი (ლიმიტი {MAX_INPUT_RUNS}) +@msg more than {MAX_INPUT_TEXT_TOTAL} bytes of text over the output მთელ გამონატანში {MAX_INPUT_TEXT_TOTAL} ბაიტზე მეტი ტექსტია +@msg unknown key '{k}' უცნობი გასაღები '{k}' +@msg must be a list of 6 numbers უნდა იყოს 6 რიცხვის სია +@msg a number is out of range (limit ±{MAX_COORD}) რიცხვი დიაპაზონს გარეთაა (ლიმიტი ±{MAX_COORD}) +@msg flattens the object to a line or a point ობიექტს ხაზად ან წერტილად აბრტყელებს +@msg an object flattened to a line or a point can't be placed again ხაზად ან წერტილად გაბრტყელებული ობიექტის ხელახლა განთავსება შეუძლებელია +@msg must be a number from 0 to 1 უნდა იყოს რიცხვი 0-დან 1-მდე +@msg must be the name of a symbol უნდა იყოს სიმბოლოს სახელი +@msg '{shown}' is not a symbol in this document '{shown}' ამ დოკუმენტში სიმბოლო არ არის +@msg a run must be {{"text", "style", "inline"?}} მონაკვეთი უნდა იყოს {{"text", "style", "inline"?}} +@msg `text` holds the character of an inline graphic `text` შეიცავს ტექსტში ჩასმული გრაფიკის სიმბოლოს +@msg inline graphics can't be added, removed, reordered or changed ტექსტში ჩასმული გრაფიკის დამატება, წაშლა, გადალაგება ან შეცვლა შეუძლებელია +@msg the characters of threaded type can't be changed დაკავშირებული ტექსტის სიმბოლოების შეცვლა შეუძლებელია +@msg the characters of type with ruby can't be changed რუბის მქონე ტექსტის სიმბოლოების შეცვლა შეუძლებელია +@msg expected {count} paragraph styles, one per paragraph მოსალოდნელი იყო აბზაცის {count} სტილი, თითო აბზაცზე ერთი +@msg the document has no Kinsoku set named '{shown}' დოკუმენტს არ აქვს Kinsoku-ის ნაკრები სახელით '{shown}' +@msg must be 1-{MAX_FAMILY} printable characters უნდა შედგებოდეს 1-{MAX_FAMILY} დასაბეჭდი სიმბოლოსგან Read the objects it is given, and the document's settings, artboards, layers and swatches მიღებული ობიექტების და დოკუმენტის პარამეტრების, სამუშაო დაფების, შრეებისა და ფერის ნიმუშების წაკითხვა @msg `context` must list distinct sections: settings, artboards, layers or swatches `context`-ში განსხვავებული სექციები უნდა იყოს: settings, artboards, layers ან swatches @msg `context` is for a filter, or a live effect with `commands`, at `api` 3 or later with the permission `doc.read` `context` განკუთვნილია ფილტრისთვის ან `commands`-ის მქონე ცოცხალი ეფექტისთვის, `api` 3-ზე ან უფრო ახალზე, ნებართვით `doc.read` diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index 005f8284ea..78dc8d7b97 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -7136,6 +7136,35 @@ axis Y Axis Y축 @msg `inputs` lists `{shown}` twice `inputs`에 `{shown}`이(가) 두 번 나열되어 있습니다 @msg `inputs` needs `api` 2 or later `inputs`에는 `api` 2 이상이 필요합니다 @msg `inputs` needs the permission `doc.read` `inputs`에는 `doc.read` 권한이 필요합니다 +@msg only a filter declares `writes` 필터만 `writes`를 선언할 수 있습니다 +@msg `writes` names an unknown object kind `{shown}`: use type, image or symbolInstance `writes`에 알 수 없는 개체 종류 `{shown}`이(가) 있습니다. type, image 또는 symbolInstance를 사용하세요 +@msg `writes` lists `{shown}` twice `writes`에 `{shown}`이(가) 두 번 나열되어 있습니다 +@msg `writes` lists `{shown}`, which `inputs` doesn't list `writes`에 나열된 `{shown}`이(가) `inputs`에는 없습니다 +@msg `writes` needs `api` {WRITES_API} or later `writes`에는 `api` {WRITES_API} 이상이 필요합니다 +@msg `writes` needs the permission `doc.write` `writes`에는 `doc.write` 권한이 필요합니다 +@msg {_1} is not type, an image or a symbol instance {_1}은(는) 문자, 이미지, 심볼 인스턴스가 아닙니다 +@msg the text of type given as `truncated` can't be changed `truncated`로 전달된 문자 개체의 텍스트는 변경할 수 없습니다 +@msg must be a list of at most {MAX_INPUT_RUNS} entries 항목이 최대 {MAX_INPUT_RUNS}개인 목록이어야 합니다 +@msg type needs at least one run 문자에는 런이 하나 이상 있어야 합니다 +@msg {bytes} bytes of text (limit {MAX_INPUT_TEXT}) 텍스트 {bytes}바이트(한도 {MAX_INPUT_TEXT}) +@msg {paragraphs} paragraphs (limit {MAX_INPUT_RUNS}) 단락 {paragraphs}개(한도 {MAX_INPUT_RUNS}) +@msg more than {MAX_INPUT_TEXT_TOTAL} bytes of text over the output 출력 전체의 텍스트가 {MAX_INPUT_TEXT_TOTAL}바이트를 넘습니다 +@msg unknown key '{k}' 알 수 없는 키 '{k}' +@msg must be a list of 6 numbers 숫자 6개의 목록이어야 합니다 +@msg a number is out of range (limit ±{MAX_COORD}) 숫자가 범위를 벗어났습니다(한도 ±{MAX_COORD}) +@msg flattens the object to a line or a point 개체를 선이나 점으로 납작하게 만듭니다 +@msg an object flattened to a line or a point can't be placed again 선이나 점으로 납작해진 개체는 다시 배치할 수 없습니다 +@msg must be a number from 0 to 1 0에서 1 사이의 숫자여야 합니다 +@msg must be the name of a symbol 심볼 이름이어야 합니다 +@msg '{shown}' is not a symbol in this document '{shown}'은(는) 이 문서의 심볼이 아닙니다 +@msg a run must be {{"text", "style", "inline"?}} 런은 {{"text", "style", "inline"?}} 형식이어야 합니다 +@msg `text` holds the character of an inline graphic `text`에 인라인 그래픽 문자가 들어 있습니다 +@msg inline graphics can't be added, removed, reordered or changed 인라인 그래픽은 추가, 제거, 순서 변경, 수정할 수 없습니다 +@msg the characters of threaded type can't be changed 연결된 문자의 글자는 변경할 수 없습니다 +@msg the characters of type with ruby can't be changed 루비가 있는 문자의 글자는 변경할 수 없습니다 +@msg expected {count} paragraph styles, one per paragraph 단락마다 하나씩 단락 스타일 {count}개가 필요합니다 +@msg the document has no Kinsoku set named '{shown}' 문서에 '{shown}'(이)라는 긴소쿠 세트가 없습니다 +@msg must be 1-{MAX_FAMILY} printable characters 인쇄 가능한 문자 1-{MAX_FAMILY}자여야 합니다 Read the objects it is given, and the document's settings, artboards, layers and swatches 전달받은 개체와 문서의 설정, 아트보드, 레이어, 견본 읽기 @msg `context` must list distinct sections: settings, artboards, layers or swatches `context`에는 서로 다른 섹션을 나열해야 합니다: settings, artboards, layers 또는 swatches @msg `context` is for a filter, or a live effect with `commands`, at `api` 3 or later with the permission `doc.read` `context`는 `api` 3 이상이고 `doc.read` 권한이 있는 필터 또는 `commands`가 있는 라이브 효과에만 쓸 수 있습니다 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index 731173eea6..bbe1681764 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -567,6 +567,35 @@ liquify-list-end {0}, {1} {0} en {1} @msg `inputs` lists `{shown}` twice `inputs` noemt `{shown}` twee keer @msg `inputs` needs `api` 2 or later `inputs` vereist `api` 2 of hoger @msg `inputs` needs the permission `doc.read` `inputs` vereist de machtiging `doc.read` +@msg only a filter declares `writes` alleen een filter declareert `writes` +@msg `writes` names an unknown object kind `{shown}`: use type, image or symbolInstance `writes` noemt een onbekende objectsoort `{shown}`: gebruik type, image of symbolInstance +@msg `writes` lists `{shown}` twice `writes` noemt `{shown}` twee keer +@msg `writes` lists `{shown}`, which `inputs` doesn't list `writes` noemt `{shown}`, dat `inputs` niet noemt +@msg `writes` needs `api` {WRITES_API} or later `writes` vereist `api` {WRITES_API} of hoger +@msg `writes` needs the permission `doc.write` `writes` vereist de machtiging `doc.write` +@msg {_1} is not type, an image or a symbol instance {_1} is geen tekst, afbeelding of symboolinstantie +@msg the text of type given as `truncated` can't be changed de tekst van een tekstobject dat als `truncated` is doorgegeven, kan niet worden gewijzigd +@msg must be a list of at most {MAX_INPUT_RUNS} entries moet een lijst van ten hoogste {MAX_INPUT_RUNS} items zijn +@msg type needs at least one run tekst heeft ten minste één tekstreeks nodig +@msg {bytes} bytes of text (limit {MAX_INPUT_TEXT}) {bytes} bytes tekst (limiet {MAX_INPUT_TEXT}) +@msg {paragraphs} paragraphs (limit {MAX_INPUT_RUNS}) {paragraphs} alinea's (limiet {MAX_INPUT_RUNS}) +@msg more than {MAX_INPUT_TEXT_TOTAL} bytes of text over the output meer dan {MAX_INPUT_TEXT_TOTAL} bytes tekst in de hele uitvoer +@msg unknown key '{k}' onbekende sleutel '{k}' +@msg must be a list of 6 numbers moet een lijst van 6 getallen zijn +@msg a number is out of range (limit ±{MAX_COORD}) een getal valt buiten het bereik (limiet ±{MAX_COORD}) +@msg flattens the object to a line or a point drukt het object plat tot een lijn of een punt +@msg an object flattened to a line or a point can't be placed again een object dat tot een lijn of een punt is platgedrukt, kan niet opnieuw worden geplaatst +@msg must be a number from 0 to 1 moet een getal van 0 tot 1 zijn +@msg must be the name of a symbol moet de naam van een symbool zijn +@msg '{shown}' is not a symbol in this document '{shown}' is geen symbool in dit document +@msg a run must be {{"text", "style", "inline"?}} een tekstreeks moet {{"text", "style", "inline"?}} zijn +@msg `text` holds the character of an inline graphic `text` bevat het teken van een inline afbeelding +@msg inline graphics can't be added, removed, reordered or changed inline afbeeldingen kunnen niet worden toegevoegd, verwijderd, anders geordend of gewijzigd +@msg the characters of threaded type can't be changed de tekens van gekoppelde tekst kunnen niet worden gewijzigd +@msg the characters of type with ruby can't be changed de tekens van tekst met ruby kunnen niet worden gewijzigd +@msg expected {count} paragraph styles, one per paragraph {count} alineastijlen verwacht, één per alinea +@msg the document has no Kinsoku set named '{shown}' het document heeft geen Kinsoku-set met de naam '{shown}' +@msg must be 1-{MAX_FAMILY} printable characters moet uit 1-{MAX_FAMILY} afdrukbare tekens bestaan Read the objects it is given, and the document's settings, artboards, layers and swatches De objecten lezen die het krijgt, en de instellingen, tekengebieden, lagen en stalen van het document @msg `context` must list distinct sections: settings, artboards, layers or swatches `context` moet verschillende secties noemen: settings, artboards, layers of swatches @msg `context` is for a filter, or a live effect with `commands`, at `api` 3 or later with the permission `doc.read` `context` is voor een filter, of een live-effect met `commands`, bij `api` 3 of later en met de machtiging `doc.read` diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 9152459071..be22f98247 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -7397,6 +7397,35 @@ axis Y Axis Oś Y @msg `inputs` lists `{shown}` twice `inputs` wymienia `{shown}` dwa razy @msg `inputs` needs `api` 2 or later `inputs` wymaga `api` 2 lub nowszego @msg `inputs` needs the permission `doc.read` `inputs` wymaga uprawnienia `doc.read` +@msg only a filter declares `writes` tylko filtr deklaruje `writes` +@msg `writes` names an unknown object kind `{shown}`: use type, image or symbolInstance `writes` wymienia nieznany rodzaj obiektu `{shown}`: użyj type, image lub symbolInstance +@msg `writes` lists `{shown}` twice `writes` wymienia `{shown}` dwa razy +@msg `writes` lists `{shown}`, which `inputs` doesn't list `writes` wymienia `{shown}`, którego nie wymienia `inputs` +@msg `writes` needs `api` {WRITES_API} or later `writes` wymaga `api` {WRITES_API} lub nowszego +@msg `writes` needs the permission `doc.write` `writes` wymaga uprawnienia `doc.write` +@msg {_1} is not type, an image or a symbol instance {_1} nie jest tekstem, obrazem ani wystąpieniem symbolu +@msg the text of type given as `truncated` can't be changed nie można zmienić tekstu obiektu tekstowego przekazanego jako `truncated` +@msg must be a list of at most {MAX_INPUT_RUNS} entries musi być listą co najwyżej {MAX_INPUT_RUNS} pozycji +@msg type needs at least one run tekst potrzebuje co najmniej jednego fragmentu +@msg {bytes} bytes of text (limit {MAX_INPUT_TEXT}) {bytes} bajtów tekstu (limit {MAX_INPUT_TEXT}) +@msg {paragraphs} paragraphs (limit {MAX_INPUT_RUNS}) {paragraphs} akapitów (limit {MAX_INPUT_RUNS}) +@msg more than {MAX_INPUT_TEXT_TOTAL} bytes of text over the output ponad {MAX_INPUT_TEXT_TOTAL} bajtów tekstu w całym wyniku +@msg unknown key '{k}' nieznany klucz '{k}' +@msg must be a list of 6 numbers musi być listą 6 liczb +@msg a number is out of range (limit ±{MAX_COORD}) liczba spoza zakresu (limit ±{MAX_COORD}) +@msg flattens the object to a line or a point spłaszcza obiekt do linii lub punktu +@msg an object flattened to a line or a point can't be placed again obiektu spłaszczonego do linii lub punktu nie można ponownie umieścić +@msg must be a number from 0 to 1 musi być liczbą od 0 do 1 +@msg must be the name of a symbol musi być nazwą symbolu +@msg '{shown}' is not a symbol in this document '{shown}' nie jest symbolem w tym dokumencie +@msg a run must be {{"text", "style", "inline"?}} fragment musi mieć postać {{"text", "style", "inline"?}} +@msg `text` holds the character of an inline graphic `text` zawiera znak grafiki w wierszu +@msg inline graphics can't be added, removed, reordered or changed grafik w wierszu nie można dodawać, usuwać, zmieniać ich kolejności ani modyfikować +@msg the characters of threaded type can't be changed nie można zmienić znaków tekstu wątkowego +@msg the characters of type with ruby can't be changed nie można zmienić znaków tekstu z ruby +@msg expected {count} paragraph styles, one per paragraph oczekiwano {count} stylów akapitowych, po jednym na akapit +@msg the document has no Kinsoku set named '{shown}' dokument nie ma zestawu kinsoku o nazwie '{shown}' +@msg must be 1-{MAX_FAMILY} printable characters musi mieć 1-{MAX_FAMILY} drukowalnych znaków Read the objects it is given, and the document's settings, artboards, layers and swatches Odczytywać obiekty, które otrzymuje, oraz ustawienia, obszary kompozycji, warstwy i próbki dokumentu @msg `context` must list distinct sections: settings, artboards, layers or swatches `context` musi wymieniać różne sekcje: settings, artboards, layers lub swatches @msg `context` is for a filter, or a live effect with `commands`, at `api` 3 or later with the permission `doc.read` `context` dotyczy filtra albo efektu na żywo z `commands`, z `api` 3 lub nowszym i z uprawnieniem `doc.read` diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index b49b217c8f..a2be19bf7e 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -7441,6 +7441,35 @@ axis Y Axis Eixo Y @msg `inputs` lists `{shown}` twice `inputs` lista `{shown}` duas vezes @msg `inputs` needs `api` 2 or later `inputs` exige `api` 2 ou posterior @msg `inputs` needs the permission `doc.read` `inputs` exige a permissão `doc.read` +@msg only a filter declares `writes` somente um filtro declara `writes` +@msg `writes` names an unknown object kind `{shown}`: use type, image or symbolInstance `writes` cita um tipo de objeto desconhecido `{shown}`: use type, image ou symbolInstance +@msg `writes` lists `{shown}` twice `writes` lista `{shown}` duas vezes +@msg `writes` lists `{shown}`, which `inputs` doesn't list `writes` lista `{shown}`, que `inputs` não lista +@msg `writes` needs `api` {WRITES_API} or later `writes` exige `api` {WRITES_API} ou posterior +@msg `writes` needs the permission `doc.write` `writes` exige a permissão `doc.write` +@msg {_1} is not type, an image or a symbol instance {_1} não é texto, nem uma imagem, nem uma instância de símbolo +@msg the text of type given as `truncated` can't be changed o texto de um objeto de texto fornecido como `truncated` não pode ser alterado +@msg must be a list of at most {MAX_INPUT_RUNS} entries deve ser uma lista de no máximo {MAX_INPUT_RUNS} entradas +@msg type needs at least one run o texto precisa de pelo menos um trecho +@msg {bytes} bytes of text (limit {MAX_INPUT_TEXT}) {bytes} bytes de texto (limite {MAX_INPUT_TEXT}) +@msg {paragraphs} paragraphs (limit {MAX_INPUT_RUNS}) {paragraphs} parágrafos (limite {MAX_INPUT_RUNS}) +@msg more than {MAX_INPUT_TEXT_TOTAL} bytes of text over the output mais de {MAX_INPUT_TEXT_TOTAL} bytes de texto em toda a saída +@msg unknown key '{k}' chave desconhecida '{k}' +@msg must be a list of 6 numbers deve ser uma lista de 6 números +@msg a number is out of range (limit ±{MAX_COORD}) um número está fora do intervalo (limite ±{MAX_COORD}) +@msg flattens the object to a line or a point achata o objeto em uma linha ou um ponto +@msg an object flattened to a line or a point can't be placed again um objeto achatado em uma linha ou um ponto não pode ser posicionado de novo +@msg must be a number from 0 to 1 deve ser um número de 0 a 1 +@msg must be the name of a symbol deve ser o nome de um símbolo +@msg '{shown}' is not a symbol in this document '{shown}' não é um símbolo deste documento +@msg a run must be {{"text", "style", "inline"?}} um trecho deve ser {{"text", "style", "inline"?}} +@msg `text` holds the character of an inline graphic `text` contém o caractere de um gráfico em linha +@msg inline graphics can't be added, removed, reordered or changed gráficos em linha não podem ser adicionados, removidos, reordenados nem alterados +@msg the characters of threaded type can't be changed os caracteres de texto encadeado não podem ser alterados +@msg the characters of type with ruby can't be changed os caracteres de texto com ruby não podem ser alterados +@msg expected {count} paragraph styles, one per paragraph eram esperados {count} estilos de parágrafo, um por parágrafo +@msg the document has no Kinsoku set named '{shown}' o documento não tem um conjunto Kinsoku chamado '{shown}' +@msg must be 1-{MAX_FAMILY} printable characters deve ter 1-{MAX_FAMILY} caracteres imprimíveis Read the objects it is given, and the document's settings, artboards, layers and swatches Ler os objetos que recebe, e as configurações, as mesas de trabalho, as camadas e as amostras do documento @msg `context` must list distinct sections: settings, artboards, layers or swatches `context` deve listar seções distintas: settings, artboards, layers ou swatches @msg `context` is for a filter, or a live effect with `commands`, at `api` 3 or later with the permission `doc.read` `context` é para um filtro, ou um efeito dinâmico com `commands`, com `api` 3 ou posterior e a permissão `doc.read` diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index eec9216b69..e722b4e782 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -7164,6 +7164,35 @@ axis Y Axis Ось Y @msg `inputs` lists `{shown}` twice в `inputs` `{shown}` указано дважды @msg `inputs` needs `api` 2 or later для `inputs` нужен `api` 2 или выше @msg `inputs` needs the permission `doc.read` для `inputs` нужно разрешение `doc.read` +@msg only a filter declares `writes` `writes` может объявлять только фильтр +@msg `writes` names an unknown object kind `{shown}`: use type, image or symbolInstance в `writes` указан неизвестный вид объекта `{shown}`: используйте type, image или symbolInstance +@msg `writes` lists `{shown}` twice в `writes` `{shown}` указано дважды +@msg `writes` lists `{shown}`, which `inputs` doesn't list в `writes` указано `{shown}`, которого нет в `inputs` +@msg `writes` needs `api` {WRITES_API} or later для `writes` нужен `api` {WRITES_API} или выше +@msg `writes` needs the permission `doc.write` для `writes` нужно разрешение `doc.write` +@msg {_1} is not type, an image or a symbol instance {_1} не является ни текстом, ни изображением, ни экземпляром символа +@msg the text of type given as `truncated` can't be changed текст текстового объекта, переданного как `truncated`, изменить нельзя +@msg must be a list of at most {MAX_INPUT_RUNS} entries должно быть списком не более чем из {MAX_INPUT_RUNS} элементов +@msg type needs at least one run у текста должен быть хотя бы один фрагмент +@msg {bytes} bytes of text (limit {MAX_INPUT_TEXT}) {bytes} байт текста (предел {MAX_INPUT_TEXT}) +@msg {paragraphs} paragraphs (limit {MAX_INPUT_RUNS}) {paragraphs} абзацев (предел {MAX_INPUT_RUNS}) +@msg more than {MAX_INPUT_TEXT_TOTAL} bytes of text over the output более {MAX_INPUT_TEXT_TOTAL} байт текста во всём выводе +@msg unknown key '{k}' неизвестный ключ '{k}' +@msg must be a list of 6 numbers должно быть списком из 6 чисел +@msg a number is out of range (limit ±{MAX_COORD}) число вне диапазона (предел ±{MAX_COORD}) +@msg flattens the object to a line or a point сплющивает объект в линию или точку +@msg an object flattened to a line or a point can't be placed again объект, сплющенный в линию или точку, нельзя разместить заново +@msg must be a number from 0 to 1 должно быть числом от 0 до 1 +@msg must be the name of a symbol должно быть именем символа +@msg '{shown}' is not a symbol in this document '{shown}' не является символом этого документа +@msg a run must be {{"text", "style", "inline"?}} фрагмент должен иметь вид {{"text", "style", "inline"?}} +@msg `text` holds the character of an inline graphic `text` содержит символ встроенной в строку графики +@msg inline graphics can't be added, removed, reordered or changed встроенную в строку графику нельзя добавлять, удалять, переупорядочивать или изменять +@msg the characters of threaded type can't be changed знаки связанного текста изменить нельзя +@msg the characters of type with ruby can't be changed знаки текста с руби изменить нельзя +@msg expected {count} paragraph styles, one per paragraph ожидалось стилей абзацев: {count}, по одному на абзац +@msg the document has no Kinsoku set named '{shown}' в документе нет набора kinsoku с именем '{shown}' +@msg must be 1-{MAX_FAMILY} printable characters должно содержать 1-{MAX_FAMILY} печатаемых символов Read the objects it is given, and the document's settings, artboards, layers and swatches Читать переданные ему объекты, а также параметры, монтажные области, слои и образцы документа @msg `context` must list distinct sections: settings, artboards, layers or swatches `context` должен перечислять разные разделы: settings, artboards, layers или swatches @msg `context` is for a filter, or a live effect with `commands`, at `api` 3 or later with the permission `doc.read` `context` допустим только для фильтра или динамического эффекта с `commands`, с `api` 3 или выше и с разрешением `doc.read` diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index a4184199a4..2c9b16b092 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -7542,6 +7542,35 @@ axis Y Axis Y-axel @msg `inputs` lists `{shown}` twice `inputs` anger `{shown}` två gånger @msg `inputs` needs `api` 2 or later `inputs` kräver `api` 2 eller senare @msg `inputs` needs the permission `doc.read` `inputs` kräver behörigheten `doc.read` +@msg only a filter declares `writes` bara ett filter anger `writes` +@msg `writes` names an unknown object kind `{shown}`: use type, image or symbolInstance `writes` anger en okänd objekttyp `{shown}`: använd type, image eller symbolInstance +@msg `writes` lists `{shown}` twice `writes` anger `{shown}` två gånger +@msg `writes` lists `{shown}`, which `inputs` doesn't list `writes` anger `{shown}`, som `inputs` inte anger +@msg `writes` needs `api` {WRITES_API} or later `writes` kräver `api` {WRITES_API} eller senare +@msg `writes` needs the permission `doc.write` `writes` kräver behörigheten `doc.write` +@msg {_1} is not type, an image or a symbol instance {_1} är varken text, en bild eller en symbolinstans +@msg the text of type given as `truncated` can't be changed texten i ett textobjekt som getts som `truncated` kan inte ändras +@msg must be a list of at most {MAX_INPUT_RUNS} entries måste vara en lista med högst {MAX_INPUT_RUNS} poster +@msg type needs at least one run text behöver minst ett textavsnitt +@msg {bytes} bytes of text (limit {MAX_INPUT_TEXT}) {bytes} byte text (gräns {MAX_INPUT_TEXT}) +@msg {paragraphs} paragraphs (limit {MAX_INPUT_RUNS}) {paragraphs} stycken (gräns {MAX_INPUT_RUNS}) +@msg more than {MAX_INPUT_TEXT_TOTAL} bytes of text over the output mer än {MAX_INPUT_TEXT_TOTAL} byte text i hela utdatan +@msg unknown key '{k}' okänd nyckel '{k}' +@msg must be a list of 6 numbers måste vara en lista med 6 tal +@msg a number is out of range (limit ±{MAX_COORD}) ett tal ligger utanför intervallet (gräns ±{MAX_COORD}) +@msg flattens the object to a line or a point plattar till objektet till en linje eller en punkt +@msg an object flattened to a line or a point can't be placed again ett objekt som plattats till en linje eller en punkt kan inte placeras igen +@msg must be a number from 0 to 1 måste vara ett tal från 0 till 1 +@msg must be the name of a symbol måste vara namnet på en symbol +@msg '{shown}' is not a symbol in this document '{shown}' är ingen symbol i det här dokumentet +@msg a run must be {{"text", "style", "inline"?}} ett textavsnitt måste vara {{"text", "style", "inline"?}} +@msg `text` holds the character of an inline graphic `text` innehåller tecknet för en grafik i texten +@msg inline graphics can't be added, removed, reordered or changed grafik i texten kan inte läggas till, tas bort, ordnas om eller ändras +@msg the characters of threaded type can't be changed tecknen i länkad text kan inte ändras +@msg the characters of type with ruby can't be changed tecknen i text med ruby kan inte ändras +@msg expected {count} paragraph styles, one per paragraph {count} styckestilar förväntades, en per stycke +@msg the document has no Kinsoku set named '{shown}' dokumentet har ingen Kinsoku-uppsättning med namnet '{shown}' +@msg must be 1-{MAX_FAMILY} printable characters måste vara 1-{MAX_FAMILY} utskrivbara tecken Read the objects it is given, and the document's settings, artboards, layers and swatches Läsa objekten den får, och dokumentets inställningar, ritytor, lager och färgrutor @msg `context` must list distinct sections: settings, artboards, layers or swatches `context` måste ange olika avsnitt: settings, artboards, layers eller swatches @msg `context` is for a filter, or a live effect with `commands`, at `api` 3 or later with the permission `doc.read` `context` gäller ett filter eller en liveeffekt med `commands`, med `api` 3 eller senare och behörigheten `doc.read` diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index 6f1d616aca..81accf43c5 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -7614,6 +7614,35 @@ axis Y Axis Y ekseni @msg `inputs` lists `{shown}` twice `inputs` `{shown}` değerini iki kez listeliyor @msg `inputs` needs `api` 2 or later `inputs` için `api` 2 veya üstü gerekir @msg `inputs` needs the permission `doc.read` `inputs` için `doc.read` izni gerekir +@msg only a filter declares `writes` `writes` yalnızca bir filtrede bildirilebilir +@msg `writes` names an unknown object kind `{shown}`: use type, image or symbolInstance `writes` bilinmeyen bir nesne türü belirtiyor: `{shown}`; type, image veya symbolInstance kullanın +@msg `writes` lists `{shown}` twice `writes` `{shown}` değerini iki kez listeliyor +@msg `writes` lists `{shown}`, which `inputs` doesn't list `writes` `{shown}` değerini listeliyor, ancak `inputs` listelemiyor +@msg `writes` needs `api` {WRITES_API} or later `writes` için `api` {WRITES_API} veya üstü gerekir +@msg `writes` needs the permission `doc.write` `writes` için `doc.write` izni gerekir +@msg {_1} is not type, an image or a symbol instance {_1} metin, görüntü veya sembol örneği değil +@msg the text of type given as `truncated` can't be changed `truncated` olarak verilen metin nesnesinin metni değiştirilemez +@msg must be a list of at most {MAX_INPUT_RUNS} entries en fazla {MAX_INPUT_RUNS} girişli bir liste olmalıdır +@msg type needs at least one run metnin en az bir parçası olmalıdır +@msg {bytes} bytes of text (limit {MAX_INPUT_TEXT}) {bytes} bayt metin (sınır {MAX_INPUT_TEXT}) +@msg {paragraphs} paragraphs (limit {MAX_INPUT_RUNS}) {paragraphs} paragraf (sınır {MAX_INPUT_RUNS}) +@msg more than {MAX_INPUT_TEXT_TOTAL} bytes of text over the output çıktının tamamında {MAX_INPUT_TEXT_TOTAL} bayttan fazla metin +@msg unknown key '{k}' bilinmeyen anahtar '{k}' +@msg must be a list of 6 numbers 6 sayılık bir liste olmalıdır +@msg a number is out of range (limit ±{MAX_COORD}) bir sayı aralık dışında (sınır ±{MAX_COORD}) +@msg flattens the object to a line or a point nesneyi bir çizgiye veya noktaya yassılaştırıyor +@msg an object flattened to a line or a point can't be placed again bir çizgiye veya noktaya yassılaşmış nesne yeniden yerleştirilemez +@msg must be a number from 0 to 1 0 ile 1 arasında bir sayı olmalıdır +@msg must be the name of a symbol bir sembolün adı olmalıdır +@msg '{shown}' is not a symbol in this document '{shown}' bu belgede bir sembol değil +@msg a run must be {{"text", "style", "inline"?}} bir parça {{"text", "style", "inline"?}} biçiminde olmalıdır +@msg `text` holds the character of an inline graphic `text` satır içi bir grafiğin karakterini içeriyor +@msg inline graphics can't be added, removed, reordered or changed satır içi grafikler eklenemez, kaldırılamaz, yeniden sıralanamaz veya değiştirilemez +@msg the characters of threaded type can't be changed zincirli metnin karakterleri değiştirilemez +@msg the characters of type with ruby can't be changed ruby içeren metnin karakterleri değiştirilemez +@msg expected {count} paragraph styles, one per paragraph her paragraf için bir tane olmak üzere {count} paragraf stili bekleniyordu +@msg the document has no Kinsoku set named '{shown}' belgede '{shown}' adlı Kinsoku seti yok +@msg must be 1-{MAX_FAMILY} printable characters 1-{MAX_FAMILY} yazdırılabilir karakter olmalıdır Read the objects it is given, and the document's settings, artboards, layers and swatches Kendisine verilen nesneleri ve belgenin ayarlarını, çalışma yüzeylerini, katmanlarını ve renk örneklerini okuma @msg `context` must list distinct sections: settings, artboards, layers or swatches `context` farklı bölümleri listelemelidir: settings, artboards, layers veya swatches @msg `context` is for a filter, or a live effect with `commands`, at `api` 3 or later with the permission `doc.read` `context` yalnızca `api` 3 veya sonrasında, `doc.read` izniyle bir filtre ya da `commands` içeren bir canlı efekt içindir diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index 89c20c44a5..e1700dbb94 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -7146,6 +7146,35 @@ axis Y Axis Вісь Y @msg `inputs` lists `{shown}` twice в `inputs` `{shown}` указано двічі @msg `inputs` needs `api` 2 or later для `inputs` потрібен `api` 2 або новіший @msg `inputs` needs the permission `doc.read` для `inputs` потрібен дозвіл `doc.read` +@msg only a filter declares `writes` `writes` може оголошувати лише фільтр +@msg `writes` names an unknown object kind `{shown}`: use type, image or symbolInstance в `writes` указано невідомий вид об’єкта `{shown}`: використовуйте type, image або symbolInstance +@msg `writes` lists `{shown}` twice в `writes` `{shown}` указано двічі +@msg `writes` lists `{shown}`, which `inputs` doesn't list в `writes` указано `{shown}`, якого немає в `inputs` +@msg `writes` needs `api` {WRITES_API} or later для `writes` потрібен `api` {WRITES_API} або новіший +@msg `writes` needs the permission `doc.write` для `writes` потрібен дозвіл `doc.write` +@msg {_1} is not type, an image or a symbol instance {_1} не є ні текстом, ні зображенням, ні екземпляром символу +@msg the text of type given as `truncated` can't be changed текст текстового об’єкта, переданого як `truncated`, змінити не можна +@msg must be a list of at most {MAX_INPUT_RUNS} entries має бути списком щонайбільше з {MAX_INPUT_RUNS} елементів +@msg type needs at least one run текст повинен мати щонайменше один фрагмент +@msg {bytes} bytes of text (limit {MAX_INPUT_TEXT}) {bytes} байтів тексту (межа {MAX_INPUT_TEXT}) +@msg {paragraphs} paragraphs (limit {MAX_INPUT_RUNS}) {paragraphs} абзаців (межа {MAX_INPUT_RUNS}) +@msg more than {MAX_INPUT_TEXT_TOTAL} bytes of text over the output понад {MAX_INPUT_TEXT_TOTAL} байтів тексту в усьому виводі +@msg unknown key '{k}' невідомий ключ '{k}' +@msg must be a list of 6 numbers має бути списком із 6 чисел +@msg a number is out of range (limit ±{MAX_COORD}) число поза діапазоном (межа ±{MAX_COORD}) +@msg flattens the object to a line or a point сплющує об’єкт у лінію чи точку +@msg an object flattened to a line or a point can't be placed again об’єкт, сплющений у лінію чи точку, не можна розмістити знову +@msg must be a number from 0 to 1 має бути числом від 0 до 1 +@msg must be the name of a symbol має бути назвою символу +@msg '{shown}' is not a symbol in this document '{shown}' не є символом цього документа +@msg a run must be {{"text", "style", "inline"?}} фрагмент має мати вигляд {{"text", "style", "inline"?}} +@msg `text` holds the character of an inline graphic `text` містить знак вбудованої в рядок графіки +@msg inline graphics can't be added, removed, reordered or changed вбудовану в рядок графіку не можна додавати, вилучати, переставляти чи змінювати +@msg the characters of threaded type can't be changed знаки пов’язаного тексту змінити не можна +@msg the characters of type with ruby can't be changed знаки тексту з рубі змінити не можна +@msg expected {count} paragraph styles, one per paragraph очікувалося стилів абзаців: {count}, по одному на абзац +@msg the document has no Kinsoku set named '{shown}' у документі немає набору kinsoku з назвою '{shown}' +@msg must be 1-{MAX_FAMILY} printable characters має містити 1-{MAX_FAMILY} друкованих символів Read the objects it is given, and the document's settings, artboards, layers and swatches Читати передані йому об’єкти, а також параметри, монтажні області, шари та зразки документа @msg `context` must list distinct sections: settings, artboards, layers or swatches `context` має перелічувати різні розділи: settings, artboards, layers або swatches @msg `context` is for a filter, or a live effect with `commands`, at `api` 3 or later with the permission `doc.read` `context` дозволено лише для фільтра або динамічного ефекту з `commands`, з `api` 3 або вище та з дозволом `doc.read` diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index d358d49544..278a8c10e9 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -7193,6 +7193,35 @@ axis Y Axis Trục Y @msg `inputs` lists `{shown}` twice `inputs` liệt kê `{shown}` hai lần @msg `inputs` needs `api` 2 or later `inputs` cần `api` 2 trở lên @msg `inputs` needs the permission `doc.read` `inputs` cần quyền `doc.read` +@msg only a filter declares `writes` chỉ bộ lọc mới khai báo `writes` +@msg `writes` names an unknown object kind `{shown}`: use type, image or symbolInstance `writes` nêu một loại đối tượng không xác định `{shown}`: dùng type, image hoặc symbolInstance +@msg `writes` lists `{shown}` twice `writes` liệt kê `{shown}` hai lần +@msg `writes` lists `{shown}`, which `inputs` doesn't list `writes` liệt kê `{shown}`, nhưng `inputs` không liệt kê +@msg `writes` needs `api` {WRITES_API} or later `writes` cần `api` {WRITES_API} trở lên +@msg `writes` needs the permission `doc.write` `writes` cần quyền `doc.write` +@msg {_1} is not type, an image or a symbol instance {_1} không phải là văn bản, hình ảnh hay thực thể ký hiệu +@msg the text of type given as `truncated` can't be changed không thể thay đổi văn bản của đối tượng văn bản được đưa vào dưới dạng `truncated` +@msg must be a list of at most {MAX_INPUT_RUNS} entries phải là danh sách có tối đa {MAX_INPUT_RUNS} mục +@msg type needs at least one run văn bản cần ít nhất một đoạn chạy +@msg {bytes} bytes of text (limit {MAX_INPUT_TEXT}) {bytes} byte văn bản (giới hạn {MAX_INPUT_TEXT}) +@msg {paragraphs} paragraphs (limit {MAX_INPUT_RUNS}) {paragraphs} đoạn văn (giới hạn {MAX_INPUT_RUNS}) +@msg more than {MAX_INPUT_TEXT_TOTAL} bytes of text over the output hơn {MAX_INPUT_TEXT_TOTAL} byte văn bản trên toàn bộ đầu ra +@msg unknown key '{k}' khóa không xác định '{k}' +@msg must be a list of 6 numbers phải là danh sách gồm 6 số +@msg a number is out of range (limit ±{MAX_COORD}) một số nằm ngoài phạm vi (giới hạn ±{MAX_COORD}) +@msg flattens the object to a line or a point làm dẹt đối tượng thành một đường hoặc một điểm +@msg an object flattened to a line or a point can't be placed again không thể đặt lại một đối tượng đã bị dẹt thành đường hoặc điểm +@msg must be a number from 0 to 1 phải là một số từ 0 đến 1 +@msg must be the name of a symbol phải là tên của một ký hiệu +@msg '{shown}' is not a symbol in this document '{shown}' không phải là ký hiệu trong tài liệu này +@msg a run must be {{"text", "style", "inline"?}} một đoạn chạy phải có dạng {{"text", "style", "inline"?}} +@msg `text` holds the character of an inline graphic `text` chứa ký tự của một đồ họa nội dòng +@msg inline graphics can't be added, removed, reordered or changed không thể thêm, xóa, sắp xếp lại hoặc thay đổi đồ họa nội dòng +@msg the characters of threaded type can't be changed không thể thay đổi ký tự của văn bản chuỗi +@msg the characters of type with ruby can't be changed không thể thay đổi ký tự của văn bản có ruby +@msg expected {count} paragraph styles, one per paragraph cần {count} kiểu đoạn văn, mỗi đoạn một kiểu +@msg the document has no Kinsoku set named '{shown}' tài liệu không có bộ Kinsoku nào tên '{shown}' +@msg must be 1-{MAX_FAMILY} printable characters phải có 1-{MAX_FAMILY} ký tự in được Read the objects it is given, and the document's settings, artboards, layers and swatches Đọc các đối tượng được trao cho nó, cùng các thiết lập, bảng vẽ, lớp và mẫu màu của tài liệu @msg `context` must list distinct sections: settings, artboards, layers or swatches `context` phải liệt kê các phần khác nhau: settings, artboards, layers hoặc swatches @msg `context` is for a filter, or a live effect with `commands`, at `api` 3 or later with the permission `doc.read` `context` dành cho bộ lọc, hoặc hiệu ứng trực tiếp có `commands`, ở `api` 3 trở lên và có quyền `doc.read` diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index c48a32148a..ae265a4fc7 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -7374,6 +7374,35 @@ axis Y Axis Y 轴 @msg `inputs` lists `{shown}` twice `inputs` 列出了两次 `{shown}` @msg `inputs` needs `api` 2 or later `inputs` 需要 `api` 2 或更高 @msg `inputs` needs the permission `doc.read` `inputs` 需要权限 `doc.read` +@msg only a filter declares `writes` 只有滤镜才能声明 `writes` +@msg `writes` names an unknown object kind `{shown}`: use type, image or symbolInstance `writes` 列出了未知的对象类型 `{shown}`:请使用 type、image 或 symbolInstance +@msg `writes` lists `{shown}` twice `writes` 列出了两次 `{shown}` +@msg `writes` lists `{shown}`, which `inputs` doesn't list `writes` 列出了 `{shown}`,但 `inputs` 未列出它 +@msg `writes` needs `api` {WRITES_API} or later `writes` 需要 `api` {WRITES_API} 或更高 +@msg `writes` needs the permission `doc.write` `writes` 需要权限 `doc.write` +@msg {_1} is not type, an image or a symbol instance {_1} 不是文字、图像或符号实例 +@msg the text of type given as `truncated` can't be changed 作为 `truncated` 给出的文字对象的文本不能更改 +@msg must be a list of at most {MAX_INPUT_RUNS} entries 必须是最多 {MAX_INPUT_RUNS} 个条目的列表 +@msg type needs at least one run 文字至少需要一个文本段 +@msg {bytes} bytes of text (limit {MAX_INPUT_TEXT}) 文本 {bytes} 字节(上限 {MAX_INPUT_TEXT}) +@msg {paragraphs} paragraphs (limit {MAX_INPUT_RUNS}) 段落 {paragraphs} 个(上限 {MAX_INPUT_RUNS}) +@msg more than {MAX_INPUT_TEXT_TOTAL} bytes of text over the output 整个输出中的文本超过 {MAX_INPUT_TEXT_TOTAL} 字节 +@msg unknown key '{k}' 未知键 '{k}' +@msg must be a list of 6 numbers 必须是 6 个数字的列表 +@msg a number is out of range (limit ±{MAX_COORD}) 有数字超出范围(上限 ±{MAX_COORD}) +@msg flattens the object to a line or a point 会把对象压扁成一条线或一个点 +@msg an object flattened to a line or a point can't be placed again 已压扁成线或点的对象无法重新放置 +@msg must be a number from 0 to 1 必须是 0 到 1 之间的数字 +@msg must be the name of a symbol 必须是符号的名称 +@msg '{shown}' is not a symbol in this document '{shown}' 不是此文档中的符号 +@msg a run must be {{"text", "style", "inline"?}} 文本段必须是 {{"text", "style", "inline"?}} +@msg `text` holds the character of an inline graphic `text` 含有随文图形的字符 +@msg inline graphics can't be added, removed, reordered or changed 随文图形不能添加、删除、重新排序或更改 +@msg the characters of threaded type can't be changed 串接文本的字符不能更改 +@msg the characters of type with ruby can't be changed 带注音的文字的字符不能更改 +@msg expected {count} paragraph styles, one per paragraph 应有 {count} 个段落样式,每个段落一个 +@msg the document has no Kinsoku set named '{shown}' 文档中没有名为 '{shown}' 的 Kinsoku 集 +@msg must be 1-{MAX_FAMILY} printable characters 必须是 1-{MAX_FAMILY} 个可打印字符 Read the objects it is given, and the document's settings, artboards, layers and swatches 读取交给它的对象,以及文档的设置、画板、图层和色板 @msg `context` must list distinct sections: settings, artboards, layers or swatches `context` 必须列出互不相同的部分:settings、artboards、layers 或 swatches @msg `context` is for a filter, or a live effect with `commands`, at `api` 3 or later with the permission `doc.read` `context` 仅适用于 `api` 3 或更高、具有权限 `doc.read` 的滤镜或带 `commands` 的实时效果 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 58c451afd6..7d83822f05 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -7195,6 +7195,35 @@ axis Y Axis Y 軸 @msg `inputs` lists `{shown}` twice `inputs` 列出了兩次 `{shown}` @msg `inputs` needs `api` 2 or later `inputs` 需要 `api` 2 或更高 @msg `inputs` needs the permission `doc.read` `inputs` 需要權限 `doc.read` +@msg only a filter declares `writes` 只有濾鏡才能宣告 `writes` +@msg `writes` names an unknown object kind `{shown}`: use type, image or symbolInstance `writes` 列出了未知的物件類型 `{shown}`:請使用 type、image 或 symbolInstance +@msg `writes` lists `{shown}` twice `writes` 列出了兩次 `{shown}` +@msg `writes` lists `{shown}`, which `inputs` doesn't list `writes` 列出了 `{shown}`,但 `inputs` 未列出它 +@msg `writes` needs `api` {WRITES_API} or later `writes` 需要 `api` {WRITES_API} 或更高 +@msg `writes` needs the permission `doc.write` `writes` 需要權限 `doc.write` +@msg {_1} is not type, an image or a symbol instance {_1} 不是文字、影像或符號範例 +@msg the text of type given as `truncated` can't be changed 以 `truncated` 提供的文字物件,其文字無法變更 +@msg must be a list of at most {MAX_INPUT_RUNS} entries 必須是最多 {MAX_INPUT_RUNS} 個項目的清單 +@msg type needs at least one run 文字至少需要一個文字段 +@msg {bytes} bytes of text (limit {MAX_INPUT_TEXT}) 文字 {bytes} 位元組(上限 {MAX_INPUT_TEXT}) +@msg {paragraphs} paragraphs (limit {MAX_INPUT_RUNS}) 段落 {paragraphs} 個(上限 {MAX_INPUT_RUNS}) +@msg more than {MAX_INPUT_TEXT_TOTAL} bytes of text over the output 整個輸出中的文字超過 {MAX_INPUT_TEXT_TOTAL} 位元組 +@msg unknown key '{k}' 未知的鍵 '{k}' +@msg must be a list of 6 numbers 必須是 6 個數字的清單 +@msg a number is out of range (limit ±{MAX_COORD}) 有數字超出範圍(上限 ±{MAX_COORD}) +@msg flattens the object to a line or a point 會把物件壓扁成一條線或一個點 +@msg an object flattened to a line or a point can't be placed again 已壓扁成線或點的物件無法重新放置 +@msg must be a number from 0 to 1 必須是 0 到 1 之間的數字 +@msg must be the name of a symbol 必須是符號的名稱 +@msg '{shown}' is not a symbol in this document '{shown}' 不是此文件中的符號 +@msg a run must be {{"text", "style", "inline"?}} 文字段必須是 {{"text", "style", "inline"?}} +@msg `text` holds the character of an inline graphic `text` 含有行內圖形的字元 +@msg inline graphics can't be added, removed, reordered or changed 行內圖形無法新增、移除、重新排序或變更 +@msg the characters of threaded type can't be changed 串連文字的字元無法變更 +@msg the characters of type with ruby can't be changed 含注音的文字,其字元無法變更 +@msg expected {count} paragraph styles, one per paragraph 應有 {count} 個段落樣式,每個段落一個 +@msg the document has no Kinsoku set named '{shown}' 文件中沒有名為 '{shown}' 的 Kinsoku 集 +@msg must be 1-{MAX_FAMILY} printable characters 必須是 1-{MAX_FAMILY} 個可列印字元 Read the objects it is given, and the document's settings, artboards, layers and swatches 讀取交給它的物件,以及文件的設定、工作區域、圖層和色票 @msg `context` must list distinct sections: settings, artboards, layers or swatches `context` 必須列出互不相同的部分:settings、artboards、layers 或 swatches @msg `context` is for a filter, or a live effect with `commands`, at `api` 3 or later with the permission `doc.read` `context` 僅適用於 `api` 3 或更高、具有權限 `doc.read` 的濾鏡或帶 `commands` 的即時效果 diff --git a/crates/ui-egui/src/plugin_runs.rs b/crates/ui-egui/src/plugin_runs.rs index f537dd91c8..8830ab7526 100644 --- a/crates/ui-egui/src/plugin_runs.rs +++ b/crates/ui-egui/src/plugin_runs.rs @@ -23,7 +23,7 @@ use std::sync::mpsc::{Receiver, TryRecvError, channel}; use serde_json::{Value, json}; use vectorcraft_engine::EngineError; use vectorcraft_engine::cmd::fileio::progress::{self, Progress}; -use vectorcraft_engine::cmd::plugin::FilterRun; +use vectorcraft_engine::cmd::plugin::{self, FilterRun}; use vectorcraft_plugins::{permissions, registry}; use crate::VectorcraftApp; @@ -75,6 +75,11 @@ pub fn start(app: &mut VectorcraftApp, p: Value) -> Result { } // Bad parameters and a missing document fail here, before anything runs. let run = FilterRun::prepare(&app.session, &p).map_err(|e| e.to_string())?; + // Typing Real-time Drawing off left out of the document is kept next, so the plug-in is given it. + let run = match plugin::keep_unapplied_typing(&mut app.session).map_err(|e| e.to_string())? { + true => FilterRun::prepare(&app.session, &p).map_err(|e| e.to_string())?, + false => run, + }; let who = format!("“{}”", run.plugin().manifest().name.trim_end_matches('…')); let mut params = p; params["ids"] = json!(run.inputs().iter().map(|i| i.0).collect::>()); @@ -141,7 +146,8 @@ fn finish(app: &mut VectorcraftApp, r: Running, done: Option) { return; } }; - if !run.current(&app.session) { + // Typing started meanwhile with Real-time Drawing off isn't in what the plug-in was given. + if !run.current(&app.session) || plugin::unapplied_typing(&app.session) { app.status(format!("{} finished, but the document or the plug-in changed meanwhile: run it again", r.who)); return; } diff --git a/crates/ui-egui/src/tests/plugin_runs.rs b/crates/ui-egui/src/tests/plugin_runs.rs index ed161e797f..ef910a800e 100644 --- a/crates/ui-egui/src/tests/plugin_runs.rs +++ b/crates/ui-egui/src/tests/plugin_runs.rs @@ -201,6 +201,69 @@ fn a_heavy_filter_s_result_needs_the_document_as_it_was() { assert_eq!(app.ui.status, format!("“Test {id}” finished, but the document or the plug-in changed meanwhile: run it again")); } +/// A heavy filter that writes type, run while typing is in progress with Real-time Drawing off: +/// the typing is kept before the run starts, so the plug-in is given the typed text and its result +/// applies once it is done. A run that can't start keeps no typing. Typing started with Real-time +/// Drawing off while it runs isn't in what it was given: nothing changes, and the status bar says +/// to run it again. +#[test] +fn a_heavy_filter_is_given_the_typing_in_progress() { + use vectorcraft_doc::{NodeId, NodeKind}; + use vectorcraft_engine::ViewInfo; + use vectorcraft_engine::tools::{PointerEvent, PointerKind}; + let id = "test.ui.heavy.typing"; + let plain = |app: &VectorcraftApp, t: NodeId| match &app.session.doc().unwrap().doc.node(t).unwrap().kind { + NodeKind::Text(x) => x.plain_text(), + _ => panic!("type"), + }; + // Clicks into the end of `t` with the Type tool and types `text`. + let type_into = |app: &mut VectorcraftApp, t: NodeId, text: &str| { + let v = ViewInfo::default(); + app.session.select_tool("type", v).unwrap(); + let b = app.session.doc().unwrap().doc.bounds_of(&[t], false).unwrap(); + for k in [PointerKind::Down, PointerKind::Up] { + app.session.pointer(&PointerEvent::new(k, b.x1 - 1.0, b.center().y), v).unwrap(); + } + app.session.tool_text(text, v).unwrap(); + }; + let mut app = app(); + app.session.prefs.real_time_drawing = false; + let t = NodeId(app.run("text.create", json!({"x": 100, "y": 100, "text": "A", "size": 20})).unwrap()["id"].as_u64().unwrap()); + let style = match &app.session.doc().unwrap().doc.node(t).unwrap().kind { + NodeKind::Text(x) => serde_json::to_value(&x.runs[0].style).unwrap(), + _ => panic!("type"), + }; + let retyped = |text: &str| json!({"objects": [{"id": t.0, "text": {"runs": [{"text": text, "style": style}]}}]}).to_string(); + let manifest = format!( + r#"{{"id":"{id}","name":"Test {id}","kind":"filter","budget":"heavy","api":3,"permissions":["doc.read","doc.write"],"inputs":["type"],"writes":["type"]}}"# + ); + // It adds "!" to the text it is given: "AB" or, given only "A", "A". + let src = tpl::when_given_else(&manifest, tpl::Given::Input, r#""AB""#, &retyped("AB!"), &retyped("A!")); + let data = vectorcraft_format::base64_encode(&wat::parse_str(src).unwrap()); + app.run("plugin.install", json!({"dataBase64": data, "allowHeavy": true, "grant": ["doc.read", "doc.write"]})).unwrap(); + type_into(&mut app, t, "B"); + assert_eq!(plain(&app, t), "A", "Real-time Drawing off leaves the typing out of the document"); + // A run that can't start leaves the typing in progress, out of the document. + let undo = app.session.doc().unwrap().history.undo.len(); + assert!(plugin_runs::start(&mut app, json!({"id": "test.ui.heavy.missing", "ids": [t.0]})).is_err()); + assert_eq!(plain(&app, t), "A", "a run that can't start keeps no typing"); + assert_eq!(app.session.doc().unwrap().history.undo.len(), undo); + assert!(app.session.in_interaction(), "the typing is still in progress"); + let p = json!({"id": id, "ids": [t.0]}); + assert_eq!(plugin_runs::start(&mut app, p.clone()).unwrap()["background"], true); + assert_eq!(plain(&app, t), "AB", "the typing is kept before the run starts"); + finish_runs(&mut app); + assert_eq!(plain(&app, t), "AB!", "{}", app.ui.status); + assert!(app.ui.status.is_empty(), "{}", app.ui.status); + // Typing started while it runs, Real-time Drawing off. + plugin_runs::start(&mut app, p).unwrap(); + type_into(&mut app, t, "C"); + let doc = app.session.doc().unwrap().doc.clone(); + finish_runs(&mut app); + assert_eq!(app.session.doc().unwrap().doc, doc, "nothing changed"); + assert_eq!(app.ui.status, format!("“Test {id}” finished, but the document or the plug-in changed meanwhile: run it again")); +} + /// The progress window is the run's: headed by it, with Cancel and Continue in Background; Cancel /// stops the run, which changes nothing, and the window goes. #[test] diff --git a/docs/mcp.md b/docs/mcp.md index 88afdc37d5..3a4af8d453 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -13695,8 +13695,10 @@ its features turned off, distinct from unset. not a global swatch of the document, a stroke weight outside 0 to 4000000, more than 256 feature tags and an OpenType feature tag the shaper does not know, unless the style or the text it is made from already has that value. They also reject a size outside 0.1 to 1296, explicit leading outside 0.1 to 5000, horizontal or vertical scale -outside 1 to 10000, and baseline shift or Tate-chu-yoko offsets outside -1296 to 1296. `leading: null` keeps -Auto leading. An invalid value leaves the style, its text, and Undo history unchanged. +outside 1 to 10000, baseline shift or Tate-chu-yoko offsets outside -1296 to 1296, tracking or kerning +outside -1000 to 10000, rotation outside -360 to 360, a stroke miter limit outside 1 to 500, a +stroke dash length outside 0 to 4000000 or offset outside -4000000 to 4000000, Small Caps outside 1 to 200 and a +variable font axis setting that is not a number. `leading: null` keeps Auto leading. An invalid value leaves the style, its text, and Undo history unchanged. The New Character Style dialog accepts the same character fields and starts with the selected text's captured attributes. Without selected text, it starts with the character defaults for the interface language (including `charAlign: "emBoxCenter"` in Japanese); changing a Basic field keeps other seeded attributes. @@ -13828,9 +13830,16 @@ transforms and names included: pixels and runs that don't fit come the same way, fit makes `plugin.run` return a memory-budget error naming the object and its size, with nothing changed. A path or compound path that doesn't fit makes it return the memory-budget error `the selection is too large to hand over`, and more than 100,000 of these objects make it return an object-budget error. Its output returns -each of them as `{"id": …}` or exactly as given, otherwise `plugin.run` returns an error naming the object and the -field, and the document and undo history are unchanged. A filter, or a live effect with commands, at plug-in API level 3 -whose manifest lists `context` (`settings`, `artboards`, `layers`, `swatches`; `context` in its `plugin.list` entry) +each of them as `{"id": …}` or exactly as given (an image may leave out `opacity`), otherwise `plugin.run` returns an +error naming the object and the field, and the document and undo history are unchanged. A filter at plug-in API level 3 whose manifest also lists some of +those kinds in `writes` (with `doc.write`; `writes` in its `plugin.list` entry) may return an object of such a kind with +only the fields it changes: its name and `transform`, type's `text.runs` (at most 4,096 runs and 4,096 paragraphs, and +fills and strokes with only the keys their `type` reads) and `text.paragraphs` (one style per paragraph of the new text, +also when returned as given next to changed runs), an image's `opacity` and +an instance's `symbolId`, which must name a symbol in the document. Any other changed field, or a value out of range, +makes `plugin.run` return an error naming the object and the field, with nothing changed (docs/plugins.md, "Writing +type, images and symbols"). An output that changes nothing records no undo step. A filter, or a live effect with +commands, at plug-in API level 3 whose manifest lists `context` (`settings`, `artboards`, `layers`, `swatches`; `context` in its `plugin.list` entry) also lists `doc.read` in its `permissions`, and each filter or command run is given those parts of the active document in `_context.document`, with or without a selection: the document's name without its folder, color mode, units, active artboard size, bleed and raster effects resolution; every artboard's id, name and rectangle; every layer and sublayer diff --git a/docs/plugins.md b/docs/plugins.md index 64dc663710..fbde30ed55 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -425,7 +425,8 @@ capability model proposed for PhotoCraft plug-ins - `api` is the plug-in API level the manifest is written for: `1` (the default); `2`, which adds the [host imports](#host-imports-api-level-2), a filter's `inputs` ([reading type, images and symbols](#reading-type-images-and-symbols)) and a live effect's [`paintOutput`](#painted-live-effects); or `3`, which - adds `context` ([document information](#document-information)). A higher one is refused. `plugin.list` and + adds a filter's `writes` ([writing type, images and symbols](#writing-type-images-and-symbols)) and `context` + ([document information](#document-information)). A higher one is refused. `plugin.list` and `plugin.info` give it as `api`. `inputs` is not a permission: the objects it asks for are read under `doc.read`, which a filter that lists `inputs` must list in `permissions`, so installing it asks the user to grant them. `context` is not a permission either: it is read under `doc.read` in the same way, and the install prompt says that the plug-in @@ -671,11 +672,17 @@ the module's start function, in a run that isn't a filter's run on a document, o filters](#heavy-filters)). Hosts from before it ignore the key, so there the filter gets a light run's budget. - `api`: the plug-in API level, `1` when left out. `permissions`: what the plug-in may do, a list of names ([permissions](#permissions)); without it, what its kind implies. -- `inputs` (filters at `api` 2 only): the kinds of object besides paths and compound paths the filter reads, any of +- `inputs` (filters at `api` 2 or later): the kinds of object besides paths and compound paths the filter reads, any of `"type"`, `"image"` and `"symbolInstance"`, each at most once (`"inputs": ["type", "image"]`). Left out or `[]`, the filter gets paths and compound paths alone, as before. An unknown, repeated or wrongly typed entry, `inputs` on another kind, below `api` 2, or without a `permissions` list that holds `doc.read`, is refused when the plug-in is installed, and so is `api` 2 on hosts from before it. +- `writes` (filters at `api` 3 only): the kinds among `inputs` the filter may change ([writing type, images and + symbols](#writing-type-images-and-symbols)), each at most once (`"writes": ["type"]`). Left out or `[]`, everything + the filter reads stays read-only. An unknown, repeated or wrongly typed entry, a kind `inputs` doesn't list, `writes` + on another kind, below `api` 3, or without `doc.write` in `permissions`, is refused when the plug-in is installed. + Hosts from before `api` 3 refuse the manifest. A host at `api` 3 that doesn't read `writes` installs the filter, + ignores the key and keeps everything the filter reads read-only, so an output that changes those objects is refused. - `context` (filters, and live effects with `commands`, at `api` 3 only): the parts of the active document a run reads in `_context.document`, any of `"settings"`, `"artboards"`, `"layers"` and `"swatches"`, each at most once (`"context": ["artboards", "layers"]`). Left out or `[]`, a run gets none, as before. An unknown, repeated or wrongly @@ -810,7 +817,7 @@ every attribute: "runs": [{"text": "Hello\nthere", "style": {"font_family": "Source Sans 3", "size": 12}}], "paragraphs": [{"justify": "Left"}, {"justify": "Center"}]}, "truncated": false}, - {"id": 18, "type": "image", "bounds": [0, 0, 4, 2], "transform": [2, 0, 0, 2, 0, 0], "pixelSize": [2, 1], + {"id": 18, "type": "image", "bounds": [0, 0, 4, 2], "transform": [2, 0, 0, 2, 0, 0], "opacity": 1, "pixelSize": [2, 1], "colorMode": "rgb", "linked": false, "pixelsOmitted": false, "pixelsBase64": "AAAegGQAHoA="}, {"id": 19, "type": "symbolInstance", "bounds": [100, 0, 110, 10], "transform": [1, 0, 0, 1, 100, 0], "symbolId": "Star", "overrides": {}} @@ -824,7 +831,7 @@ every attribute: true` and empty `runs` and `paragraphs`. The runs and paragraphs of all the type in one input take at most 16 MiB of JSON: type whose runs and paragraphs don't fit what the type before it in paint order left comes with `truncated: true` too. -- An image (`"image"`): `pixelSize` is its width and height in pixels; `colorMode` is `"rgb"`, `"cmyk"`, `"gray"` or +- An image (`"image"`): `opacity` is its opacity, 0 to 1; `pixelSize` is its width and height in pixels; `colorMode` is `"rgb"`, `"cmyk"`, `"gray"` or `"unknown"`, read from the image itself. An image whose corners Perspective Distort or Free Distort moved to a shape that is not a parallelogram also has `corners`, its pixel rectangle's corners on the page (top left, top right, bottom right, bottom left), and its `transform` is then the affine placement nearest them, the one that matches the @@ -844,10 +851,13 @@ every attribute: - A symbol instance (`"symbolInstance"`): `symbolId` is the name of the symbol it shows, with `missing: true` when the document has no symbol of that name. `overrides` is `{}`. -These objects are read only. The output must list each of them exactly once, as `{"id": 17}` alone or exactly as it -was given (numbers compare by value, so `1` and `1.0` are the same). A changed or added field, one left out, an object -listed twice or left out, and a new object with one of these types are refused, and the document and undo history -stay as they were: `objects[1] (id 17): read-only field 'text.runs[0].text' changed`, `objects (id 17): a read-only +Objects of a kind that the manifest's `writes` doesn't list are read only. The output must list each of them exactly +once, as `{"id": 17}` alone or exactly as it was given (numbers compare by value, so `1` and `1.0` are the same). An +image may leave out `opacity`, which hosts before `api` 3 don't give. An object of a kind that `writes` lists is also +listed exactly once, and its entry may give only the fields it changes ([writing type, images and +symbols](#writing-type-images-and-symbols)). An output deletes the paths and compound paths it leaves out +([output](#output)), but none of these objects. A changed or added field, one left out, an object listed twice or left +out, and a new object with one of these types are refused, and the document and undo history stay as they were: `objects[1] (id 17): read-only field 'text.runs[0].text' changed`, `objects (id 17): a read-only object was left out`. The field is named with control and bidirectional characters escaped (`\u{202E}`), cut to 64 characters. New objects listed after one of them go just above it. @@ -861,6 +871,61 @@ the objects after it are written. An output lists at most 100,000 objects, so a objects fails with `plug-in exceeded its object budget (more than 100000 read-only objects)`. An echo of them counts toward the 64 MiB output cap. +### Writing type, images and symbols + +A filter at `api` 3 whose manifest lists some of its `inputs` kinds in `writes`, with `doc.write` in its +`permissions`, may change the objects of those kinds it is given. It returns such an object as `{"id": 17}` alone, +exactly as given, or with the fields it changes; a field it leaves out keeps its value. Each kind takes these fields: + +| Kind | Fields a filter may change | +|------|----------------------------| +| `type` | `name`, `transform`, `text.runs`, `text.paragraphs` | +| `image` | `name`, `transform`, `opacity` | +| `symbolInstance` | `name`, `transform`, `symbolId` | + +```json +{"objects": [ + {"id": 17, "text": {"runs": [{"text": "Goodbye", "style": {"font_family": "Source Sans 3", "size": 14}}]}}, + {"id": 18, "transform": [2, 0, 0, 2, 50, 60], "opacity": 0.5}, + {"id": 19, "symbolId": "Moon"} +]} +``` + +- `name` is a string, or `null` for no name. +- `transform` is six finite numbers, each within ±4,000,000, that don't flatten the object to a line. The object moves + by the change from its given transform, so an image's distorted corners move with it. +- `text.runs` replaces the type's runs: each is `{text, style, inline?}` with the character attributes as the native + file stores them, and an attribute the host doesn't know is refused, as is a key of a fill or stroke that its `type` + doesn't read. There is at least one run, at most 4,096, at most 4,096 paragraphs, and at most 256 KiB of UTF-8 text; + the runs written in one output take at most 16 MiB. Every number in every run's style is + checked against the range `charStyle.new` keeps it to, including a style one of the type's runs already has: size + 0.1 to 1296 pt, leading 0.1 to 5000 pt, tracking and kerning -1000 to 10000, horizontal and vertical scale 1 to + 10000 %, baseline shift -1296 to 1296 pt, rotation -360 to 360°, and the ranges `docs/mcp.md` gives for + `charStyle.new` for the East Asian, Warichu and stroke attributes. A style that none of the type's runs has also needs a font family of 1 to 256 + printable characters, and fills and strokes that a path's appearance would take. Inline graphics stay where they + were: the runs keep each `inline` run as it was given, in the same order. The characters of threaded type, and of + type with ruby, can't change, though their attributes can. The runs and paragraphs of type given with + `truncated: true` can't change. +- `text.paragraphs` holds one paragraph style per paragraph of the new text, each checked as `paraStyle.new` checks + its attributes: indents and space before and after within ±1296 pt, the Hyphenation and Justification options in + their ranges, at most 256 tab stops at 0 to 100,000 pt, and a custom Kinsoku set only by the name of one of the + document's sets, whose characters the paragraph takes. A `text.paragraphs` list returned as it was given next to + changed `text.runs` must also hold one style per paragraph of the new text. With `text.runs` alone, each paragraph keeps its style when + the number of paragraphs stays the same. When runs add or join paragraphs, the host matches the old and new + paragraphs by their text: a paragraph whose text is unchanged keeps its style, changed paragraphs take the styles of + the paragraphs they replace in order, and a paragraph added between others takes the style of the one before it (of + the next one at the start), without a list number. Apart from the paragraphs both texts start and end with, when + the old paragraphs times the new ones pass 262,144, the host pairs them in order instead. +- `opacity` is a number from 0 to 1. +- `symbolId` names a symbol in the document. An instance that shows another symbol loses its overrides, as Replace + Symbol does. + +Every other field, including `type`, `bounds`, `text.kind` and an image's pixels, stays read-only, and objects of these +kinds can't be added or left out. A changed read-only field or a value out of range refuses the whole output, naming +the object and the field (`objects[2] (id 18).opacity: must be a number from 0 to 1`), and the document and undo history +stay as they were. The changes of one run are one undo step, with the type laid out again; an output that changes +nothing records no undo step. The host never reads or gives a linked image's file when a filter writes. + ### Document information A filter, or a live effect with [commands](#commands), whose manifest lists `context` (plug-in API level 3) gets those @@ -948,7 +1013,9 @@ For an **object filter**, the output is the new state of the input objects: - An object without an `id` is new and needs a `path`. It goes just above the object listed before it, or, listed before any input object, just below the first one listed after it. New objects take a path's defaults: no fills or strokes, full opacity. -- Input objects missing from the output are deleted. The order of the input objects themselves doesn't change. +- Input paths and compound paths missing from the output are deleted; type, images and symbol instances can't be left + out ([reading type, images and symbols](#reading-type-images-and-symbols)). The order of the input objects themselves + doesn't change. - `type` turns a path into a compound path (one member per subpath) or back; `name: ""` clears the name. - `guide: true` makes the object a guide, as View › Guides › Make Guides does (a compound path's members become guide paths), and `guide: false` a plain path again; `locked: true` locks it and `locked: false` unlocks it. Objects @@ -1102,7 +1169,7 @@ per change of their input, parameters or paints (results are cached), not per fr - Tool plug-ins (pointer events on the canvas, a guide line or rectangle, geometry back), panel plug-ins, importers that make type, images, layers or artboards, and placed importer files that stay linked to their file. - Live effects that change opacity, blending or effects (at `api` 2 one may [paint](#painted-live-effects) the pieces - it returns), and filters that change type, images or symbol instances (a filter at `api` 2 reads them, see - [`inputs`](#reading-type-images-and-symbols)). + it returns), filters that add or delete type, images or symbol instances or change their pixels and other fields + (a filter at `api` 3 changes [some of their fields](#writing-type-images-and-symbols)). - Scripts can't run object filters (`plugin.*` commands are refused there), so a script doesn't change what Apply Last Filter runs. diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index da42d67bdf..182cade5be 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -840,7 +840,7 @@ since 2026-10-01. - **Composite fonts' custom character sets:** Type › Composite Fonts… › Custom adds named character sets to a composite font, each setting the characters it lists in its own font, style, size, baseline and scales ahead of their class; the later of two sets that list a character sets it ([the help page](https://web.archive.org/web/20220911143322/https://helpx.adobe.com/pdf/cs6/illustrator_reference.pdf#page=348)). Characters are added by Direct Entry or by Unicode code and deleted one at a time; the sets are saved with the document and in `.vccomposite` files (`custom` in `type.compositeFonts.set`). Evidence: `tests::composite::custom_character_sets_take_their_characters_first` (`crates/text`), `compositefonts::tests::custom_character_sets_set_their_characters` (`crates/engine`), `dialogs::composite_fonts::tests::custom_character_sets_are_edited_in_the_dialog` (`crates/ui-egui`). Scores unchanged (estimated). - **Composite fonts' Show Sample:** Type › Composite Fonts… › Show Sample draws the font picked in a line of sample text with lines for its ICF box, em box, baseline, cap height, highest ascent and lowest descent, highest ascender and x-height, each shown or hidden by its button, at the magnification Zoom picks ([Creating composite fonts](https://help.adobe.com/archive/en_US/illustrator/cs4/illustrator_cs4_help.pdf#page=352)). The sample text, the zoom steps and what each line measures are VectorCraft's own. Evidence: `dialogs::composite_fonts::tests::sample_lines_follow_the_parts`, `show_sample_shows_and_hides_the_sample` and `sample_fields_are_set_and_checked` (`crates/ui-egui`). Scores unchanged (estimated). - **Character-style Auto leading:** capture and explicit style attributes retain Auto as a reset, distinct from omitted leading. Redefine and later numeric updates preserve local leading overrides; the Character Styles marker recognizes Auto correctly. Regression assertions cover partial definitions, Undo/Redo and native save/load serialization. Public references: [Character and paragraph styles](https://helpx.adobe.com/illustrator/using/character-paragraph-styles.html) and [Leading](https://helpx.adobe.com/illustrator/using/line-character-spacing.html). -- **Character-style numeric bounds:** `charStyle.new`, `charStyle.edit`, and `charStyle.setAttrs` accept size from 0.1 to 1296 pt, explicit leading from 0.1 to 5000 pt, horizontal and vertical scale from 1% to 10,000%, and baseline shift and Tate-chu-yoko offsets from -1296 to 1296 pt. Out-of-range input leaves the style and Undo history unchanged; Auto leading remains available. These limits match the Character panel controls. +- **Character-style numeric bounds:** `charStyle.new`, `charStyle.edit`, and `charStyle.setAttrs` accept size from 0.1 to 1296 pt, explicit leading from 0.1 to 5000 pt, horizontal and vertical scale from 1% to 10,000%, baseline shift and Tate-chu-yoko offsets from -1296 to 1296 pt, tracking and kerning from -1000 to 10,000, rotation from -360° to 360°, a stroke miter limit from 1 to 500, Small Caps from 1% to 200%, finite stroke dashes and variable font axis settings. Out-of-range input leaves the style and Undo history unchanged; Auto leading remains available. These limits match the Character panel controls. - **Character Style Options, General and Basic Character Formats:** the dialog edits a style's name and stored character formats together. Empty fields remain unset, checkboxes show an indeterminate unset state, Basic's Reset Panel clears its explicit settings, and Preview can be canceled without changing history. OK saves one undo step; New Character Style offers the same fields from captured text or the interface language's defaults without a selection. Public reference: [Character and paragraph styles](https://helpx.adobe.com/illustrator/using/character-paragraph-styles.html). - **Character Style Options, Advanced Character Formats:** Character Style Options and New Character Style set a style's Horizontal Scale and Vertical Scale (1% to 10,000%), Baseline Shift (-1296 pt to 1296 pt), the Tate-chu-yoko Settings Up/Down and Left/Right (-1296 pt to 1296 pt), Character Rotation (stored from -180° to 180°) and Language; text that uses the style takes them and keeps its local overrides. Empty fields remain unset, an explicit 100%, 0 pt, 0° or English: USA stays distinct from unset, and the section's Reset Panel clears only these seven. Language sets the language the characters are shaped in, not hyphenation or spelling. Public references: [Character and paragraph styles](https://helpx.adobe.com/illustrator/using/character-paragraph-styles.html) and [Format East Asian characters](https://helpx.adobe.com/illustrator/using/formatting-asian-characters.html). - **Character Style Options, Character Color and OpenType Features:** Character Style Options and New Character Style set a style's fill and stroke (None or a document swatch; a global swatch stays linked, with a Tint from 0% to 100%), stroke Weight, Overprint Fill and Overprint Stroke, and its Figure, Position, Standard and Discretionary Ligatures, Contextual, Stylistic and Titling Alternates, Swash, Ordinals, Fractions and Stylistic Sets 1 to 20; text that uses the style takes them and keeps its local overrides, and editing a global swatch later updates the style and its text. Empty controls remain unset, an explicit None, off, Default Figure or Default Position stays distinct from unset, each stylistic set is on, off or unset, a gradient or pattern paint stays until another paint is chosen, a changed OpenType control keeps the style's other feature tags, and each section's Reset Panel clears only its own attributes. Public references: [Character and paragraph styles](https://helpx.adobe.com/illustrator/using/character-paragraph-styles.html) and [Format text with OpenType features](https://helpx.adobe.com/illustrator/desktop/design-with-text/special-characters-glyphs/format-text-with-opentype-features.html). @@ -2715,6 +2715,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - **Bulk memory fuzz cases use the host's fuel constants:** `crates/engine/tests/plugin_fuzz.rs` samples runs around one slice of the instruction budget and lengths around the bytes one unit of fuel pays for with `vectorcraft_plugins`' own `FUEL_SLICE` and `BYTES_COPIED_PER_FUEL`, so the sampled cases move when either value changes. Regressions: `crates/engine/tests/plugin_fuzz.rs`. Scores and hours unchanged. - **Plug-in permissions (G17):** a manifest may list `permissions` (`doc.read`, `doc.write`, `state`, `effect.render`, `export.write`; the first three follow storytold/photocraft#662) and an `api` level; without the list a plug-in gets what its kind implies and installs as before. Install Plug-in… and File › Open show the name, id, version, file SHA-256 and each permission in plain words, with control and bidirectional characters escaped, and install nothing on Cancel; for a plug-in that lists permissions, `plugin.install` needs `grant` and folders install it only when it is granted. The grant is kept with the module's hash, a module asking for more asks again, and a filter run refuses output its permissions don't allow. Regressions: `crates/plugins/src/permissions.rs`, `crates/plugins/src/manifest.rs`, `crates/engine/src/tests/plugins.rs`, `crates/engine/tests/plugin_fuzz.rs`, `crates/ui-egui/src/tests/plugins.rs`. Scores and hours unchanged. - **Filter plug-ins read type, images and symbol instances (G17, #4333):** a filter at plug-in API level 2 lists `inputs` (`type`, `image`, `symbolInstance`) with `doc.read` in its `permissions`, so installing it asks for approval, and is also given the selected objects of those kinds, read only: type with its runs, character and paragraph attributes (no text past 256 KiB or 4,096 runs or paragraphs, or 16 MiB of runs over the input), images with their size, color mode and, when embedded and at most 1 MiB in base64 (16 MiB over the input), their RGBA pixels (a CMYK image's through the working CMYK profile; never a linked file's), and symbol instances with their symbol and transform. The objects come in paint order from the bottom, and an image that reaches the decoder counts toward the 16 MiB of pixels even when decoding fails. Every object counts toward the input's half of the memory cap; one whose fields besides its pixels and runs don't fit fails the run naming it and its size, a path or compound path that doesn't fit fails it too, and so do more than 100,000 of these objects. Its output returns each as `{id}` or exactly as given; any change or omission is refused before the document changes. Filters without `inputs` get the same input as before, except that compound paths that clip a clip group and paths inside a group that clips one are left out for every filter. Regressions: `crates/plugins/src/objects/tests.rs`, `crates/plugins/src/manifest.rs`, `crates/engine/src/tests/plugins.rs`, `crates/engine/tests/plugin_fuzz.rs`. Scores and hours unchanged. +- **Filter plug-ins change type, images and symbol instances (G17):** a filter at plug-in API level 3 lists in `writes` the kinds among its `inputs` it may change, with `doc.write` in its `permissions`, and may return those objects with changed fields: type's runs (characters and character attributes, inline graphics kept as they were) and paragraph styles, an image's transform and opacity, an instance's transform and the symbol it shows (one already in the document; its overrides are cleared as Replace Symbol clears them), and each one's name. Runs are held to the input's limits (4,096 runs and 256 KiB of text a type object, 16 MiB over the output), every number in every run's and paragraph's style is checked against the range `charStyle.new` and `paraStyle.new` keep it to (one shared check, also for a style the type already has), a custom Kinsoku set must be one of the document's, a style of the filter's own needs a font family and its paints are checked as a path's are, and the characters of threaded type and type with ruby stay as they were. Any other changed field, or a value out of range, refuses the run naming the object and the field, with the document unchanged. The changes are one undo step, and an output that changes nothing, for every filter, records none. Images now also come with their `opacity`. Regressions: `crates/plugins/src/objects/tests.rs`, `crates/plugins/src/manifest.rs`, `crates/engine/src/tests/plugins.rs`. Scores and hours unchanged. - **Plug-ins read document information without a selection (G17):** a filter, or a live effect with commands, at plug-in API level 3 lists `context` (`settings`, `artboards`, `layers`, `swatches`) with `doc.read` in its `permissions`, so installing it asks for approval and the prompt names the document information, and each filter or command run is given those sections in `_context.document` whether or not anything is selected: the document's name without its folder, color mode, units, active artboard size, bleed and raster effects resolution; every artboard's id, index, name, rectangle and whether it is active; every layer and sublayer with its id, parent, depth, name, own visibility, lock and template settings, color and whether it is current; and every swatch as `swatch.list` lists it, with the document's revision. No path, object or other document is given, and drawing a live effect gets none. More than 10,000 rows or 4 MiB of them fail the run before the plug-in starts, and each row takes 1,000 instructions from its budget (VectorCraft's own values). Regressions: `crates/plugins/src/manifest.rs`, `crates/engine/src/tests/plugins.rs`. Scores and hours unchanged. - **Plug-in grants cover one module (G17):** a grant counts only for the module with the id and SHA-256 it records. A module that lists permissions and has other bytes under the same id needs a new approval, even with the same permissions: `plugin.inspect` reports `needsApproval`, `plugin.install` refuses it without `grant`, Install Plug-in… and File › Open ask again, and the plug-in store and plug-in folders skip it. A module with a missing or empty permissions list needs no grant; without the list, it gets its kind's implied permissions. A grant with a malformed hash covers nothing. Regressions: `crates/plugins/src/permissions.rs`, `crates/engine/src/tests/plugins.rs`, `crates/ui-egui/src/tests/plugins.rs`. Scores and hours unchanged. - **Plug-in approval needs a person (G17):** a plug-in's permissions and heavy budget are approved in a dialog that only a person can confirm: the control channel, MCP and injected input are refused, and `plugin.install` takes `grant` or `allowHeavy` only with that approval. `vectorcraft-cli mcp` and `run` refuse them unless started with `--allow-plugin-grants`. Regressions: `crates/engine/src/tests/plugins.rs`, `crates/ui-egui/src/tests/automation.rs`, `apps/vectorcraft-cli/tests/it/cli.rs`. Scores and hours unchanged.