mirror of
https://github.com/penpot/penpot.git
synced 2025-05-19 11:56:45 +02:00
🐛 Fix copy paste a very nested boards inside itself
This commit is contained in:
parent
47481986a1
commit
8f2e3d5fe4
2 changed files with 53 additions and 39 deletions
|
@ -1,4 +1,9 @@
|
|||
# CHANGELOG
|
||||
## 1.17.3
|
||||
|
||||
### :bug: Bugs fixed
|
||||
- Fix copy and paste very nested inside itself [Taiga #4848](https://tree.taiga.io/project/penpot/issue/4848)
|
||||
|
||||
## 1.17.2
|
||||
|
||||
### :bug: Bugs fixed
|
||||
|
@ -8,10 +13,6 @@
|
|||
- Fix correct behaviour for space-around and added space-evenly option
|
||||
- Fix duplicate with alt and undo only undo one step [Taiga #4746](https://tree.taiga.io/project/penpot/issue/4746)
|
||||
- Fix problem creating frames inside layout [Taiga #4844](https://tree.taiga.io/project/penpot/issue/4844)
|
||||
|
||||
## 1.17.2
|
||||
|
||||
### :bug: Bugs fixed
|
||||
- Fix paste board inside itself [Taiga #4775](https://tree.taiga.io/project/penpot/issue/4775)
|
||||
- Fix middle button panning can drag guides [Taiga #4266](https://tree.taiga.io/project/penpot/issue/4266)
|
||||
|
||||
|
|
|
@ -1440,9 +1440,17 @@
|
|||
(and (= 1 (count selected))
|
||||
(= :frame (get-in objects [(first selected) :type])))))
|
||||
|
||||
(defn same-frame-from-selected? [state frame-id]
|
||||
(let [selected (wsh/lookup-selected state)]
|
||||
(contains? frame-id (first selected))))
|
||||
(defn get-tree-root-shapes [tree]
|
||||
;; This fn gets a map of shapes and finds what shapes are parent of the rest
|
||||
(let [shapes-in-tree (vals tree)
|
||||
shape-ids (keys tree)
|
||||
parent-ids (set (map #(:parent-id %) shapes-in-tree))]
|
||||
(->> shape-ids
|
||||
(filter #(contains? parent-ids %)))))
|
||||
|
||||
(defn any-same-frame-from-selected? [state frame-ids]
|
||||
(let [selected (first (wsh/lookup-selected state))]
|
||||
(< 0 (count (filter #(= % selected) frame-ids)))))
|
||||
|
||||
(defn frame-same-size?
|
||||
[paste-obj frame-obj]
|
||||
|
@ -1500,13 +1508,18 @@
|
|||
frame-id (first page-selected)
|
||||
frame-object (get page-objects frame-id)
|
||||
base (cph/get-base-shape page-objects page-selected)
|
||||
index (cph/get-position-on-parent page-objects (:id base))]
|
||||
index (cph/get-position-on-parent page-objects (:id base))
|
||||
tree-root (get-tree-root-shapes paste-objects)
|
||||
only-one-root-shape? (and
|
||||
(< 1 (count paste-objects))
|
||||
(= 1 (count tree-root)))]
|
||||
|
||||
(cond
|
||||
(selected-frame? state)
|
||||
|
||||
(if (or (same-frame-from-selected? state (first (vals paste-objects)))
|
||||
(frame-same-size? paste-objects frame-object))
|
||||
(if (or (any-same-frame-from-selected? state (keys paste-objects))
|
||||
(and only-one-root-shape?
|
||||
(frame-same-size? paste-objects (first tree-root))))
|
||||
;; Paste next to selected frame, if selected is itself or of the same size as the copied
|
||||
(let [selected-frame-obj (get page-objects (first page-selected))
|
||||
parent-id (:parent-id base)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue