diff --git a/common/src/app/common/files/changes_builder.cljc b/common/src/app/common/files/changes_builder.cljc index 1e71d05b4d..3317d91653 100644 --- a/common/src/app/common/files/changes_builder.cljc +++ b/common/src/app/common/files/changes_builder.cljc @@ -187,7 +187,8 @@ (assert (check-changes changes) "expected valid changes") - (if-let [file-data (::file-data (meta changes))] + (if-let [file-data (and (not (::skip-local? (meta changes))) + (::file-data (meta changes)))] (let [library-data (::library-data (meta changes)) index (::applied-changes-count (meta changes)) redo-changes (:redo-changes changes) @@ -206,6 +207,11 @@ ::applied-changes-count (count redo-changes))) changes)) +(defn skip-local + "Stop applying changes to the builder objects." + [changes skip?] + (vary-meta changes assoc ::skip-local? skip?)) + (defn- without-changes-local "Append changes through `f` without applying them to the mounted page's working state." diff --git a/frontend/src/app/main/data/workspace/shapes.cljs b/frontend/src/app/main/data/workspace/shapes.cljs index 0b195be68b..587956c084 100644 --- a/frontend/src/app/main/data/workspace/shapes.cljs +++ b/frontend/src/app/main/data/workspace/shapes.cljs @@ -184,6 +184,26 @@ ::update-shapes-buffer-event)))) (rx/empty))))))) +(defn- any-group-like? + "Whether any of `ids` or their ancestors is group-like." + [objects ids] + (let [cache (js/Map.) + group-like? + (fn group-like? [id] + (let [cached (.get cache id)] + (if (some? cached) + cached + (let [shape (get objects id) + parent-id (:parent-id shape) + result (boolean + (or (cfh/group-like-shape? shape) + (and (some? parent-id) + (not= parent-id id) + (group-like? parent-id))))] + (.set cache id result) + result))))] + (boolean (some group-like? ids)))) + (defn update-shapes ([ids update-fn] (update-shapes ids update-fn nil)) @@ -212,10 +232,15 @@ objects (dsh/lookup-page-objects state page-id) ids (into [] (filter some?) ids) + ;; Parent resizing only reads the builder objects for groups + skip-local? + (and translation? (not (any-group-like? objects ids))) + changes (-> (pcb/empty-changes it page-id) (pcb/set-save-undo? save-undo?) (pcb/set-stack-undo? stack-undo?) + (pcb/skip-local skip-local?) (cls/generate-update-shapes ids update-fn objects