Type: Make Numbers Sequence leaves locked type and masks alone and replaces signed numbers

Locked or hidden type inside a selected group is no longer numbered or
deleted, and removeUnused keeps a type object that masks a clipping group
or layer and keeps the selection instead of selecting the numbered objects.
In Numbers mode a minus sign that does not follow a letter is part of the
number, and a number or placeholder that already reads the new number keeps
its text and style. Rows and columns are found among the objects that get a
number, with the true median for an even count. A run that would replace
more than 10,000 numbers or placeholders is refused before any text is
built, and a seed that is not a whole number is refused even with shuffle
off. ui.menuDialog lists the dialog, and the progress doc has its line.
This commit is contained in:
dotCooCoo committed 2026-12-01 09:46:40 -08:00
1 parent 219ea91984
commit c2cf867f1d
7 files changed
+167 -29

No files matched your search

+1 -1
View File
@@ -71,7 +71,7 @@ pub fn specs() -> Vec<CommandSpec> {
"Make Numbers Sequence…",
["Object", "Plug-ins", "Type Tools"],
None,
"{start?: number (1), step?: number (1; its sign is set to run toward `end`; 0: every object gets `start`), end?: number (omitted: the numbers run to the last type object; given: they stop past `end`, and the objects after the last number keep their text), order?: \"stacking\" (stacking order, from the back) | \"rows\" (top to bottom, each row left to right) | \"columns\" (left to right, each column top to bottom) (\"stacking\"; rows and columns group objects whose centers are within half the median height or width), replace?: \"all\" (the whole text) | \"numbers\" (every number in the text: digits, with any `.` or `,` between digits) | \"placeholder\" (every {%n}, in any case) (\"all\"; with numbers or placeholder, objects that hold none are skipped and get no number), shuffle?: false (true: the numbers go to the objects in random order, and order is not used), seed?: whole number (0; the same seed gives the same order), leadingZeros?: true (non-negative numbers are padded with zeros to the whole digits of the widest of start and end, or of the last number), digits?: 1..30 (with leadingZeros, at least this many whole digits), trailingZeros?: false (true: every number gets as many decimal places as the one with the most), removeUnused?: false (true, with end: the objects left without a number are deleted), ids?: [id…], id? (instead of ids; neither: the selection)} number the type objects among the objects (inside groups too), as one undo step. A frame of threaded type among them is an error. Values are -1e12..1e12, rounded to the most decimal places among start, step and end (at most 6). Replaced text takes the style of the text it replaces. Objects that already read so are left as they are, and when nothing changes no undo step is made → {count (objects changed), ids (numbered, in order), removed}",
"{start?: number (1), step?: number (1; its sign is set to run toward `end`; 0: every object gets `start`), end?: number (omitted: the numbers run to the last type object; given: they stop past `end`, and the objects after the last number keep their text), order?: \"stacking\" (stacking order, from the back) | \"rows\" (top to bottom, each row left to right) | \"columns\" (left to right, each column top to bottom) (\"stacking\"; rows and columns group objects whose centers are within half the median height or width), replace?: \"all\" (the whole text) | \"numbers\" (every number in the text: digits, with any `.` or `,` between digits and a `-` before them that does not follow a letter or digit) | \"placeholder\" (every {%n}, in any case) (\"all\"; with numbers or placeholder, objects that hold none are skipped, get no number and order leaves them out; the remaining objects are ordered before end limits the sequence, so objects past end still count for rows and columns; at most 10000 numbers or placeholders are replaced in one run (matches that already read their number do not count); more is an error), shuffle?: false (true: the numbers go to the objects in random order, and order is not used), seed?: whole number (0; the same seed gives the same order; checked even with shuffle off), leadingZeros?: true (non-negative numbers are padded with zeros to the whole digits of the widest of start and end, or of the last number), digits?: 1..30 (with leadingZeros, at least this many whole digits), trailingZeros?: false (true: every number gets as many decimal places as the one with the most), removeUnused?: false (true, with end: the objects left without a number are deleted, except a clipping mask), ids?: [id…], id? (instead of ids; neither: the selection)} number the type objects among the objects (inside groups too), as one undo step. Locked or hidden type is left alone. A frame of threaded type among them is an error. Values are -1e12..1e12, rounded to the most decimal places among start, step and end (at most 6). Replaced text takes the style of the text it replaces, and a match that already reads its number keeps its style. Objects that already read so are left as they are, and when nothing changes no undo step is made → {count (objects changed), ids (numbered, in order), removed}",
has_selection,
numbers::make_numbers
),
@@ -13,6 +13,7 @@ use vectorcraft_doc::{NodeId, NodeKind};
use vectorcraft_geom::Rect;
use vectorcraft_render::effects;
use vectorcraft_text::edit;
use vectorcraft_text::retype::is_combining_mark;
use super::super::super::menucmds::whole_or;
use super::super::super::object::choice;
@@ -39,6 +40,8 @@ const MAX_DECIMALS: usize = 6;
pub const MAX_DIGITS: u64 = 30;
/// The most type objects one run numbers.
const MAX_TEXTS: usize = 100_000;
/// The most numbers or placeholders one run replaces.
pub(crate) const MAX_MATCHES: usize = 10_000;
/// What one run does, read from its params.
#[derive(Debug, Clone, PartialEq)]
@@ -76,7 +79,8 @@ impl Options {
};
let order = pick(choice(p, C, "order", &ORDERS)?.unwrap_or("stacking"), &ORDERS);
let replace = pick(choice(p, C, "replace", &REPLACES)?.unwrap_or("all"), &REPLACES);
let shuffle = if switch_or(p, "shuffle", false, C)? { Some(whole_or(p, "seed", 0, C)?) } else { None };
let seed = whole_or(p, "seed", 0, C)?;
let shuffle = if switch_or(p, "shuffle", false, C)? { Some(seed) } else { None };
let digits = match p.get("digits") {
None | Some(Value::Null) => None,
Some(_) => {
@@ -197,7 +201,7 @@ pub(crate) fn sequence(o: &Options, count: usize) -> Vec<String> {
}
/// The byte ranges of `text` a number replaces: each run of ASCII digits, with any `.` or `,`
/// followed by more digits inside it.
/// followed by more digits inside it, and a `-` before it that does not follow a letter or digit.
pub(crate) fn number_spans(text: &str) -> Vec<(usize, usize)> {
let b = text.as_bytes();
let mut out = vec![];
@@ -207,7 +211,8 @@ pub(crate) fn number_spans(text: &str) -> Vec<(usize, usize)> {
i += 1;
continue;
}
let start = i;
let signed = i > 0 && b[i - 1] == b'-' && !text[..i - 1].chars().rev().find(|c| !is_combining_mark(*c)).is_some_and(char::is_alphanumeric);
let start = if signed { i - 1 } else { i };
while i < b.len() && b[i].is_ascii_digit() {
i += 1;
}
@@ -236,7 +241,13 @@ fn by_position(ids: Vec<(NodeId, Rect)>, rows: bool) -> Vec<NodeId> {
let across = |r: &Rect| if rows { r.center().x } else { r.center().y };
let mut sizes: Vec<f64> = ids.iter().map(|(_, r)| if rows { r.height() } else { r.width() }).collect();
sizes.sort_by(f64::total_cmp);
let tolerance = if ids.len() < 2 { 0.0 } else { sizes[sizes.len() / 2] / 2.0 };
let n = sizes.len();
let median = match n {
0 | 1 => 0.0,
_ if n.is_multiple_of(2) => (sizes[n / 2 - 1] + sizes[n / 2]) / 2.0,
_ => sizes[n / 2],
};
let tolerance = median / 2.0;
let mut ids = ids;
ids.sort_by(|a, b| along(&a.1).total_cmp(&along(&b.1)));
let mut out = Vec::with_capacity(ids.len());
@@ -256,9 +267,10 @@ fn by_position(ids: Vec<(NodeId, Rect)>, rows: bool) -> Vec<NodeId> {
/// One replacement in a text: its start and end bytes and the number that goes there.
type Edit = (usize, usize, String);
/// Each span of `spans` replaced by `number`, as edits from the last to the first.
fn edits(spans: Vec<(usize, usize)>, number: &str) -> Vec<Edit> {
spans.into_iter().rev().map(|(a, b)| (a, b, number.to_string())).collect()
/// Each span of `spans` in `text` replaced by `number`, as edits from the last to the first. A
/// span that already reads `number` is left out, so its formatting stays.
pub(crate) fn edits(text: &str, spans: Vec<(usize, usize)>, number: &str) -> Vec<Edit> {
spans.into_iter().rev().filter(|(a, b)| text.get(*a..*b) != Some(number)).map(|(a, b)| (a, b, number.to_string())).collect()
}
pub(crate) fn make_numbers(s: &mut Session, p: &Value) -> Result<Value> {
@@ -269,8 +281,12 @@ pub(crate) fn make_numbers(s: &mut Session, p: &Value) -> Result<Value> {
if let Some(id) = named.iter().find(|id| d.node(**id).is_none()) {
return Err(EngineError::NoNode(*id));
}
// Type objects, groups' included, in stacking order from the back.
// Type objects, groups' included, in stacking order from the back; locked or hidden ones stay.
let mut texts = text_ids(d, &named);
{
let editable = d.editable();
texts.retain(|id| editable(*id));
}
let paths = d.index_paths(texts.iter().copied());
texts.sort_by(|a, b| paths.get(a).cmp(&paths.get(b)));
if texts.len() > MAX_TEXTS {
@@ -284,14 +300,7 @@ pub(crate) fn make_numbers(s: &mut Session, p: &Value) -> Result<Value> {
Some(NodeKind::Text(t)) => t.plain_text(),
_ => String::new(),
};
if o.order != "stacking" && o.shuffle.is_none() {
let placed: Vec<(NodeId, Rect)> = texts
.iter()
.map(|id| (*id, effects::preview::bounds_of(d, &[*id], false).unwrap_or(Rect::new(f64::MAX, f64::MAX, f64::MAX, f64::MAX))))
.collect();
texts = by_position(placed, o.order == "rows");
}
// Only objects that hold a number or the placeholder count.
// Only objects that hold a number or the placeholder count, for the order too.
let mut texts: Vec<(NodeId, String)> = texts
.into_iter()
.map(|id| (id, plain(id)))
@@ -301,6 +310,14 @@ pub(crate) fn make_numbers(s: &mut Session, p: &Value) -> Result<Value> {
_ => true,
})
.collect();
if o.order != "stacking" && o.shuffle.is_none() {
let placed: Vec<(NodeId, Rect)> = texts
.iter()
.map(|(id, _)| (*id, effects::preview::bounds_of(d, &[*id], false).unwrap_or(Rect::new(f64::MAX, f64::MAX, f64::MAX, f64::MAX))))
.collect();
let mut by_id: std::collections::HashMap<NodeId, String> = texts.into_iter().collect();
texts = by_position(placed, o.order == "rows").into_iter().filter_map(|id| by_id.remove(&id).map(|t| (id, t))).collect();
}
// The objects are shuffled, not the numbers, so an end limit can number any of them.
if let Some(seed) = o.shuffle {
let mut rng = Rng::new(seed);
@@ -311,10 +328,20 @@ pub(crate) fn make_numbers(s: &mut Session, p: &Value) -> Result<Value> {
}
let numbers = sequence(&o, texts.len());
let mut plans: Vec<(NodeId, Vec<Edit>)> = vec![];
let mut matches = 0;
for ((id, text), number) in texts.iter().zip(&numbers) {
let spans = match o.replace {
"numbers" => number_spans(text),
"placeholder" => placeholder_spans(text),
_ => vec![],
};
// Checked before any replacement text is made.
matches += spans.iter().filter(|(a, b)| text.get(*a..*b) != Some(number.as_str())).count();
if matches > MAX_MATCHES {
return Err(bad(C, format!("too many numbers or placeholders to replace: at most {MAX_MATCHES}")));
}
let changes = match o.replace {
"numbers" => edits(number_spans(text), number),
"placeholder" => edits(placeholder_spans(text), number),
"numbers" | "placeholder" => edits(text, spans, number),
_ => vec![(0, text.len(), number.clone())],
};
// The text it would have, to leave out objects that already read so.
@@ -327,12 +354,16 @@ pub(crate) fn make_numbers(s: &mut Session, p: &Value) -> Result<Value> {
}
}
let numbered: Vec<u64> = texts.iter().take(numbers.len()).map(|(id, _)| id.0).collect();
let removed: Vec<NodeId> = if o.remove_unused { texts.iter().skip(numbers.len()).map(|(id, _)| *id).collect() } else { vec![] };
// A clipping group's or layer's mask is its first child; removing it would make the next child the mask.
let mask = |id: NodeId| {
d.parent_of(id).and_then(|g| d.node(g)).is_some_and(|g| g.clips() && g.children().and_then(|c| c.first()).is_some_and(|c| c.id == id))
};
let removed: Vec<NodeId> =
if o.remove_unused { texts.iter().skip(numbers.len()).map(|(id, _)| *id).filter(|id| !mask(*id)).collect() } else { vec![] };
if plans.is_empty() && removed.is_empty() {
return Ok(json!({ "count": 0, "ids": numbered, "removed": [] }));
}
let count = plans.len();
let kept: Vec<NodeId> = numbered.iter().map(|n| NodeId(*n)).collect();
s.edit("Make Numbers Sequence", |d, sel| {
for (id, changes) in &plans {
let t = text_mut(d, *id).ok_or(EngineError::NoNode(*id))?;
@@ -345,7 +376,7 @@ pub(crate) fn make_numbers(s: &mut Session, p: &Value) -> Result<Value> {
}
d.remove_many(&removed)?;
if !removed.is_empty() {
sel.set(kept.iter().copied());
sel.remove_all(removed.iter().copied());
}
Ok(())
})?;
@@ -201,6 +201,103 @@ fn shuffle_with_an_end_can_number_any_object() {
assert_eq!(numbered, [true; 6], "every object is numbered for some seed");
}
fn group_of(s: &mut Session, ids: &[NodeId]) -> NodeId {
s.execute("select.set", &json!({"ids": ids.iter().map(|id| id.0).collect::<Vec<_>>()})).unwrap();
s.execute("object.group", &json!({})).unwrap();
s.doc().unwrap().doc.parent_of(ids[0]).unwrap()
}
#[test]
fn a_negative_number_in_the_text_is_replaced_with_its_sign() {
assert_eq!(number_spans("Seat -4, A-4"), [(5, 7), (11, 12)], "a hyphen after a letter is not a sign");
assert_eq!(number_spans("É-4"), [(3, 4)], "nor after a letter outside ASCII");
assert_eq!(number_spans("E\u{301}-4"), [(4, 5)], "nor after a letter with a combining mark");
assert_eq!(number_spans("क्-4"), [(7, 8)], "nor after a letter with a virama");
let mut s = session();
let a = text_at(&mut s, 40.0, 100.0, "Seat -4");
let b = text_at(&mut s, 40.0, 140.0, "Seat 9");
s.execute(C, &json!({"ids": [a.0, b.0], "replace": "numbers", "start": 2, "step": -3})).unwrap();
assert_eq!([plain(&s, a), plain(&s, b)], ["Seat 2", "Seat -1"]);
}
#[test]
fn a_match_that_already_reads_the_number_is_not_edited() {
let text = "5 and 4";
assert_eq!(super::edits(text, number_spans(text), "5"), [(6, 7, "5".to_string())]);
}
#[test]
fn too_many_matches_in_one_run_are_refused() {
let mut unchanged = session();
let text = vec!["1"; super::MAX_MATCHES + 1].join(" ");
let id = text_at(&mut unchanged, 40.0, 100.0, &text);
let before = steps(&unchanged);
let out = unchanged.execute(C, &json!({"ids": [id.0], "start": 1, "replace": "numbers"})).unwrap();
assert_eq!(out["count"], 0);
assert_eq!(plain(&unchanged, id), text);
assert_eq!(steps(&unchanged), before);
let mut s = session();
let a = text_at(&mut s, 40.0, 100.0, &"{%n}".repeat(super::MAX_MATCHES + 1));
let n = steps(&s);
assert!(s.execute(C, &json!({"ids": [a.0], "replace": "placeholder"})).is_err());
assert_eq!(steps(&s), n);
// Whole texts are not matches: the object limit covers them.
s.execute("edit.undo", &json!({})).unwrap();
text_at(&mut s, 40.0, 140.0, "x");
// Each duplicate of the whole selection doubles it: 2^14 objects in 14 steps.
for _ in 0..14 {
s.execute("edit.duplicate", &json!({})).unwrap();
s.execute("select.all", &json!({})).unwrap();
}
let count = s.doc().unwrap().selection.objects.len();
assert!(count > super::MAX_MATCHES, "{count} objects");
let out = s.execute(C, &json!({"step": 0}));
assert!(out.is_ok());
let out = out.unwrap();
assert!(out["count"].as_u64().unwrap() > super::MAX_MATCHES as u64);
}
#[test]
fn locked_and_hidden_type_in_a_group_is_left_alone() {
let mut s = session();
let ids: Vec<NodeId> = (0..3).map(|i| text_at(&mut s, 40.0, 100.0 + 40.0 * f64::from(i), "x")).collect();
let group = group_of(&mut s, &ids);
s.execute("object.setProps", &json!({"ids": [ids[1].0], "locked": true})).unwrap();
s.execute("object.setProps", &json!({"ids": [ids[2].0], "visible": false})).unwrap();
let out = s.execute(C, &json!({"ids": [group.0], "end": 1, "removeUnused": true})).unwrap();
assert_eq!(out["removed"], json!([]));
assert_eq!(ids.iter().map(|id| plain(&s, *id)).collect::<Vec<_>>(), ["1", "x", "x"]);
}
#[test]
fn removing_unused_type_keeps_a_clipping_mask_and_the_selection() {
let mut s = session();
let a = text_at(&mut s, 40.0, 100.0, "x");
let b = text_at(&mut s, 40.0, 140.0, "x");
// The top object becomes the mask; it sits lowest on the page, so rows number it last.
let mask = text_at(&mut s, 40.0, 300.0, "x");
s.execute("select.set", &json!({"ids": [a.0, b.0, mask.0]})).unwrap();
s.execute("object.clippingMask.make", &json!({})).unwrap();
let group = s.doc().unwrap().doc.parent_of(mask).unwrap();
s.execute("select.set", &json!({"ids": [group.0]})).unwrap();
let out = s.execute(C, &json!({"order": "rows", "end": 1, "removeUnused": true})).unwrap();
assert_eq!(out["removed"], json!([b.0]), "the mask stays");
assert!(s.doc().unwrap().doc.node(mask).is_some());
assert_eq!(s.doc().unwrap().selection.objects, [group], "the group stays selected");
}
#[test]
fn rows_are_found_among_the_type_that_gets_numbers() {
let mut s = session();
let upper = text_at(&mut s, 300.0, 100.0, "1");
let lower = text_at(&mut s, 40.0, 135.0, "1");
let h1 = NodeId(s.execute("text.create", &json!({"x": 40, "y": 400, "text": "Title", "size": 200})).unwrap()["id"].as_u64().unwrap());
let h2 = NodeId(s.execute("text.create", &json!({"x": 40, "y": 700, "text": "Title", "size": 200})).unwrap()["id"].as_u64().unwrap());
s.execute(C, &json!({"ids": [upper.0, lower.0, h1.0, h2.0], "replace": "numbers", "order": "rows", "start": 1, "leadingZeros": false})).unwrap();
assert_eq!([plain(&s, upper), plain(&s, lower)], ["1", "2"], "headings without numbers do not merge the rows");
}
#[test]
fn a_run_that_changes_nothing_makes_no_step_and_bad_params_fail() {
let mut s = session();
@@ -215,6 +312,7 @@ fn a_run_that_changes_nothing_makes_no_step_and_bad_params_fail() {
json!({"ids": [a.0], "digits": 0}),
json!({"ids": [a.0], "removeUnused": true}),
json!({"ids": [a.0], "shuffle": "yes"}),
json!({"ids": [a.0], "seed": "x"}),
] {
assert!(s.execute(C, &p).is_err(), "{p} fails");
}
+1 -1
View File
@@ -1531,7 +1531,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
"ui.menuDialog",
"Menu Dialog",
"",
"{command: object.move|object.rotate|object.scale|object.reflect|object.shear|object.transformEach|path.average|path.averageJoin|object.path.offsetPath|object.path.simplify|object.path.smooth|object.path.splitIntoGrid|object.vectorHalftone|object.stepAndRepeat|artboard.rearrange|artboard.rename|object.envelope.makeWithWarp|object.envelope.resetWithWarp|object.envelope.makeWithMesh|object.envelope.resetWithMesh|object.envelope.options|addon.arrange.grid|addon.arrange.offset|addon.arrange.replace|addon.arrange.size|addon.arrange.match|addon.arrange.groupRows|addon.packaging.setFoldAngle|addon.pathtools.cornerSet|addon.pathtools.divideDashes|addon.pathtools.bridge|addon.pathtools.tangentCircle|addon.type.textTweaker|addon.color.swatchLegend|addon.arrange.randomizeOpacity|addon.arrange.sort|addon.arrange.markBounds|addon.color.applyNearestSwatch|addon.color.randomFill|addon.select.byArtboards|addon.select.editPointsOnly|type.smartPunctuation|variable.define|variable.rename|variable.bind|dataset.new|dataset.set|dataset.rename|dataset.select} open the dialog that command's menu item opens (its `key` in ui.inspect is the command id, except `transformEach` for object.transformEach, `envelopeWarp` for object.envelope.makeWithWarp and object.envelope.resetWithWarp, `envelopeMesh` for object.envelope.makeWithMesh and object.envelope.resetWithMesh, `variables` for variable.define and variable.rename and variable.bind and dataset.new and dataset.set and dataset.rename and dataset.select, `envelopeOptions` for object.envelope.options, `smoothSlider` for object.path.smooth, and `simplifySlider` for object.path.simplify; the dialogs of addon.color.applyNearestSwatch and addon.select.byArtboards have no `key`; smoothSlider and simplifySlider are the sliders over the canvas, with field `level`, and object.path.simplify opens its dialog `object.path.simplify` instead once OK in that dialog keeps the settings (`retain`); Set Fold Angle's `angle` is the selected fold lines' angle, and it is refused while the selection has no fold line it can change; Scale and Transform Each have `corners` and `strokes`, from the preferences, which OK updates; Transform Each opens on the values it was last confirmed with (not `copy`), and its Copy button confirms with `copy: true`; the envelope dialogs start from the selected envelope, Make opens as Reset (`reset: true`) while one is selected; variable.rename opens only while the document has a variable, and dataset.set and dataset.rename only while it has a data set, and otherwise the status bar says why; ui.dialog.set, ui.dialog.confirm and ui.dialog.cancel take the dialog's `id` from ui.inspect, or `top`, not its `key`)",
"{command: object.move|object.rotate|object.scale|object.reflect|object.shear|object.transformEach|path.average|path.averageJoin|object.path.offsetPath|object.path.simplify|object.path.smooth|object.path.splitIntoGrid|object.vectorHalftone|object.stepAndRepeat|artboard.rearrange|artboard.rename|object.envelope.makeWithWarp|object.envelope.resetWithWarp|object.envelope.makeWithMesh|object.envelope.resetWithMesh|object.envelope.options|addon.arrange.grid|addon.arrange.offset|addon.arrange.replace|addon.arrange.size|addon.arrange.match|addon.arrange.groupRows|addon.packaging.setFoldAngle|addon.pathtools.cornerSet|addon.pathtools.divideDashes|addon.pathtools.bridge|addon.pathtools.tangentCircle|addon.type.textTweaker|addon.type.numbers|addon.color.swatchLegend|addon.arrange.randomizeOpacity|addon.arrange.sort|addon.arrange.markBounds|addon.color.applyNearestSwatch|addon.color.randomFill|addon.select.byArtboards|addon.select.editPointsOnly|type.smartPunctuation|variable.define|variable.rename|variable.bind|dataset.new|dataset.set|dataset.rename|dataset.select} open the dialog that command's menu item opens (its `key` in ui.inspect is the command id, except `transformEach` for object.transformEach, `envelopeWarp` for object.envelope.makeWithWarp and object.envelope.resetWithWarp, `envelopeMesh` for object.envelope.makeWithMesh and object.envelope.resetWithMesh, `variables` for variable.define and variable.rename and variable.bind and dataset.new and dataset.set and dataset.rename and dataset.select, `envelopeOptions` for object.envelope.options, `smoothSlider` for object.path.smooth, and `simplifySlider` for object.path.simplify; the dialogs of addon.color.applyNearestSwatch and addon.select.byArtboards have no `key`; smoothSlider and simplifySlider are the sliders over the canvas, with field `level`, and object.path.simplify opens its dialog `object.path.simplify` instead once OK in that dialog keeps the settings (`retain`); Set Fold Angle's `angle` is the selected fold lines' angle, and it is refused while the selection has no fold line it can change; Scale and Transform Each have `corners` and `strokes`, from the preferences, which OK updates; Transform Each opens on the values it was last confirmed with (not `copy`), and its Copy button confirms with `copy: true`; the envelope dialogs start from the selected envelope, Make opens as Reset (`reset: true`) while one is selected; variable.rename opens only while the document has a variable, and dataset.set and dataset.rename only while it has a data set, and otherwise the status bar says why; ui.dialog.set, ui.dialog.confirm and ui.dialog.cancel take the dialog's `id` from ui.inspect, or `top`, not its `key`)",
),
(
"ui.widthPointEdit",
+1 -1
View File
@@ -1532,7 +1532,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
"ui.menuDialog",
"Menu Dialog",
"",
"{command: object.move|object.rotate|object.scale|object.reflect|object.shear|object.transformEach|path.average|path.averageJoin|object.path.offsetPath|object.path.simplify|object.path.smooth|object.path.splitIntoGrid|object.vectorHalftone|object.stepAndRepeat|artboard.rearrange|artboard.rename|object.envelope.makeWithWarp|object.envelope.resetWithWarp|object.envelope.makeWithMesh|object.envelope.resetWithMesh|object.envelope.options|addon.arrange.grid|addon.arrange.offset|addon.arrange.replace|addon.arrange.size|addon.arrange.match|addon.arrange.groupRows|addon.packaging.setFoldAngle|addon.pathtools.cornerSet|addon.pathtools.divideDashes|addon.pathtools.bridge|addon.pathtools.tangentCircle|addon.type.textTweaker|addon.color.swatchLegend|addon.arrange.randomizeOpacity|addon.arrange.sort|addon.arrange.markBounds|addon.color.applyNearestSwatch|addon.color.randomFill|addon.select.byArtboards|addon.select.editPointsOnly|type.smartPunctuation|variable.define|variable.rename|variable.bind|dataset.new|dataset.set|dataset.rename|dataset.select} open the dialog that command's menu item opens (its `key` in ui.inspect is the command id, except `transformEach` for object.transformEach, `envelopeWarp` for object.envelope.makeWithWarp and object.envelope.resetWithWarp, `envelopeMesh` for object.envelope.makeWithMesh and object.envelope.resetWithMesh, `variables` for variable.define and variable.rename and variable.bind and dataset.new and dataset.set and dataset.rename and dataset.select, `envelopeOptions` for object.envelope.options, `smoothSlider` for object.path.smooth, and `simplifySlider` for object.path.simplify; the dialogs of addon.color.applyNearestSwatch and addon.select.byArtboards have no `key`; smoothSlider and simplifySlider are the sliders over the canvas, with field `level`, and object.path.simplify opens its dialog `object.path.simplify` instead once OK in that dialog keeps the settings (`retain`); Set Fold Angle's `angle` is the selected fold lines' angle, and it is refused while the selection has no fold line it can change; Scale and Transform Each have `corners` and `strokes`, from the preferences, which OK updates; Transform Each opens on the values it was last confirmed with (not `copy`), and its Copy button confirms with `copy: true`; the envelope dialogs start from the selected envelope, Make opens as Reset (`reset: true`) while one is selected; variable.rename opens only while the document has a variable, and dataset.set and dataset.rename only while it has a data set, and otherwise the status bar says why; ui.dialog.set, ui.dialog.confirm and ui.dialog.cancel take the dialog's `id` from ui.inspect, or `top`, not its `key`)",
"{command: object.move|object.rotate|object.scale|object.reflect|object.shear|object.transformEach|path.average|path.averageJoin|object.path.offsetPath|object.path.simplify|object.path.smooth|object.path.splitIntoGrid|object.vectorHalftone|object.stepAndRepeat|artboard.rearrange|artboard.rename|object.envelope.makeWithWarp|object.envelope.resetWithWarp|object.envelope.makeWithMesh|object.envelope.resetWithMesh|object.envelope.options|addon.arrange.grid|addon.arrange.offset|addon.arrange.replace|addon.arrange.size|addon.arrange.match|addon.arrange.groupRows|addon.packaging.setFoldAngle|addon.pathtools.cornerSet|addon.pathtools.divideDashes|addon.pathtools.bridge|addon.pathtools.tangentCircle|addon.type.textTweaker|addon.type.numbers|addon.color.swatchLegend|addon.arrange.randomizeOpacity|addon.arrange.sort|addon.arrange.markBounds|addon.color.applyNearestSwatch|addon.color.randomFill|addon.select.byArtboards|addon.select.editPointsOnly|type.smartPunctuation|variable.define|variable.rename|variable.bind|dataset.new|dataset.set|dataset.rename|dataset.select} open the dialog that command's menu item opens (its `key` in ui.inspect is the command id, except `transformEach` for object.transformEach, `envelopeWarp` for object.envelope.makeWithWarp and object.envelope.resetWithWarp, `envelopeMesh` for object.envelope.makeWithMesh and object.envelope.resetWithMesh, `variables` for variable.define and variable.rename and variable.bind and dataset.new and dataset.set and dataset.rename and dataset.select, `envelopeOptions` for object.envelope.options, `smoothSlider` for object.path.smooth, and `simplifySlider` for object.path.simplify; the dialogs of addon.color.applyNearestSwatch and addon.select.byArtboards have no `key`; smoothSlider and simplifySlider are the sliders over the canvas, with field `level`, and object.path.simplify opens its dialog `object.path.simplify` instead once OK in that dialog keeps the settings (`retain`); Set Fold Angle's `angle` is the selected fold lines' angle, and it is refused while the selection has no fold line it can change; Scale and Transform Each have `corners` and `strokes`, from the preferences, which OK updates; Transform Each opens on the values it was last confirmed with (not `copy`), and its Copy button confirms with `copy: true`; the envelope dialogs start from the selected envelope, Make opens as Reset (`reset: true`) while one is selected; variable.rename opens only while the document has a variable, and dataset.set and dataset.rename only while it has a data set, and otherwise the status bar says why; ui.dialog.set, ui.dialog.confirm and ui.dialog.cancel take the dialog's `id` from ui.inspect, or `top`, not its `key`)",
),
(
"ui.widthPointEdit",
+10 -5
View File
@@ -18243,10 +18243,15 @@ placeholder in it. It is based on Sergey Osokin's MIT-licensed
script.
- With `end` omitted the numbers run to the last object. With `end`, they stop past it and the objects after the last
number keep their text, or are deleted with `removeUnused`. The sign of `step` is set to run toward `end`.
- With `replace` `numbers` or `placeholder`, objects that hold no number or placeholder are skipped and get no number.
A number is a run of digits with any `.` or `,` between digits. Replaced text takes the style of the text it
replaces.
number keep their text, or are deleted with `removeUnused`. A type object that is the mask of a clipping group or layer
is not deleted. The sign of `step` is set to run toward `end`.
- Locked or hidden type, also inside a selected group, is not numbered or deleted.
- With `replace` `numbers` or `placeholder`, objects that hold no number or placeholder are skipped and get no number,
and `order` leaves them out. The remaining objects are ordered before `end` limits the sequence, so objects past
`end` still count for rows and columns. A number is a run of digits with any `.` or `,` between digits,
and a `-` before it that does not follow a letter or digit. Replaced text takes the style of the text it replaces;
a number or placeholder that already reads the new number keeps its text and style. With `numbers` or
`placeholder`, one run replaces at most 10,000 numbers or placeholders; more is an error, and nothing changes.
- Values are rounded to the most decimal places among `start`, `step` and `end` (at most 6), so 0.1 by 0.1 gives
0.1, 0.2, 0.3.
- Objects that already read so are left as they are; when nothing changes no undo step is made.
@@ -18258,7 +18263,7 @@ script.
| `end` | number −1e12…1e12 (omitted: to the last object) |
| `order` | `stacking` (from the back), `rows` (top to bottom, each row left to right), `columns` (left to right, each column top to bottom) (`stacking`). Objects whose centers are within half the median height (width for columns) of a row's first object share its row |
| `replace` | `all`, `numbers`, `placeholder` (`all`) |
| `shuffle`, `seed` | false; true: the numbers go to the objects in random order, the same `seed` (0) giving the same order, and `order` is not used |
| `shuffle`, `seed` | false; true: the numbers go to the objects in random order, the same `seed` (a whole number, 0) giving the same order, and `order` is not used. A `seed` that is not a whole number is an error even with `shuffle` off |
| `leadingZeros` | true: non-negative numbers are padded with zeros to the whole digits of the wider of `start` and `end` (or the last number) |
| `digits` | 1…30: with `leadingZeros`, at least this many whole digits |
| `trailingZeros` | false; true: every number gets as many decimal places as the one with the most |
+4
View File
@@ -3184,6 +3184,10 @@ A VectorCraft addition, not a feature of the reference app, so no area score mov
A VectorCraft addition, not a feature of the reference app (it has no command for this), so no area score moves. Object › Plug-ins › Type Tools › Release Type on a Path… splits each selected type on a path into point type holding the same text and the plain path it was set on, or keeps only one of them (#5532). The path keeps its exact shape (open or closed, anchors and handles, the object's transform), layer and place in the stacking order, with no fill and no stroke since type paths carry no paint of their own. The text keeps its runs, character and paragraph attributes and becomes point type on one straight line whose baseline starts where the first character sat on the path; Type on a Path Options don't apply to point type and are dropped. Keep Original leaves the type on a path and adds the released objects above it. Other objects are left alone and a selection with no type on a path makes no undo step; otherwise the run is one undo step, the released objects are selected, and the dialog's Preview works as Type on a Path Options' does (#5360). Tests: `cmd::addons::typetools::tests::release` in `vectorcraft-engine` (each mode, Keep Original, mixed and empty selections, closed, open, curved and flipped paths, transformed and grouped type, multi-style and unicode text with a centred paragraph, empty type, undo and redo, preview, cancel and commit, bad params refused), `release_type_on_a_path_previews_cancels_and_runs_on_ok` in `vectorcraft-ui-egui` and `command_sweep`. Commands: `docs/mcp.md` › Type Tools add-on › Release Type on a Path.
## Type Tools add-on: Make Numbers Sequence (2026-12-01)
A VectorCraft addition, so no area score moves. Object › Plug-ins › Type Tools › Make Numbers Sequence… numbers the selected type objects from a start value by a step, optionally stopping at an end value, and each number replaces the whole text, every number in it, or every `{%n}` placeholder (#10448). The objects are taken in stacking order, by rows or by columns, or in a seeded random order, with optional leading and trailing zeros, and the objects past the end can be deleted. Locked and hidden type is left alone, a clipping mask is not deleted, threaded type and bad parameters are refused, and the run is one undo step from a dialog with Preview. It is based on Sergey Osokin's MIT-licensed MakeNumbersSequence script. Tests: `cmd::addons::typetools::numbers::tests` in `vectorcraft-engine`, `addons::typetools::numbers::tests` in `vectorcraft-ui-egui` and `command_sweep`. Commands: `docs/mcp.md` › Type Tools add-on.
## Unit Converter add-on (2026-11-14)
A VectorCraft addition, so no area score moves. Object › Plug-ins › Unit Converter opens a panel with one number field per unit of Preferences › Units › East Asian Type (pt, picas, in, mm, cm, px, ft & in, m, yd, ft, Q, Ha), as proposed in #5528. A length typed in any field, with units and arithmetic as every number field reads them, updates the others as it is typed; text that does not read leaves them as they were. From Selection reads the selection's width and height as the Transform panel measures them, Width or Height picks which one the fields show, and Apply sets that side of the selection through `object.setBounds` as the Transform panel's W or H field does (its reference point, Constrain Width and Height Proportions and its Transform Object Only, Pattern Only or Both choice) as one undo step, with no step when the size is already that length. Each field's copy button copies its value, with its unit when Copy with Units is on. Agents use `addon.units.convert` and `addon.units.selectionSize`, which change nothing in the document (`docs/mcp.md`). Tests: `cmd::addons::units::tests` in `vectorcraft-engine` (every unit, number-field syntax, preview bounds and selected anchors, bad params and unknown keys refused), `addons::units::tests` in `vectorcraft-ui-egui` (typing, From Selection and a changed selection, Apply with the Transform panel's reference point, proportions, pattern choice and a symbol's registration point, copy, screen-reader names) and `command_sweep`.