💄 Add cosmetic changes to common libraries logic ns

This commit is contained in:
Andrey Antukh 2025-01-16 13:19:27 +01:00
parent e7b0e253d4
commit 12fa4fdef5

View file

@ -204,21 +204,23 @@
(cond-> {} (cond-> {}
force-frame? (assoc :force-frame-id frame-id))) force-frame? (assoc :force-frame-id frame-id)))
first-shape (cond-> (first new-shapes) first-shape
(not (nil? parent-id)) (cond-> (first new-shapes)
(assoc :parent-id parent-id) (not (nil? parent-id))
(and (not (nil? parent)) (= :frame (:type parent))) (assoc :parent-id parent-id)
(assoc :frame-id (:id parent)) (and (not (nil? parent)) (= :frame (:type parent)))
(and (not (nil? parent)) (not= :frame (:type parent))) (assoc :frame-id (:id parent))
(assoc :frame-id (:frame-id parent)) (and (not (nil? parent)) (not= :frame (:type parent)))
(and (not (nil? parent)) (ctn/in-any-component? objects parent)) (assoc :frame-id (:frame-id parent))
(dissoc :component-root) (and (not (nil? parent)) (ctn/in-any-component? objects parent))
(and (nil? parent) (not (nil? frame-id))) (dissoc :component-root)
(assoc :frame-id frame-id)) (and (nil? parent) (not (nil? frame-id)))
(assoc :frame-id frame-id))
;; on copy/paste old id is used later to reorder the paster layers ;; on copy/paste old id is used later to reorder the paster layers
changes (cond-> (pcb/add-object changes first-shape {:ignore-touched true}) changes
(some? old-id) (pcb/amend-last-change #(assoc % :old-id old-id))) (cond-> (pcb/add-object changes first-shape {:ignore-touched true})
(some? old-id) (pcb/amend-last-change #(assoc % :old-id old-id)))
changes changes
(if (ctl/grid-layout? objects (:parent-id first-shape)) (if (ctl/grid-layout? objects (:parent-id first-shape))
@ -239,9 +241,10 @@
(pcb/reorder-grid-children [(:parent-id first-shape)]))) (pcb/reorder-grid-children [(:parent-id first-shape)])))
changes) changes)
changes (reduce #(pcb/add-object %1 %2 {:ignore-touched true}) changes
changes (reduce #(pcb/add-object %1 %2 {:ignore-touched true})
(rest new-shapes))] changes
(rest new-shapes))]
[new-shape changes]))) [new-shape changes])))
@ -1487,7 +1490,7 @@
(defn- update-tokens (defn- update-tokens
"Token synchronization algorithm. Copy the applied tokens that have changed "Token synchronization algorithm. Copy the applied tokens that have changed
in the origin shape to the dest shape (applying or removing as necessary). in the origin shape to the dest shape (applying or removing as necessary).
Only the given token attributes are synced." Only the given token attributes are synced."
[changes container dest-shape orig-shape token-attrs] [changes container dest-shape orig-shape token-attrs]
(let [orig-tokens (get orig-shape :applied-tokens {}) (let [orig-tokens (get orig-shape :applied-tokens {})