mirror of
https://github.com/penpot/penpot.git
synced 2026-08-01 19:06:18 +00:00
✨ Avoid setting touched flags in copies
This commit is contained in:
parent
8ccd9bedfa
commit
7fbc47ccdb
@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
(defn update-shapes
|
(defn update-shapes
|
||||||
([ids update-fn] (update-shapes ids update-fn nil))
|
([ids update-fn] (update-shapes ids update-fn nil))
|
||||||
([ids update-fn {:keys [reg-objects? save-undo? attrs ignore-tree page-id]
|
([ids update-fn {:keys [reg-objects? save-undo? attrs ignore-tree page-id ignore-touched-fn]
|
||||||
:or {reg-objects? false save-undo? true}}]
|
:or {reg-objects? false save-undo? true}}]
|
||||||
|
|
||||||
(us/assert ::coll-of-uuid ids)
|
(us/assert ::coll-of-uuid ids)
|
||||||
@ -52,7 +52,10 @@
|
|||||||
|
|
||||||
changes (reduce
|
changes (reduce
|
||||||
(fn [changes id]
|
(fn [changes id]
|
||||||
(let [opts {:attrs attrs :ignore-geometry? (get ignore-tree id)}]
|
(let [opts {:attrs attrs
|
||||||
|
:ignore-geometry? (get ignore-tree id)
|
||||||
|
:ignore-touched (when ignore-touched-fn
|
||||||
|
(ignore-touched-fn id))}]
|
||||||
(pcb/update-shapes changes [id] update-fn opts)))
|
(pcb/update-shapes changes [id] update-fn opts)))
|
||||||
(-> (pcb/empty-changes it page-id)
|
(-> (pcb/empty-changes it page-id)
|
||||||
(pcb/set-save-undo? save-undo?)
|
(pcb/set-save-undo? save-undo?)
|
||||||
|
|||||||
@ -78,7 +78,8 @@
|
|||||||
|
|
||||||
(-> (ctm/empty)
|
(-> (ctm/empty)
|
||||||
(ctm/move translation)
|
(ctm/move translation)
|
||||||
(ctm/resize resize center)))))
|
(ctm/resize resize center)
|
||||||
|
(vary-meta assoc :copied-modifier? true)))))
|
||||||
|
|
||||||
(defn- process-text-modifiers
|
(defn- process-text-modifiers
|
||||||
"For texts we only use the displacement because resize
|
"For texts we only use the displacement because resize
|
||||||
@ -379,7 +380,7 @@
|
|||||||
(ptk/reify ::set-rotation-modifiers
|
(ptk/reify ::set-rotation-modifiers
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(let [objects (wsh/lookup-page-objects state)
|
(let [objects (wsh/lookup-page-objects state)
|
||||||
ids
|
ids
|
||||||
(->> shapes
|
(->> shapes
|
||||||
(remove #(get % :blocked false))
|
(remove #(get % :blocked false))
|
||||||
@ -416,25 +417,27 @@
|
|||||||
shapes (map (d/getf objects) ids)
|
shapes (map (d/getf objects) ids)
|
||||||
ignore-tree (->> (map #(get-ignore-tree object-modifiers objects %) shapes)
|
ignore-tree (->> (map #(get-ignore-tree object-modifiers objects %) shapes)
|
||||||
(reduce merge {}))
|
(reduce merge {}))
|
||||||
undo-id (uuid/next)]
|
undo-id (uuid/next)
|
||||||
|
|
||||||
(rx/concat
|
update-fn
|
||||||
(if undo-transation?
|
(fn [shape]
|
||||||
(rx/of (dwu/start-undo-transaction undo-id))
|
(let [modif (get-in object-modifiers [(:id shape) :modifiers])
|
||||||
(rx/empty))
|
text-shape? (cph/text-shape? shape)]
|
||||||
(rx/of (ptk/event ::dwg/move-frame-guides ids-with-children)
|
(-> shape
|
||||||
(ptk/event ::dwcm/move-frame-comment-threads ids-with-children)
|
(gsh/transform-shape modif)
|
||||||
(dch/update-shapes
|
(cond-> text-shape?
|
||||||
ids
|
(update-grow-type shape)))))
|
||||||
(fn [shape]
|
|
||||||
(let [modif (get-in object-modifiers [(:id shape) :modifiers])
|
ignore-touched-fn
|
||||||
text-shape? (cph/text-shape? shape)]
|
(fn [shape-id]
|
||||||
(-> shape
|
;; When a modifier comes from copying a main component to copies,
|
||||||
(gsh/transform-shape modif)
|
;; do not set the touched flag, because this change is synced.
|
||||||
(cond-> text-shape?
|
(let [modif (get-in object-modifiers [shape-id :modifiers])]
|
||||||
(update-grow-type shape)))))
|
(:copied-modifier? (meta modif))))
|
||||||
{:reg-objects? true
|
|
||||||
|
opts {:reg-objects? true
|
||||||
:ignore-tree ignore-tree
|
:ignore-tree ignore-tree
|
||||||
|
:ignore-touched-fn ignore-touched-fn
|
||||||
;; Attributes that can change in the transform. This way we don't have to check
|
;; Attributes that can change in the transform. This way we don't have to check
|
||||||
;; all the attributes
|
;; all the attributes
|
||||||
:attrs [:selrect
|
:attrs [:selrect
|
||||||
@ -451,8 +454,15 @@
|
|||||||
:flip-y
|
:flip-y
|
||||||
:grow-type
|
:grow-type
|
||||||
:layout-item-h-sizing
|
:layout-item-h-sizing
|
||||||
:layout-item-v-sizing
|
:layout-item-v-sizing]}]
|
||||||
]})
|
|
||||||
|
(rx/concat
|
||||||
|
(if undo-transation?
|
||||||
|
(rx/of (dwu/start-undo-transaction undo-id))
|
||||||
|
(rx/empty))
|
||||||
|
(rx/of (ptk/event ::dwg/move-frame-guides ids-with-children)
|
||||||
|
(ptk/event ::dwcm/move-frame-comment-threads ids-with-children)
|
||||||
|
(dch/update-shapes ids update-fn opts)
|
||||||
(clear-local-transform))
|
(clear-local-transform))
|
||||||
(if undo-transation?
|
(if undo-transation?
|
||||||
(rx/of (dwu/commit-undo-transaction undo-id))
|
(rx/of (dwu/commit-undo-transaction undo-id))
|
||||||
|
|||||||
@ -683,7 +683,7 @@
|
|||||||
(rx/map
|
(rx/map
|
||||||
(fn [[[pos mod?] shift?]]
|
(fn [[[pos mod?] shift?]]
|
||||||
(let [delta-angle (calculate-angle pos mod? shift?)]
|
(let [delta-angle (calculate-angle pos mod? shift?)]
|
||||||
(set-rotation-modifiers delta-angle shapes group-center))))
|
(dwm/set-rotation-modifiers delta-angle shapes group-center))))
|
||||||
(rx/take-until stoper))
|
(rx/take-until stoper))
|
||||||
(rx/of (dwm/apply-modifiers)
|
(rx/of (dwm/apply-modifiers)
|
||||||
(finish-transform)))))))
|
(finish-transform)))))))
|
||||||
@ -699,7 +699,7 @@
|
|||||||
objects (wsh/lookup-page-objects state page-id)
|
objects (wsh/lookup-page-objects state page-id)
|
||||||
rotate-shape (fn [shape]
|
rotate-shape (fn [shape]
|
||||||
(let [delta (- rotation (:rotation shape))]
|
(let [delta (- rotation (:rotation shape))]
|
||||||
(set-rotation-modifiers delta [shape])))]
|
(dwm/set-rotation-modifiers delta [shape])))]
|
||||||
(rx/concat
|
(rx/concat
|
||||||
(rx/from (->> ids (map #(get objects %)) (map rotate-shape)))
|
(rx/from (->> ids (map #(get objects %)) (map rotate-shape)))
|
||||||
(rx/of (dwm/apply-modifiers)))))))
|
(rx/of (dwm/apply-modifiers)))))))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user