✨ Generate ungroups of shapes a main holds

The shape structure property now ungroups groups, bools and boards a
main holds, as the ungroup changes keep the copies valid, and the
structure node passes the file's pages to them. A grouping that takes
every child out of a group, which removes it as well, stays out.

Harness only; the benchmark is not run.

AI-assisted-by: claude-opus-5-5
This commit is contained in:
alonso.torres 2026-11-12 10:26:29 +01:00
parent 59e8da6070
commit 4fba88d567
2 changed files with 5 additions and 5 deletions

View File

@ -2294,7 +2294,8 @@
(:id page) shapes "Group" false)))
:mask (let [shapes (clg/shapes-for-group-or-mask objects ids)]
(second (clg/generate-mask-changes nil (uuid/next) (:id page) objects shapes)))
:ungroup (clg/generate-ungroup-changes nil (:id page) objects (clg/ungroup-ids objects ids))
:ungroup (clg/generate-ungroup-changes nil (:id page) objects (clg/ungroup-ids objects ids)
(get-in the-file [:data :pages-index]))
:unmask (clg/generate-unmask-changes nil (:id page) objects ids)
:bool (second (clb/generate-create-bool nil (:id page) objects ids (:bool-type params) nil))
:path (-> (pcb/empty-changes nil (:id page))

View File

@ -620,14 +620,13 @@
(get shapes (inc index)))
pair (cond-> [(:id shape)]
(and (odd? (or value 0)) sibling (contains? eligible sibling)) (conj sibling))
;; removing a shape a main holds leaves its copies referring to it
;; until sync, so no edit removes one: no ungroup, and no grouping
;; that takes every child out of a group
;; a grouping that takes every child out of a group removes it
;; and leaves its copies referring to it until sync
empties? (and (#{:group :bool} (:type parent)) (= (set pair) (set (:shapes parent))))
targets (case action
(:group :mask) (when-not empties? pair)
:bool (when (not-any? #(= :text (:type (get objects %))) pair) pair)
:ungroup nil
:ungroup (when (#{:group :bool :frame} (:type shape)) [(:id shape)])
:unmask (when (:masked-group shape) [(:id shape)])
:path (when (#{:rect :circle} (:type shape)) [(:id shape)]))]
(when targets