mirror of
https://github.com/penpot/penpot.git
synced 2026-08-06 21:08:34 +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]
|
||||
(ptk/reify ::replace-text-in-shapes
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [undo-group (uuid/next)
|
||||
update-event
|
||||
(dwsh/update-shapes
|
||||
ids
|
||||
(fn [shape]
|
||||
(if (and (= :text (:type shape)) (some? (:content shape)))
|
||||
(let [new-content (txt/replace-text-in-content (:content shape) search replacement)
|
||||
new-name (txt/generate-shape-name (txt/content->text new-content))]
|
||||
(-> shape (assoc :content new-content) (assoc :name new-name)))
|
||||
shape))
|
||||
{:attrs #{:content :name} :undo-group undo-group})]
|
||||
(rx/concat
|
||||
(rx/of update-event)
|
||||
(if (features/active-feature? state "render-wasm/v1")
|
||||
(->> (rx/from ids)
|
||||
(rx/map #(dwwt/resize-wasm-text-debounce %)))
|
||||
(rx/empty)))))))
|
||||
(watch [_ _ _]
|
||||
;; No explicit WASM resize: the :content change committed below is
|
||||
;; picked up by the commit-level text re-measure in `initialize-workspace`.
|
||||
(let [undo-group (uuid/next)]
|
||||
(rx/of
|
||||
(dwsh/update-shapes
|
||||
ids
|
||||
(fn [shape]
|
||||
(if (and (= :text (:type shape)) (some? (:content shape)))
|
||||
(let [new-content (txt/replace-text-in-content (:content shape) search replacement)
|
||||
new-name (txt/generate-shape-name (txt/content->text new-content))]
|
||||
(-> shape (assoc :content new-content) (assoc :name new-name)))
|
||||
shape))
|
||||
{:attrs #{:content :name} :undo-group undo-group}))))))
|
||||
|
||||
;; -- Text Editor v3
|
||||
|
||||
|
||||
@ -18,7 +18,6 @@
|
||||
[app.main.data.workspace.texts-v3 :as dwt-v3]
|
||||
[app.main.data.workspace.tokens.application :as dwta]
|
||||
[app.main.data.workspace.undo :as dwu]
|
||||
[app.main.data.workspace.wasm-text :as dwwt]
|
||||
[app.main.features :as features]
|
||||
[app.main.refs :as refs]
|
||||
[app.main.store :as st]
|
||||
@ -180,11 +179,13 @@
|
||||
(when (some? content)
|
||||
(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)))
|
||||
|
||||
(when (features/active-feature? @st/state "render-wasm/v1")
|
||||
(st/emit! (dwwt/resize-wasm-text-all ids)
|
||||
(ptk/data-event :layout/update {:ids ids})))
|
||||
(st/emit! (ptk/data-event :layout/update {:ids ids})))
|
||||
;; We asynchronously commit so every sychronous event is resolved first and inside the transaction
|
||||
(ts/schedule #(st/emit! (dwu/commit-undo-transaction uid))))
|
||||
(when (some? on-blur) (on-blur))))]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user