Shaper: new groups and clipping masks no longer delete a Shaper group

A Shaper group keeps its source art at the bottom and rebuilds the rest
from it. object.newGroup with a Shaper group as parent at index 0, and
layer.clippingMask.toggle (also a script's clipped = true) on a Shaper
group, put a new object where the source art was. The group then read
no sources and was deleted. Both commands now refuse a Shaper group and
leave the document as it is; the clipping check runs before the edit
opens, so a refused call leaves typing as it is.
This commit is contained in:
dotCooCoo committed 2026-12-04 18:02:53 -08:00
1 parent 3368ac519c
commit 05ed058fb1
6 files changed
+45 -5

No files matched your search

+6 -1
View File
@@ -192,7 +192,7 @@ pub fn specs() -> Vec<CommandSpec> {
"Make/Release Clipping Mask",
["Window", "Layers"],
None,
"{id?: layer or group (default: the one highlighted layer or group row, else the one selected group, else the current layer)} make: its top object (a path, compound path or text, which loses its paint) clips the rest and moves to the bottom (new art added on top is clipped); release: it stops clipping, the clipping path stays unpainted → {clip}",
"{id?: layer or group (default: the one highlighted layer or group row, else the one selected group, else the current layer)} make: its top object (a path, compound path or text, which loses its paint) clips the rest and moves to the bottom (new art added on top is clipped; a Shaper group is refused and changes nothing); release: it stops clipping, the clipping path stays unpainted → {clip}",
has_doc,
clip_toggle
),
@@ -526,6 +526,11 @@ fn clip_toggle(s: &mut Session, p: &Value) -> Result<Value> {
None => None,
};
let id = given.or(row).or(group).or(st.current_layer()).ok_or_else(|| bad("layer.clippingMask.toggle", "no layer"))?;
// A Shaper group keeps its source art first; a clipping path there would replace it. The
// check comes before the edit so that a refused call leaves any typing as it is.
if st.doc.node(id).is_some_and(|n| !n.clips() && n.extras().shaper.is_some()) {
return Err(bad("layer.clippingMask.toggle", format!("{} is a Shaper group, whose contents are made from its source art", id.0)));
}
let clip = s.edit("Make/Release Clipping Mask", |d, _| {
let n = d.node(id).ok_or(EngineError::NoNode(id))?;
if !matches!(n.kind, NodeKind::Layer { .. } | NodeKind::Group { .. }) {
+4
View File
@@ -129,6 +129,10 @@ pub(super) fn new_group(s: &mut Session, p: &Value) -> Result<Value> {
if !matches!(n.kind, NodeKind::Layer { .. } | NodeKind::Group { .. }) || n.extras().graph.is_some() {
return Err(bad(C, format!("{} is not a layer or group", parent.0)));
}
// A Shaper group rebuilds its contents from the source art it holds first.
if n.extras().shaper.is_some() {
return Err(bad(C, format!("{} is a Shaper group, whose contents are made from its source art", parent.0)));
}
if !d.is_editable(parent) {
return Err(bad(C, "the layer or group is hidden or locked"));
}
+1 -1
View File
@@ -142,7 +142,7 @@ pub fn specs() -> Vec<CommandSpec> {
"Group",
[],
None,
"{parent?: layer or group id (default: the current layer), index?: n (0 = bottom, or directly above the clipping path in a clipping layer or group; 0 is refused in an Image Trace object, whose source image stays at the bottom; default: on top), compound?: bool (default false; true: an empty compound path instead of a group)} → {id}: an empty group or compound path in a shown, unlocked layer or group; an omitted key takes its default; null is refused for parent, index and compound; the selection stays as it is",
"{parent?: layer or group id (default: the current layer), index?: n (0 = bottom, or directly above the clipping path in a clipping layer or group; 0 is refused in an Image Trace object, whose source image stays at the bottom; default: on top), compound?: bool (default false; true: an empty compound path instead of a group)} → {id}: an empty group or compound path in a shown, unlocked layer or group (a Shaper group is refused and changes nothing); an omitted key takes its default; null is refused for parent, index and compound; the selection stays as it is",
has_doc,
new_group
),
+27
View File
@@ -3683,6 +3683,33 @@ fn compound_path_items_add_makes_an_empty_compound_path_that_takes_paths() {
assert!(s.execute("object.newGroup", &json!({"compound": 1})).unwrap_err().to_string().contains("true or false"));
}
/// A Shaper group rebuilds its contents from the source art it holds first, so `object.newGroup`
/// refuses it as a parent: at index 0 the empty group would take the sources' place and the
/// Shaper group would be deleted.
#[test]
fn new_group_refuses_a_shaper_group_as_its_parent() {
let (mut s, a, _) = doc();
let b = rect(&mut s, 30.0, 20.0, 30.0, 40.0);
s.execute("select.set", &json!({"ids": [a.0, b.0]})).unwrap();
let shaper = NodeId(s.execute("shaper.scribble", &json!({"points": [[25, 40], [50, 40]]})).unwrap()["id"].as_u64().unwrap());
let before = s.active().unwrap().doc.node(shaper).cloned().unwrap();
for index in [json!(0), json!(1), Value::Null] {
let mut p = json!({"parent": shaper.0});
if !index.is_null() {
p["index"] = index;
}
let err = s.execute("object.newGroup", &p).unwrap_err().to_string();
assert!(err.contains("Shaper group"), "{p}: {err}");
assert_eq!(s.active().unwrap().doc.node(shaper), Some(&before), "{p}");
}
// Making a clipping mask moves the topmost object to index 0 the same way.
let err = s.execute("layer.clippingMask.toggle", &json!({"id": shaper.0})).unwrap_err().to_string();
assert!(err.contains("Shaper group"), "{err}");
let src = "var g = app.activeDocument.groupItems[0]; try { g.clipped = true; vc.log('clipped'); } catch (e) { vc.log(String(e).indexOf('Shaper group') >= 0); }";
assert_eq!(log(&mut s, src), [json!(true)]);
assert_eq!(s.active().unwrap().doc.node(shaper), Some(&before));
}
/// The paint of a compound path's only path is the compound path's: moved into an empty compound
/// path, the path gives it that paint, not its own default one.
#[test]
+6 -2
View File
@@ -3414,7 +3414,8 @@ through `$`:
without art releases its mask in the same undo step. `groupItems.add()` makes an empty group on top of the
layer's or group's contents, or of the current layer's for the document's collection, and `compoundPathItems.add()`
makes an empty compound path in the same place
(https://ai-scripting.docsforadobe.dev/jsobjref/CompoundPathItems/). A path that `move` or `duplicate` puts into a
(https://ai-scripting.docsforadobe.dev/jsobjref/CompoundPathItems/). In a Shaper group, `groupItems.add()`,
`compoundPathItems.add()` and `clipped = true` throw and change nothing. A path that `move` or `duplicate` puts into a
compound path becomes one of its paths and gives up its own paint, as Make Compound Path leaves its paths. The
compound path becomes pixel-aligned when the path was, or when the compound path it leaves was. A path moved
into an already pixel-aligned compound path is snapped to the pixel grid. An empty
@@ -3444,6 +3445,8 @@ through `$`:
since the source image stays at the bottom, and index 1 puts it directly above the source image), as one undo step
named Group, and
gives `{id}`. With `compound: true` it adds an empty compound path instead, as one undo step named Compound Path.
A Shaper group is refused as `parent` and changes nothing, since its contents are made from the source art it holds
at the bottom.
An omitted key takes its default (`parent`: the current layer; `index`: on top; `compound`: false).
Explicit `null` is refused for `parent`, `index` and `compound`.
The selection stays as it is. `node.move` also puts a path into a shown, unlocked compound path (its layer and
@@ -5281,7 +5284,8 @@ paints behind the clipped art and its stroke over it, not clipped, on screen and
`layer.clippingMask.toggle {id?}` is the Layers panel's clipping mask button: the top object of the layer `id` (default:
the one highlighted layer or group row, else the one selected group, else the current layer) becomes its clipping path (unpainted, moved to the bottom of the layer,
so art added later is clipped too); called again it releases the mask. It returns `{clip}`, and the Layers panel
underlines clipping-path names.
underlines clipping-path names. Making a mask in a Shaper group is refused and changes nothing, since the group's
source art stays at its bottom.
## Object selection
+1 -1
View File
@@ -1131,7 +1131,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
- Scripts: `document.characterStyles` and `document.paragraphStyles` add, find, rename, redefine, apply and remove character and paragraph styles, with the Normal styles listed first and kept, and a text range lists the styles its text is in, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/CharacterStyles/, https://ai-scripting.docsforadobe.dev/jsobjref/CharacterStyle/, https://ai-scripting.docsforadobe.dev/jsobjref/ParagraphStyles/, https://ai-scripting.docsforadobe.dev/jsobjref/ParagraphStyle/ and https://ai-scripting.docsforadobe.dev/jsobjref/TextRange/ describe them (`docs/mcp.md`). Style names of 1 to 256 characters without control characters, and at most 4,096 styles named in one run, are VectorCraft's own rules. Load Character Styles, Load Paragraph Styles and Load All Styles refuse a file larger than 64 MB. A paragraph style's character attributes are not there yet. `crates/engine/src/tests/script_styles.rs`.
- Scripts: a text frame's `nextFrame` and `previousFrame` read and set its links to the frames before and after it, `areaText` and `pathText` thread a new frame to a base frame, and `document.stories` lists the stories, each with its frames in thread order and its text across them as one text range with its characters, words and paragraphs, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/TextFrameItem/, https://ai-scripting.docsforadobe.dev/jsobjref/Story/ and https://ai-scripting.docsforadobe.dev/jsobjref/Stories/ describe them; `text.thread.setNeighbor` links or unlinks two frames by id (`docs/mcp.md`). Which links are refused, and how a story is listed and found, are VectorCraft's own rules. `crates/engine/src/tests/script_threads.rs`.
- Scripts: `PageItem.tags` reads, adds, renames and deletes an object's tags, name and value pairs that the native file keeps, and `Document.tags` reads, renames and deletes the tags of every page item but adds none (its `add` throws; a script adds a tag through the page item's `tags`), as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/Tags/ and https://ai-scripting.docsforadobe.dev/jsobjref/Tag/ describe them, through `object.tags` and the `object.tag.*` commands, at most 64 tags an object (`docs/mcp.md`). `crates/engine/src/tests/script_tags.rs`.
- Scripts: a document's layers and sublayers with their options, stacking and current layer, its groups and compound paths with clipping masks, new empty groups and compound paths and paths moved into compound paths, and its artboards with their rectangles, names, ruler origins and display options, added, inserted, removed and made active, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/Layer/, https://ai-scripting.docsforadobe.dev/jsobjref/Layers/, https://ai-scripting.docsforadobe.dev/jsobjref/GroupItems/, https://ai-scripting.docsforadobe.dev/jsobjref/CompoundPathItem/, https://ai-scripting.docsforadobe.dev/jsobjref/CompoundPathItems/, https://ai-scripting.docsforadobe.dev/jsobjref/Artboard/ and https://ai-scripting.docsforadobe.dev/jsobjref/Artboards/ describe them (`docs/mcp.md`); `artboards.add` returns the new artboard and `artboards.insert` returns nothing. Scoped collections support string conversion, which fails for `Layers`, `GroupItems`, `CompoundPathItems` and `Artboards` once their container is gone; a compound path's `pathItems` are `PathItems` objects whose `add()` and shape methods make the new path inside it; `removeAll()` on a compound path's `pathItems` throws when it would empty a compound path that clips a group or layer keeping other objects that are not ruler guides. Empty clipping containers release their masks in the deletion's undo step, and `clipped` changes check the group's, layer's and artboard's locks; turning clipping on also refuses a hidden or locked topmost object, which would become the mask. Layer selection changes keep unrelated selected objects, layer colors are assignable `RGBColor` values, stacking scans count toward the script budget, and paths moved into pixel-aligned compound paths are snapped. The `textFrames` of a layer or group list the type directly in it and put new type on top of its contents (VectorCraft's own rule), as https://ai-scripting.docsforadobe.dev/jsobjref/Layer/ and https://ai-scripting.docsforadobe.dev/jsobjref/GroupItem/ list them. `crates/engine/src/tests/script_dom.rs`, `crates/engine/src/tests/script_text.rs`, `crates/ui-egui/src/tests/script_run.rs`.
- Scripts: a document's layers and sublayers with their options, stacking and current layer, its groups and compound paths with clipping masks, new empty groups and compound paths and paths moved into compound paths, and its artboards with their rectangles, names, ruler origins and display options, added, inserted, removed and made active, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/Layer/, https://ai-scripting.docsforadobe.dev/jsobjref/Layers/, https://ai-scripting.docsforadobe.dev/jsobjref/GroupItems/, https://ai-scripting.docsforadobe.dev/jsobjref/CompoundPathItem/, https://ai-scripting.docsforadobe.dev/jsobjref/CompoundPathItems/, https://ai-scripting.docsforadobe.dev/jsobjref/Artboard/ and https://ai-scripting.docsforadobe.dev/jsobjref/Artboards/ describe them (`docs/mcp.md`); `artboards.add` returns the new artboard and `artboards.insert` returns nothing. Scoped collections support string conversion, which fails for `Layers`, `GroupItems`, `CompoundPathItems` and `Artboards` once their container is gone; a compound path's `pathItems` are `PathItems` objects whose `add()` and shape methods make the new path inside it; `removeAll()` on a compound path's `pathItems` throws when it would empty a compound path that clips a group or layer keeping other objects that are not ruler guides. Empty clipping containers release their masks in the deletion's undo step, and `clipped` changes check the group's, layer's and artboard's locks; turning clipping on also refuses a hidden or locked topmost object, which would become the mask. In a Shaper group, new empty groups and compound paths and turning clipping on are refused, since the group keeps its source art at the bottom. Layer selection changes keep unrelated selected objects, layer colors are assignable `RGBColor` values, stacking scans count toward the script budget, and paths moved into pixel-aligned compound paths are snapped. The `textFrames` of a layer or group list the type directly in it and put new type on top of its contents (VectorCraft's own rule), as https://ai-scripting.docsforadobe.dev/jsobjref/Layer/ and https://ai-scripting.docsforadobe.dev/jsobjref/GroupItem/ list them. `crates/engine/src/tests/script_dom.rs`, `crates/engine/src/tests/script_text.rs`, `crates/ui-egui/src/tests/script_run.rs`.
- Scripts: `Document.print` prints the document to a file with `PrintOptions` and the job, color management, color separation, coordinate, flattener, font, page marks, paper and PostScript option classes the help pages https://ai-scripting.docsforadobe.dev/jsobjref/PrintOptions/ and https://ai-scripting.docsforadobe.dev/jsobjref/PrintJobOptions/ describe, over the document's print settings, and `app.printPresetsList` lists the print presets (`docs/mcp.md`); `CUSTOMPROFILE` without a profile `name` throws. `crates/engine/src/tests/script_print.rs`.
- Scripts: `Document.exportFile` with `ExportType.AutoCAD` writes a DXF file with the `ExportOptionsAutoCAD` options and the AutoCAD enumerations that https://ai-scripting.docsforadobe.dev/jsobjref/ExportOptionsAutoCAD/ and https://ai-scripting.docsforadobe.dev/jsobjref/scripting-constants/ describe; DWG throws an error that says it is not available, and `unitScaleRatio` is a percentage, with 100 at full size (`docs/mcp.md`). `crates/engine/src/tests/script_save_open.rs`.
- Scripts: `Document.print` without a file prints to the printer `PrintOptions.printerName` names, or the default printer, and `app.printerList` lists the installed printers as `Printer` objects, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/PrintOptions/, https://ai-scripting.docsforadobe.dev/jsobjref/Application/ and https://ai-scripting.docsforadobe.dev/jsobjref/Printer/ describe. VectorCraft's own rules: the jobs are sent after the run's changes are kept and the person at the keyboard clicks Print or presses Space on it, which takes no click or focus for the first second, nothing is sent from a failed run, and the web build, and MCP or the command line without the app, cannot print to a printer from a script (`docs/mcp.md`); a batch submitted after a spool failure was reported clears it once the worker sends every job of the batch without a failure, while a failure reported after submission stays. `crates/engine/src/tests/script_print.rs`, `crates/ui-egui/src/tests/script_print.rs`.