Scripts: reject protected page-item mutations

This commit is contained in:
dotCooCoo
2026-11-26 08:35:37 -08:00
parent f040538a39
commit f4704bb688
4 changed files with 77 additions and 14 deletions
+4 -2
View File
@@ -2809,12 +2809,14 @@ other files through `$`:
the undo history as they were before the call. `move` on an object that is hidden or locked, inside a hidden or
locked layer or group, or on a locked artboard throws `Cannot move` and moves nothing. `duplicate` on such an
object, with or without a relative object, throws `Cannot duplicate` and makes no copy. Assigning `hidden`,
`locked`, `opacity`, `position`, `left`, `top`, `width` or `height` to an object in a hidden or locked layer
`locked`, `opacity`, `position`, `left`, `top`, `width` or `height` to an object in a hidden or locked layer or on a locked artboard
throws `Cannot edit` and changes nothing, even when the value is the one the object has, and `zOrder()` on such
an object throws `Cannot edit` too. The one exception is `opacity` given the value the object already has, which
changes nothing and does not throw; on a graph's mark or label whose series or kind keeps another opacity, that
value would still change the graph, so it throws `Cannot edit` as well. Its `name` and `note` still change, and an
object that is hidden or locked itself takes all of them (VectorCraft's own rule). `move` with the object itself
object that is hidden or locked itself takes `hidden`, `locked` and `opacity` (VectorCraft's own rule). Position,
size and stacking-order changes also require a selectable object. Other targets excluded by selection filtering,
including guide paths while Lock Guides is on, throw `Cannot select`. `move` with the object itself
as the relative object and `PLACEBEFORE` or `PLACEAFTER` leaves it where it is and adds no undo step. When `move`
or `remove()` takes the last path out of a compound path, the compound path stays, empty, so a script that holds
it can still read it (`remove()` runs `edit.clear` with `keepEmpty: true`). An object with nothing in it, such
+2
View File
@@ -34,6 +34,8 @@
History panel row context menus (2026-11-20, G12): Right-clicking any state offers New Document from State, Step to This State, and Clear History. Creating a document uses the clicked snapshot without stepping the source document; Step to This State uses undo/redo and is disabled on the current row; Clear History removes undo and redo steps without changing artwork and is disabled when history is empty. Headless tests in `crates/ui-egui/src/panels/history.rs` cover opening an earlier row menu, snapshot creation, backward/forward jumps, and clearing history. The snapshot chosen when the menu opens is retained while it stays open; pending tool edits are settled before resolving that snapshot to its new row; a discarded snapshot reports that it is unavailable instead of acting on a neighboring row. Jumps settle pending typing before counting undo/redo steps. Shift+F10 opens the focused row menu; Escape dismisses it and restores row focus. Switching documents dismisses the menu before it can act on another document. Headless tests cover these keyboard and document-switch paths. The list and menu use shared Craft UI controls. Scores and estimates unchanged.
Script appearance and geometry setters reject objects on locked artboards. Position, size and stacking-order setters also reject objects excluded by selection filtering, including locked guide paths. `crates/engine/src/tests/script_dom.rs` covers refused edits, unchanged documents and undo history, and editing a guide after unlocking it.
Variables panel row context menus (2026-11-20, G12): Right-click highlights the clicked variable without changing the canvas selection and offers Select Bound Object, Variable Options…, Unbind Variable, the four Make Dynamic actions, and Delete Variable. Shift+F10 opens the same menu for the focused row; Escape dismisses it. Row actions target that variable; dynamic actions use the canvas selection. Lock and selection checks disable unavailable actions. Headless pointer/accessibility tests cover opening the menu, highlighting, bound-object selection, deletion in one undo step and restoration, and disabled actions. Scores and estimates unchanged.
Actions panel item context menus (2026-11-20): Right-clicking an Action Set row selects it and presents a context menu with New Action…, New Set…, Duplicate Set, Delete Set, and Set Options…. Right-clicking an Action row selects it and presents a context menu with Play, Record, Duplicate, Delete, Action Options…, and Batch…. Duplicate on an action duplicates that action and selects the duplicate; Delete removes it. Headless tests in `crates/ui-egui/src/panels/actions.rs`: `right_clicking_an_action_set_selects_it_and_presents_set_context_options`, `right_clicking_an_action_selects_it_and_presents_action_options`, and `clicking_duplicate_on_an_action_duplicates_that_action_in_the_set`. Scores and estimates unchanged.