mirror of
https://github.com/penpot/penpot.git
synced 2026-08-07 05:18:36 +00:00
✨ Remove redundant calls to re-measure shapes, now that we're doing it at commit
This commit is contained in:
parent
04c397477f
commit
1e07263a17
@ -1353,24 +1353,20 @@
|
|||||||
[ids search replacement]
|
[ids search replacement]
|
||||||
(ptk/reify ::replace-text-in-shapes
|
(ptk/reify ::replace-text-in-shapes
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state _]
|
(watch [_ _ _]
|
||||||
(let [undo-group (uuid/next)
|
;; No explicit WASM resize: the :content change committed below is
|
||||||
update-event
|
;; picked up by the commit-level text re-measure in `initialize-workspace`.
|
||||||
(dwsh/update-shapes
|
(let [undo-group (uuid/next)]
|
||||||
ids
|
(rx/of
|
||||||
(fn [shape]
|
(dwsh/update-shapes
|
||||||
(if (and (= :text (:type shape)) (some? (:content shape)))
|
ids
|
||||||
(let [new-content (txt/replace-text-in-content (:content shape) search replacement)
|
(fn [shape]
|
||||||
new-name (txt/generate-shape-name (txt/content->text new-content))]
|
(if (and (= :text (:type shape)) (some? (:content shape)))
|
||||||
(-> shape (assoc :content new-content) (assoc :name new-name)))
|
(let [new-content (txt/replace-text-in-content (:content shape) search replacement)
|
||||||
shape))
|
new-name (txt/generate-shape-name (txt/content->text new-content))]
|
||||||
{:attrs #{:content :name} :undo-group undo-group})]
|
(-> shape (assoc :content new-content) (assoc :name new-name)))
|
||||||
(rx/concat
|
shape))
|
||||||
(rx/of update-event)
|
{:attrs #{:content :name} :undo-group undo-group}))))))
|
||||||
(if (features/active-feature? state "render-wasm/v1")
|
|
||||||
(->> (rx/from ids)
|
|
||||||
(rx/map #(dwwt/resize-wasm-text-debounce %)))
|
|
||||||
(rx/empty)))))))
|
|
||||||
|
|
||||||
;; -- Text Editor v3
|
;; -- Text Editor v3
|
||||||
|
|
||||||
|
|||||||
@ -18,7 +18,6 @@
|
|||||||
[app.main.data.workspace.texts-v3 :as dwt-v3]
|
[app.main.data.workspace.texts-v3 :as dwt-v3]
|
||||||
[app.main.data.workspace.tokens.application :as dwta]
|
[app.main.data.workspace.tokens.application :as dwta]
|
||||||
[app.main.data.workspace.undo :as dwu]
|
[app.main.data.workspace.undo :as dwu]
|
||||||
[app.main.data.workspace.wasm-text :as dwwt]
|
|
||||||
[app.main.features :as features]
|
[app.main.features :as features]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
@ -180,11 +179,13 @@
|
|||||||
(when (some? content)
|
(when (some? content)
|
||||||
(st/emit! (dwt/v2-update-text-shape-content (first ids) content :finalize? true)))))
|
(st/emit! (dwt/v2-update-text-shape-content (first ids) content :finalize? true)))))
|
||||||
|
|
||||||
|
;; The :grow-type change is committed by `update-shapes`; the
|
||||||
|
;; commit-level text re-measure in `initialize-workspace` picks it
|
||||||
|
;; up and resizes, so no explicit WASM resize is dispatched here.
|
||||||
(st/emit! (dwsh/update-shapes ids #(assoc % :grow-type grow-type)))
|
(st/emit! (dwsh/update-shapes ids #(assoc % :grow-type grow-type)))
|
||||||
|
|
||||||
(when (features/active-feature? @st/state "render-wasm/v1")
|
(when (features/active-feature? @st/state "render-wasm/v1")
|
||||||
(st/emit! (dwwt/resize-wasm-text-all ids)
|
(st/emit! (ptk/data-event :layout/update {:ids ids})))
|
||||||
(ptk/data-event :layout/update {:ids ids})))
|
|
||||||
;; We asynchronously commit so every sychronous event is resolved first and inside the transaction
|
;; We asynchronously commit so every sychronous event is resolved first and inside the transaction
|
||||||
(ts/schedule #(st/emit! (dwu/commit-undo-transaction uid))))
|
(ts/schedule #(st/emit! (dwu/commit-undo-transaction uid))))
|
||||||
(when (some? on-blur) (on-blur))))]
|
(when (some? on-blur) (on-blur))))]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user