mirror of
https://github.com/penpot/penpot.git
synced 2025-12-11 22:14:05 +01:00
🐛 Fix problem when pasting elements in reverse flex layout
Some checks failed
_DEVELOP / build-bundle (push) Has been cancelled
_DEVELOP / build-docker (push) Has been cancelled
_STAGING / build-bundle (push) Has been cancelled
_STAGING / build-docker (push) Has been cancelled
Commit Message Check / Check Commit Message (push) Has been cancelled
CI / Code Linter (push) Has been cancelled
CI / Common Tests (push) Has been cancelled
CI / Frontend Tests (push) Has been cancelled
CI / Render WASM Tests (push) Has been cancelled
CI / Backend Tests (push) Has been cancelled
CI / Library Tests (push) Has been cancelled
CI / Build Integration Bundle (push) Has been cancelled
CI / Integration Tests 1/4 (push) Has been cancelled
CI / Integration Tests 2/4 (push) Has been cancelled
CI / Integration Tests 3/4 (push) Has been cancelled
Some checks failed
_DEVELOP / build-bundle (push) Has been cancelled
_DEVELOP / build-docker (push) Has been cancelled
_STAGING / build-bundle (push) Has been cancelled
_STAGING / build-docker (push) Has been cancelled
Commit Message Check / Check Commit Message (push) Has been cancelled
CI / Code Linter (push) Has been cancelled
CI / Common Tests (push) Has been cancelled
CI / Frontend Tests (push) Has been cancelled
CI / Render WASM Tests (push) Has been cancelled
CI / Backend Tests (push) Has been cancelled
CI / Library Tests (push) Has been cancelled
CI / Build Integration Bundle (push) Has been cancelled
CI / Integration Tests 1/4 (push) Has been cancelled
CI / Integration Tests 2/4 (push) Has been cancelled
CI / Integration Tests 3/4 (push) Has been cancelled
This commit is contained in:
committed by
Andrey Antukh
parent
6611fbd13b
commit
c2014a37b4
@@ -13,6 +13,7 @@
|
|||||||
### :bug: Bugs fixed
|
### :bug: Bugs fixed
|
||||||
|
|
||||||
- Fix problem when drag+duplicate a full grid [Taiga #12565](https://tree.taiga.io/project/penpot/issue/12565)
|
- Fix problem when drag+duplicate a full grid [Taiga #12565](https://tree.taiga.io/project/penpot/issue/12565)
|
||||||
|
- Fix problem when pasting elements in reverse flex layout [Taiga #12460](https://tree.taiga.io/project/penpot/issue/12460)
|
||||||
|
|
||||||
|
|
||||||
## 2.12.0 (Unreleased)
|
## 2.12.0 (Unreleased)
|
||||||
|
|||||||
@@ -706,53 +706,58 @@
|
|||||||
(= 1 (count tree-root)))]
|
(= 1 (count tree-root)))]
|
||||||
|
|
||||||
(cond
|
(cond
|
||||||
|
;; Paste next to selected frame, if selected is itself or of the same size as the copied
|
||||||
|
(and (selected-frame? state)
|
||||||
|
(or (any-same-frame-from-selected? state (keys pobjects))
|
||||||
|
(and only-one-root-shape?
|
||||||
|
(frame-same-size? pobjects (first tree-root)))))
|
||||||
|
(let [selected-frame-obj (get page-objects (first page-selected))
|
||||||
|
parent-id (:parent-id base)
|
||||||
|
paste-x (+ (:width selected-frame-obj) (:x selected-frame-obj) 50)
|
||||||
|
paste-y (:y selected-frame-obj)
|
||||||
|
delta (gpt/subtract (gpt/point paste-x paste-y) orig-pos)]
|
||||||
|
|
||||||
|
[parent-id delta index])
|
||||||
|
|
||||||
|
;; Paste inside selected frame otherwise
|
||||||
(selected-frame? state)
|
(selected-frame? state)
|
||||||
|
(let [selected-frame-obj (get page-objects (first page-selected))
|
||||||
|
origin-frame-id (:frame-id first-selected-obj)
|
||||||
|
origin-frame-object (get page-objects origin-frame-id)
|
||||||
|
|
||||||
(if (or (any-same-frame-from-selected? state (keys pobjects))
|
margin-x (-> (- (:width origin-frame-object) (+ (:x wrapper) (:width wrapper)))
|
||||||
(and only-one-root-shape?
|
(min (- (:width frame-object) (:width wrapper))))
|
||||||
(frame-same-size? pobjects (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)
|
|
||||||
paste-x (+ (:width selected-frame-obj) (:x selected-frame-obj) 50)
|
|
||||||
paste-y (:y selected-frame-obj)
|
|
||||||
delta (gpt/subtract (gpt/point paste-x paste-y) orig-pos)]
|
|
||||||
|
|
||||||
[parent-id delta index])
|
margin-y (-> (- (:height origin-frame-object) (+ (:y wrapper) (:height wrapper)))
|
||||||
|
(min (- (:height frame-object) (:height wrapper))))
|
||||||
|
|
||||||
;; Paste inside selected frame otherwise
|
;; Pasted objects mustn't exceed the selected frame x limit
|
||||||
(let [selected-frame-obj (get page-objects (first page-selected))
|
paste-x (if (> (+ (:width wrapper) (:x1 wrapper)) (:width frame-object))
|
||||||
origin-frame-id (:frame-id first-selected-obj)
|
(+ (- (:x frame-object) (:x orig-pos)) (- (:width frame-object) (:width wrapper) margin-x))
|
||||||
origin-frame-object (get page-objects origin-frame-id)
|
(:x frame-object))
|
||||||
|
|
||||||
margin-x (-> (- (:width origin-frame-object) (+ (:x wrapper) (:width wrapper)))
|
;; Pasted objects mustn't exceed the selected frame y limit
|
||||||
(min (- (:width frame-object) (:width wrapper))))
|
paste-y (if (> (+ (:height wrapper) (:y1 wrapper)) (:height frame-object))
|
||||||
|
(+ (- (:y frame-object) (:y orig-pos)) (- (:height frame-object) (:height wrapper) margin-y))
|
||||||
|
(:y frame-object))
|
||||||
|
|
||||||
margin-y (-> (- (:height origin-frame-object) (+ (:y wrapper) (:height wrapper)))
|
delta (if (= origin-frame-id uuid/zero)
|
||||||
(min (- (:height frame-object) (:height wrapper))))
|
;; When the origin isn't in a frame the result is pasted in the center.
|
||||||
|
(gpt/subtract (gsh/shape->center frame-object) (grc/rect->center wrapper))
|
||||||
|
;; When pasting from one frame to another frame the object
|
||||||
|
;; position must be limited to container boundaries. If
|
||||||
|
;; the pasted object doesn't fit we try to:
|
||||||
|
;;
|
||||||
|
;; - Align it to the limits on the x and y axis
|
||||||
|
;; - Respect the distance of the object to the right
|
||||||
|
;; and bottom in the original frame
|
||||||
|
(gpt/point paste-x paste-y))
|
||||||
|
|
||||||
;; Pasted objects mustn't exceed the selected frame x limit
|
target-index
|
||||||
paste-x (if (> (+ (:width wrapper) (:x1 wrapper)) (:width frame-object))
|
(if (and (ctl/flex-layout? selected-frame-obj) (ctl/reverse? selected-frame-obj))
|
||||||
(+ (- (:x frame-object) (:x orig-pos)) (- (:width frame-object) (:width wrapper) margin-x))
|
(dec 0) ;; Before the first index 0
|
||||||
(:x frame-object))
|
(count (:shapes selected-frame-obj)))]
|
||||||
|
[frame-id delta target-index])
|
||||||
;; Pasted objects mustn't exceed the selected frame y limit
|
|
||||||
paste-y (if (> (+ (:height wrapper) (:y1 wrapper)) (:height frame-object))
|
|
||||||
(+ (- (:y frame-object) (:y orig-pos)) (- (:height frame-object) (:height wrapper) margin-y))
|
|
||||||
(:y frame-object))
|
|
||||||
|
|
||||||
delta (if (= origin-frame-id uuid/zero)
|
|
||||||
;; When the origin isn't in a frame the result is pasted in the center.
|
|
||||||
(gpt/subtract (gsh/shape->center frame-object) (grc/rect->center wrapper))
|
|
||||||
;; When pasting from one frame to another frame the object
|
|
||||||
;; position must be limited to container boundaries. If
|
|
||||||
;; the pasted object doesn't fit we try to:
|
|
||||||
;;
|
|
||||||
;; - Align it to the limits on the x and y axis
|
|
||||||
;; - Respect the distance of the object to the right
|
|
||||||
;; and bottom in the original frame
|
|
||||||
(gpt/point paste-x paste-y))]
|
|
||||||
[frame-id delta (dec (count (:shapes selected-frame-obj)))]))
|
|
||||||
|
|
||||||
(empty? page-selected)
|
(empty? page-selected)
|
||||||
(let [frame-id (ctst/top-nested-frame page-objects position)
|
(let [frame-id (ctst/top-nested-frame page-objects position)
|
||||||
|
|||||||
Reference in New Issue
Block a user