mirror of
https://github.com/penpot/penpot.git
synced 2025-03-11 07:11:32 -05: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
|
# 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
|
## 1.17.2
|
||||||
|
|
||||||
### :bug: Bugs fixed
|
### :bug: Bugs fixed
|
||||||
|
@ -8,10 +13,6 @@
|
||||||
- Fix correct behaviour for space-around and added space-evenly option
|
- 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 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)
|
- 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 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)
|
- 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))
|
(and (= 1 (count selected))
|
||||||
(= :frame (get-in objects [(first selected) :type])))))
|
(= :frame (get-in objects [(first selected) :type])))))
|
||||||
|
|
||||||
(defn same-frame-from-selected? [state frame-id]
|
(defn get-tree-root-shapes [tree]
|
||||||
(let [selected (wsh/lookup-selected state)]
|
;; This fn gets a map of shapes and finds what shapes are parent of the rest
|
||||||
(contains? frame-id (first selected))))
|
(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?
|
(defn frame-same-size?
|
||||||
[paste-obj frame-obj]
|
[paste-obj frame-obj]
|
||||||
|
@ -1500,13 +1508,18 @@
|
||||||
frame-id (first page-selected)
|
frame-id (first page-selected)
|
||||||
frame-object (get page-objects frame-id)
|
frame-object (get page-objects frame-id)
|
||||||
base (cph/get-base-shape page-objects page-selected)
|
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
|
(cond
|
||||||
(selected-frame? state)
|
(selected-frame? state)
|
||||||
|
|
||||||
(if (or (same-frame-from-selected? state (first (vals paste-objects)))
|
(if (or (any-same-frame-from-selected? state (keys paste-objects))
|
||||||
(frame-same-size? paste-objects frame-object))
|
(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
|
;; 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))
|
(let [selected-frame-obj (get page-objects (first page-selected))
|
||||||
parent-id (:parent-id base)
|
parent-id (:parent-id base)
|
||||||
|
|
Loading…
Add table
Reference in a new issue