0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-27 15:11:26 -05:00

🐛 Fix problem with hanging file

This commit is contained in:
alonso.torres 2022-05-25 11:22:59 +02:00
parent ef37abcbbd
commit 0f2b2d4590

View file

@ -62,20 +62,22 @@
(assoc :content (d/txt-merge content editor-content)))))
(defn- update-text-shape
[{:keys [grow-type id]} node]
[{:keys [grow-type id migrate]} node]
;; Check if we need to update the size because it's auto-width or auto-height
(when (contains? #{:auto-height :auto-width} grow-type)
(let [{:keys [width height]}
(-> (dom/query node ".paragraph-set")
(dom/get-client-size))
width (mth/ceil width)
height (mth/ceil height)]
(when (and (not (mth/almost-zero? width)) (not (mth/almost-zero? height)))
(st/emit! (dwt/resize-text id width height)))))
;; Update the position-data of every text fragment
(p/let [position-data (utp/calc-position-data node)]
(st/emit! (dwt/update-position-data id position-data)))
(st/emit! (dwt/update-position-data id position-data))
(when (contains? #{:auto-height :auto-width} grow-type)
(let [{:keys [width height]}
(-> (dom/query node ".paragraph-set")
(dom/get-client-size))
width (mth/ceil width)
height (mth/ceil height)]
(when (and (not (mth/almost-zero? width))
(not (mth/almost-zero? height))
(not migrate))
(st/emit! (dwt/resize-text id width height))))))
(st/emit! (dwt/clean-text-modifier id)))
@ -229,7 +231,14 @@
(mf/deps text-shapes modifiers)
#(d/update-vals text-shapes (partial process-shape modifiers)))
editing-shape (get text-shapes edition)]
editing-shape (get text-shapes edition)
;; This memo is necesary so the viewport-text-wrapper memoize its props correctly
text-shapes-wrapper
(mf/use-memo
(mf/deps text-shapes edition)
(fn []
(dissoc text-shapes edition)))]
;; We only need the effect to run on "mount" because the next fonts will be changed when the texts are
;; edited
@ -243,5 +252,5 @@
(when editing-shape
[:& viewport-text-editing {:shape editing-shape}])
[:& viewport-texts-wrapper {:text-shapes (dissoc text-shapes edition)
[:& viewport-texts-wrapper {:text-shapes text-shapes-wrapper
:modifiers modifiers}]]))