mirror of
https://github.com/penpot/penpot.git
synced 2025-05-20 07:06:13 +02:00
🐛 Fix paste ordering for frames not being respected
This commit is contained in:
parent
e8980fbbfe
commit
5a591d2acd
6 changed files with 37 additions and 31 deletions
|
@ -1437,7 +1437,7 @@
|
|||
(calculate-paste-position [state mouse-pos in-viewport?]
|
||||
(let [page-objects (wsh/lookup-page-objects state)
|
||||
selected-objs (map #(get paste-objects %) selected)
|
||||
has-frame? (d/seek #(= (:type %) :frame) selected-objs)
|
||||
has-frame? (d/seek #(= (:type %) :frame) selected-objs)
|
||||
page-selected (wsh/lookup-selected state)
|
||||
wrapper (gsh/selection-rect selected-objs)
|
||||
orig-pos (gpt/point (:x1 wrapper) (:y1 wrapper))]
|
||||
|
@ -1524,21 +1524,18 @@
|
|||
;; Calculate position for the pasted elements
|
||||
[frame-id parent-id delta index] (calculate-paste-position state mouse-pos in-viewport?)
|
||||
|
||||
paste-objects (->> paste-objects
|
||||
(d/mapm (fn [_ shape]
|
||||
(-> shape
|
||||
(assoc :frame-id frame-id)
|
||||
(assoc :parent-id parent-id)
|
||||
process-shape
|
||||
(fn [_ shape]
|
||||
(-> shape
|
||||
(assoc :frame-id frame-id)
|
||||
(assoc :parent-id parent-id)
|
||||
|
||||
(cond->
|
||||
;; if foreign instance, detach the shape
|
||||
(foreign-instance? shape paste-objects state)
|
||||
(dissoc :component-id
|
||||
:component-file
|
||||
:component-root?
|
||||
:remote-synced?
|
||||
:shape-ref
|
||||
:touched))))))
|
||||
;; if foreign instance, detach the shape
|
||||
(cond-> (foreign-instance? shape paste-objects state)
|
||||
(dissoc :component-id :component-file :component-root?
|
||||
:remote-synced? :shape-ref :touched))))
|
||||
|
||||
paste-objects (->> paste-objects (d/mapm process-shape))
|
||||
|
||||
all-objects (merge (:objects page) paste-objects)
|
||||
|
||||
|
|
|
@ -325,7 +325,7 @@
|
|||
selected)
|
||||
|
||||
changes (-> (pcb/empty-changes it page-id)
|
||||
(pcb/add-object shape))]
|
||||
(pcb/add-object shape {:index (when (= :frame (:type shape)) 0)}))]
|
||||
|
||||
(rx/concat
|
||||
(rx/of (dch/commit-changes changes)
|
||||
|
|
|
@ -284,15 +284,27 @@
|
|||
(let [shapes (map (d/getf all-objects) ids)
|
||||
unames (volatile! (dwc/retrieve-used-names (:objects page)))
|
||||
update-unames! (fn [new-name] (vswap! unames conj new-name))
|
||||
all-ids (reduce #(into %1 (cons %2 (cph/get-children-ids all-objects %2))) #{} ids)
|
||||
ids-map (into {} (map #(vector % (uuid/next))) all-ids)]
|
||||
(-> (reduce (fn [changes shape]
|
||||
(prepare-duplicate-change changes all-objects page unames update-unames! ids-map shape delta))
|
||||
(-> (pcb/empty-changes it)
|
||||
(pcb/with-page page)
|
||||
(pcb/with-objects all-objects))
|
||||
shapes)
|
||||
(prepare-duplicate-flows shapes page ids-map))))
|
||||
all-ids (reduce #(into %1 (cons %2 (cph/get-children-ids all-objects %2))) (d/ordered-set) ids)
|
||||
ids-map (into {} (map #(vector % (uuid/next))) all-ids)
|
||||
|
||||
init-changes
|
||||
(-> (pcb/empty-changes it)
|
||||
(pcb/with-page page)
|
||||
(pcb/with-objects all-objects))
|
||||
|
||||
changes
|
||||
(->> shapes
|
||||
(reduce #(prepare-duplicate-change %1
|
||||
all-objects
|
||||
page
|
||||
unames
|
||||
update-unames!
|
||||
ids-map
|
||||
%2
|
||||
delta)
|
||||
init-changes))]
|
||||
|
||||
(prepare-duplicate-flows changes shapes page ids-map)))
|
||||
|
||||
(defn- prepare-duplicate-change
|
||||
[changes objects page unames update-unames! ids-map shape delta]
|
||||
|
@ -349,7 +361,6 @@
|
|||
(geom/move delta)
|
||||
(d/update-when :interactions #(cti/remap-interactions % ids-map objects)))
|
||||
|
||||
changes (pcb/add-object changes new-obj {:ignore-touched true})
|
||||
changes (-> (pcb/add-object changes new-obj {:ignore-touched true})
|
||||
(pcb/amend-last-change #(assoc % :old-id (:id obj))))]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue