mirror of
https://github.com/penpot/penpot.git
synced 2025-03-11 23:31:21 -05:00
🐛 Fix problem with changes files
This commit is contained in:
parent
c17d2c1aba
commit
9f6b82dfc0
2 changed files with 59 additions and 51 deletions
|
@ -41,7 +41,9 @@
|
||||||
(let [changes (empty-changes origin)]
|
(let [changes (empty-changes origin)]
|
||||||
(with-meta changes
|
(with-meta changes
|
||||||
{::page-id page-id})))
|
{::page-id page-id})))
|
||||||
|
([]
|
||||||
|
{:redo-changes []
|
||||||
|
:undo-changes '()})
|
||||||
([origin]
|
([origin]
|
||||||
{:redo-changes []
|
{:redo-changes []
|
||||||
:undo-changes '()
|
:undo-changes '()
|
||||||
|
@ -109,13 +111,9 @@
|
||||||
|
|
||||||
(defn concat-changes
|
(defn concat-changes
|
||||||
[changes1 changes2]
|
[changes1 changes2]
|
||||||
{:redo-changes (d/concat-vec (:redo-changes changes1)
|
(-> changes1
|
||||||
(:redo-changes changes2))
|
(update :redo-changes d/concat-vec (:redo-changes changes2))
|
||||||
:undo-changes (concat (:undo-changes changes1)
|
(update :undo-changes d/concat-vec (:undo-changes changes2))))
|
||||||
(:undo-changes changes2))
|
|
||||||
:origin (:origin changes1)
|
|
||||||
:undo-group (:undo-group changes1)
|
|
||||||
:tags (:tags changes1)})
|
|
||||||
|
|
||||||
; TODO: remove this when not needed
|
; TODO: remove this when not needed
|
||||||
(defn- assert-page-id!
|
(defn- assert-page-id!
|
||||||
|
|
|
@ -1393,30 +1393,35 @@
|
||||||
(defn- update-flex-child-copy-attrs
|
(defn- update-flex-child-copy-attrs
|
||||||
"Synchronizes the attributes inside the flex-child items (main->copy)"
|
"Synchronizes the attributes inside the flex-child items (main->copy)"
|
||||||
[changes _shape-main shape-copy main-container main-component copy-container omit-touched?]
|
[changes _shape-main shape-copy main-container main-component copy-container omit-touched?]
|
||||||
(-> changes
|
(let [do-changes
|
||||||
(pcb/with-container copy-container)
|
(fn [cc]
|
||||||
(pcb/with-objects (:objects copy-container))
|
(-> cc
|
||||||
(pcb/update-shapes
|
(pcb/with-container copy-container)
|
||||||
(:shapes shape-copy)
|
(pcb/with-objects (:objects copy-container))
|
||||||
(fn [child-copy]
|
(pcb/update-shapes
|
||||||
(let [child-main (ctf/get-ref-shape main-container main-component child-copy)]
|
(:shapes shape-copy)
|
||||||
(-> child-copy
|
(fn [child-copy]
|
||||||
(propagate-attrs child-main ctk/swap-keep-attrs omit-touched?))))
|
(let [child-main (ctf/get-ref-shape main-container main-component child-copy)]
|
||||||
{:ignore-touched true})))
|
(-> child-copy
|
||||||
|
(propagate-attrs child-main ctk/swap-keep-attrs omit-touched?))))
|
||||||
|
{:ignore-touched true})))]
|
||||||
|
(pcb/concat-changes changes (do-changes (pcb/empty-changes)))))
|
||||||
|
|
||||||
(defn- update-flex-child-main-attrs
|
(defn- update-flex-child-main-attrs
|
||||||
"Synchronizes the attributes inside the flex-child items (copy->main)"
|
"Synchronizes the attributes inside the flex-child items (copy->main)"
|
||||||
[changes shape-main shape-copy main-container copy-container omit-touched?]
|
[changes shape-main shape-copy main-container copy-container omit-touched?]
|
||||||
(-> changes
|
(let [new-changes
|
||||||
(pcb/with-page main-container)
|
(-> (pcb/empty-changes)
|
||||||
(pcb/with-objects (:objects main-container))
|
(pcb/with-page main-container)
|
||||||
(pcb/update-shapes
|
(pcb/with-objects (:objects main-container))
|
||||||
(:shapes shape-main)
|
(pcb/update-shapes
|
||||||
(fn [child-main]
|
(:shapes shape-main)
|
||||||
(let [child-copy (ctf/get-shape-in-copy copy-container child-main shape-copy)]
|
(fn [child-main]
|
||||||
(-> child-main
|
(let [child-copy (ctf/get-shape-in-copy copy-container child-main shape-copy)]
|
||||||
(propagate-attrs child-copy ctk/swap-keep-attrs omit-touched?))))
|
(-> child-main
|
||||||
{:ignore-touched true})))
|
(propagate-attrs child-copy ctk/swap-keep-attrs omit-touched?))))
|
||||||
|
{:ignore-touched true}))]
|
||||||
|
(pcb/concat-changes changes new-changes)))
|
||||||
|
|
||||||
(defn- update-grid-copy-attrs
|
(defn- update-grid-copy-attrs
|
||||||
"Synchronizes the `layout-grid-cells` property from the main shape to the copies"
|
"Synchronizes the `layout-grid-cells` property from the main shape to the copies"
|
||||||
|
@ -1429,19 +1434,21 @@
|
||||||
(fn [copy-shape]
|
(fn [copy-shape]
|
||||||
(let [main-shape (ctf/get-ref-shape main-container main-component copy-shape)]
|
(let [main-shape (ctf/get-ref-shape main-container main-component copy-shape)]
|
||||||
[(:id main-shape) (:id copy-shape)]))))
|
[(:id main-shape) (:id copy-shape)]))))
|
||||||
(:shapes shape-copy))]
|
(:shapes shape-copy))
|
||||||
|
|
||||||
(-> changes
|
new-changes
|
||||||
(pcb/with-container copy-container)
|
(-> (pcb/empty-changes)
|
||||||
(pcb/with-objects (:objects copy-container))
|
(pcb/with-container copy-container)
|
||||||
(pcb/update-shapes
|
(pcb/with-objects (:objects copy-container))
|
||||||
[(:id shape-copy)]
|
(pcb/update-shapes
|
||||||
(fn [shape-copy]
|
[(:id shape-copy)]
|
||||||
;; Take cells from main and remap the shapes to assign it to the copy
|
(fn [shape-copy]
|
||||||
(let [copy-cells (:layout-grid-cells shape-copy)
|
;; Take cells from main and remap the shapes to assign it to the copy
|
||||||
main-cells (-> (ctl/remap-grid-cells shape-main ids-map) :layout-grid-cells)]
|
(let [copy-cells (:layout-grid-cells shape-copy)
|
||||||
(assoc shape-copy :layout-grid-cells (ctl/merge-cells copy-cells main-cells omit-touched?))))
|
main-cells (-> (ctl/remap-grid-cells shape-main ids-map) :layout-grid-cells)]
|
||||||
{:ignore-touched true}))))
|
(assoc shape-copy :layout-grid-cells (ctl/merge-cells copy-cells main-cells omit-touched?))))
|
||||||
|
{:ignore-touched true}))]
|
||||||
|
(pcb/concat-changes changes new-changes)))
|
||||||
|
|
||||||
(defn- update-grid-main-attrs
|
(defn- update-grid-main-attrs
|
||||||
"Synchronizes the `layout-grid-cells` property from the copy to the main shape"
|
"Synchronizes the `layout-grid-cells` property from the copy to the main shape"
|
||||||
|
@ -1454,17 +1461,20 @@
|
||||||
(fn [main-shape]
|
(fn [main-shape]
|
||||||
(let [copy-shape (ctf/get-shape-in-copy copy-container main-shape shape-copy)]
|
(let [copy-shape (ctf/get-shape-in-copy copy-container main-shape shape-copy)]
|
||||||
[(:id copy-shape) (:id main-shape)]))))
|
[(:id copy-shape) (:id main-shape)]))))
|
||||||
(:shapes shape-main))]
|
(:shapes shape-main))
|
||||||
(-> changes
|
|
||||||
(pcb/with-page main-container)
|
new-changes
|
||||||
(pcb/with-objects (:objects main-container))
|
(-> (pcb/empty-changes)
|
||||||
(pcb/update-shapes
|
(pcb/with-page main-container)
|
||||||
[(:id shape-main)]
|
(pcb/with-objects (:objects main-container))
|
||||||
(fn [shape-main]
|
(pcb/update-shapes
|
||||||
;; Take cells from copy and remap the shapes to assign it to the copy
|
[(:id shape-main)]
|
||||||
(let [new-cells (-> (ctl/remap-grid-cells shape-copy ids-map) :layout-grid-cells)]
|
(fn [shape-main]
|
||||||
(assoc shape-main :layout-grid-cells new-cells)))
|
;; Take cells from copy and remap the shapes to assign it to the copy
|
||||||
{:ignore-touched true}))))
|
(let [new-cells (-> (ctl/remap-grid-cells shape-copy ids-map) :layout-grid-cells)]
|
||||||
|
(assoc shape-main :layout-grid-cells new-cells)))
|
||||||
|
{:ignore-touched true}))]
|
||||||
|
(pcb/concat-changes changes new-changes)))
|
||||||
|
|
||||||
(defn- reposition-shape
|
(defn- reposition-shape
|
||||||
[shape origin-root dest-root]
|
[shape origin-root dest-root]
|
||||||
|
|
Loading…
Add table
Reference in a new issue