mirror of
https://github.com/penpot/penpot.git
synced 2025-03-11 23:31:21 -05: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
|
@ -60,6 +60,7 @@
|
||||||
- Fix clickable area in layers [#1680](https://github.com/penpot/penpot/issues/1680)
|
- Fix clickable area in layers [#1680](https://github.com/penpot/penpot/issues/1680)
|
||||||
- Fix problems with trackpad zoom and scroll in MacOS [#1161](https://github.com/penpot/penpot/issues/1161)
|
- Fix problems with trackpad zoom and scroll in MacOS [#1161](https://github.com/penpot/penpot/issues/1161)
|
||||||
- Fix problem with copy/paste in Safari [#1209](https://github.com/penpot/penpot/issues/1209)
|
- Fix problem with copy/paste in Safari [#1209](https://github.com/penpot/penpot/issues/1209)
|
||||||
|
- Fix paste ordering for frames not being respected [Taiga #3097](https://tree.taiga.io/project/penpot/issue/3097)
|
||||||
|
|
||||||
### :arrow_up: Deps updates
|
### :arrow_up: Deps updates
|
||||||
### :heart: Community contributions by (Thank you!)
|
### :heart: Community contributions by (Thank you!)
|
||||||
|
|
|
@ -81,9 +81,7 @@
|
||||||
shapes
|
shapes
|
||||||
|
|
||||||
(nil? index)
|
(nil? index)
|
||||||
(if (= :frame (:type obj))
|
(conj shapes id)
|
||||||
(into [id] shapes)
|
|
||||||
(conj shapes id))
|
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(cph/insert-at-index shapes index [id]))))
|
(cph/insert-at-index shapes index [id]))))
|
||||||
|
|
|
@ -198,8 +198,7 @@
|
||||||
(assert-page-id changes)
|
(assert-page-id changes)
|
||||||
(let [obj (cond-> obj
|
(let [obj (cond-> obj
|
||||||
(not= index ::undefined)
|
(not= index ::undefined)
|
||||||
(assoc :index index))
|
(assoc ::index index))
|
||||||
|
|
||||||
add-change
|
add-change
|
||||||
{:type :add-obj
|
{:type :add-obj
|
||||||
:id (:id obj)
|
:id (:id obj)
|
||||||
|
|
|
@ -1524,21 +1524,18 @@
|
||||||
;; Calculate position for the pasted elements
|
;; Calculate position for the pasted elements
|
||||||
[frame-id parent-id delta index] (calculate-paste-position state mouse-pos in-viewport?)
|
[frame-id parent-id delta index] (calculate-paste-position state mouse-pos in-viewport?)
|
||||||
|
|
||||||
paste-objects (->> paste-objects
|
process-shape
|
||||||
(d/mapm (fn [_ shape]
|
(fn [_ shape]
|
||||||
(-> shape
|
(-> shape
|
||||||
(assoc :frame-id frame-id)
|
(assoc :frame-id frame-id)
|
||||||
(assoc :parent-id parent-id)
|
(assoc :parent-id parent-id)
|
||||||
|
|
||||||
(cond->
|
|
||||||
;; if foreign instance, detach the shape
|
;; if foreign instance, detach the shape
|
||||||
(foreign-instance? shape paste-objects state)
|
(cond-> (foreign-instance? shape paste-objects state)
|
||||||
(dissoc :component-id
|
(dissoc :component-id :component-file :component-root?
|
||||||
:component-file
|
:remote-synced? :shape-ref :touched))))
|
||||||
:component-root?
|
|
||||||
:remote-synced?
|
paste-objects (->> paste-objects (d/mapm process-shape))
|
||||||
:shape-ref
|
|
||||||
:touched))))))
|
|
||||||
|
|
||||||
all-objects (merge (:objects page) paste-objects)
|
all-objects (merge (:objects page) paste-objects)
|
||||||
|
|
||||||
|
|
|
@ -325,7 +325,7 @@
|
||||||
selected)
|
selected)
|
||||||
|
|
||||||
changes (-> (pcb/empty-changes it page-id)
|
changes (-> (pcb/empty-changes it page-id)
|
||||||
(pcb/add-object shape))]
|
(pcb/add-object shape {:index (when (= :frame (:type shape)) 0)}))]
|
||||||
|
|
||||||
(rx/concat
|
(rx/concat
|
||||||
(rx/of (dch/commit-changes changes)
|
(rx/of (dch/commit-changes changes)
|
||||||
|
|
|
@ -284,15 +284,27 @@
|
||||||
(let [shapes (map (d/getf all-objects) ids)
|
(let [shapes (map (d/getf all-objects) ids)
|
||||||
unames (volatile! (dwc/retrieve-used-names (:objects page)))
|
unames (volatile! (dwc/retrieve-used-names (:objects page)))
|
||||||
update-unames! (fn [new-name] (vswap! unames conj new-name))
|
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)
|
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)]
|
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))
|
init-changes
|
||||||
(-> (pcb/empty-changes it)
|
(-> (pcb/empty-changes it)
|
||||||
(pcb/with-page page)
|
(pcb/with-page page)
|
||||||
(pcb/with-objects all-objects))
|
(pcb/with-objects all-objects))
|
||||||
shapes)
|
|
||||||
(prepare-duplicate-flows shapes page ids-map))))
|
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
|
(defn- prepare-duplicate-change
|
||||||
[changes objects page unames update-unames! ids-map shape delta]
|
[changes objects page unames update-unames! ids-map shape delta]
|
||||||
|
@ -349,7 +361,6 @@
|
||||||
(geom/move delta)
|
(geom/move delta)
|
||||||
(d/update-when :interactions #(cti/remap-interactions % ids-map objects)))
|
(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})
|
changes (-> (pcb/add-object changes new-obj {:ignore-touched true})
|
||||||
(pcb/amend-last-change #(assoc % :old-id (:id obj))))]
|
(pcb/amend-last-change #(assoc % :old-id (:id obj))))]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue