mirror of
https://github.com/penpot/penpot.git
synced 2026-08-05 04:18:41 +00:00
Merge pull request #8382 from penpot/alotor-fix-components-propagation
🐛 Fix problem with text change component propagation and undo
This commit is contained in:
commit
7c1ddd3d7d
@ -1150,3 +1150,24 @@
|
|||||||
[changes]
|
[changes]
|
||||||
(::page-id (meta changes)))
|
(::page-id (meta changes)))
|
||||||
|
|
||||||
|
|
||||||
|
(defn set-text-content
|
||||||
|
[changes id content prev-content]
|
||||||
|
(assert-page-id! changes)
|
||||||
|
(let [page-id (::page-id (meta changes))
|
||||||
|
|
||||||
|
redo-change
|
||||||
|
{:type :mod-obj
|
||||||
|
:page-id page-id
|
||||||
|
:id id
|
||||||
|
:operations [{:type :set :attr :content :val content}]}
|
||||||
|
|
||||||
|
undo-change
|
||||||
|
{:type :mod-obj
|
||||||
|
:page-id page-id
|
||||||
|
:id id
|
||||||
|
:operations [{:type :set :attr :content :val prev-content}]}]
|
||||||
|
|
||||||
|
(-> changes
|
||||||
|
(update :redo-changes conj redo-change)
|
||||||
|
(update :undo-changes conj undo-change))))
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
[app.common.attrs :as attrs]
|
[app.common.attrs :as attrs]
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.data.macros :as dm]
|
[app.common.data.macros :as dm]
|
||||||
|
[app.common.files.changes-builder :as pcb]
|
||||||
[app.common.files.helpers :as cfh]
|
[app.common.files.helpers :as cfh]
|
||||||
[app.common.geom.point :as gpt]
|
[app.common.geom.point :as gpt]
|
||||||
[app.common.geom.shapes :as gsh]
|
[app.common.geom.shapes :as gsh]
|
||||||
@ -19,6 +20,7 @@
|
|||||||
[app.common.types.shape.layout :as ctl]
|
[app.common.types.shape.layout :as ctl]
|
||||||
[app.common.types.text :as txt]
|
[app.common.types.text :as txt]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
|
[app.main.data.changes :as dch]
|
||||||
[app.main.data.event :as ev]
|
[app.main.data.event :as ev]
|
||||||
[app.main.data.helpers :as dsh]
|
[app.main.data.helpers :as dsh]
|
||||||
[app.main.data.workspace.common :as dwc]
|
[app.main.data.workspace.common :as dwc]
|
||||||
@ -916,11 +918,11 @@
|
|||||||
(update-in state [:workspace-text-modifier shape-id] {:position-data position-data}))))
|
(update-in state [:workspace-text-modifier shape-id] {:position-data position-data}))))
|
||||||
|
|
||||||
(defn v2-update-text-shape-content
|
(defn v2-update-text-shape-content
|
||||||
[id content & {:keys [update-name? name finalize? save-undo?]
|
[id content & {:keys [update-name? name finalize? save-undo? original-content]
|
||||||
:or {update-name? false name nil finalize? false save-undo? true}}]
|
:or {update-name? false name nil finalize? false save-undo? true original-content nil}}]
|
||||||
(ptk/reify ::v2-update-text-shape-content
|
(ptk/reify ::v2-update-text-shape-content
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state _]
|
(watch [it state _]
|
||||||
(if (features/active-feature? state "render-wasm/v1")
|
(if (features/active-feature? state "render-wasm/v1")
|
||||||
(let [objects (dsh/lookup-page-objects state)
|
(let [objects (dsh/lookup-page-objects state)
|
||||||
shape (get objects id)
|
shape (get objects id)
|
||||||
@ -970,7 +972,13 @@
|
|||||||
{:save-undo? false}))
|
{:save-undo? false}))
|
||||||
(dws/deselect-shape id)
|
(dws/deselect-shape id)
|
||||||
(dwsh/delete-shapes #{id})))
|
(dwsh/delete-shapes #{id})))
|
||||||
(rx/of (dwt/finish-transform))))))
|
(rx/of
|
||||||
|
;; This commit is necesary for undo and component propagation
|
||||||
|
;; on finalization
|
||||||
|
(dch/commit-changes
|
||||||
|
(-> (pcb/empty-changes it (:current-page-id state))
|
||||||
|
(pcb/set-text-content id content original-content)))
|
||||||
|
(dwt/finish-transform))))))
|
||||||
|
|
||||||
(let [objects (dsh/lookup-page-objects state)
|
(let [objects (dsh/lookup-page-objects state)
|
||||||
shape (get objects id)
|
shape (get objects id)
|
||||||
|
|||||||
@ -118,7 +118,8 @@
|
|||||||
:update-name? update-name?
|
:update-name? update-name?
|
||||||
:name generated-name
|
:name generated-name
|
||||||
:finalize? true
|
:finalize? true
|
||||||
:save-undo? false))))
|
:save-undo? false
|
||||||
|
:original-content original-content))))
|
||||||
|
|
||||||
(let [container-node (mf/ref-val container-ref)]
|
(let [container-node (mf/ref-val container-ref)]
|
||||||
(dom/set-style! container-node "opacity" 0)))
|
(dom/set-style! container-node "opacity" 0)))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user