mirror of
https://github.com/penpot/penpot.git
synced 2025-01-24 23:49:45 -05:00
🐛 Fix text shape impl (unexpected exception on prod build).
This commit is contained in:
parent
88763d236a
commit
3a4ef73f06
1 changed files with 39 additions and 37 deletions
|
@ -111,11 +111,12 @@
|
|||
(p/all))]
|
||||
(reduce (fn [text [url data]] (str/replace text url data)) font-text url-to-data)))
|
||||
|
||||
(defn- render-text-node
|
||||
([node] (render-text-node 0 node))
|
||||
([index {:keys [type text children] :as node}]
|
||||
(mf/defc text-node
|
||||
[{:keys [node index] :as props}]
|
||||
(let [embed-resources? (mf/use-ctx muc/embed-ctx)
|
||||
embeded-fonts (mf/use-state nil)]
|
||||
embeded-fonts (mf/use-state nil)
|
||||
{:keys [type text children]} node]
|
||||
|
||||
(mf/use-effect
|
||||
(mf/deps node)
|
||||
(fn []
|
||||
|
@ -125,11 +126,12 @@
|
|||
(-> (p/all embeded)
|
||||
(p/then (fn [result] (reset! embeded-fonts (str/join "\n" result)))))))))
|
||||
|
||||
(mf/html
|
||||
(if (string? text)
|
||||
(let [style (generate-text-styles (clj->js node))]
|
||||
[:span {:style style :key index} text])
|
||||
(let [children (map-indexed render-text-node children)]
|
||||
(let [children (map-indexed (fn [index node]
|
||||
(mf/element text-node {:index index :node node :key index}))
|
||||
children)]
|
||||
(case type
|
||||
"root"
|
||||
(let [style (generate-root-styles (clj->js node))]
|
||||
|
@ -151,14 +153,14 @@
|
|||
(let [style (generate-paragraph-styles (clj->js node))]
|
||||
[:p {:key index :style style} children])
|
||||
|
||||
nil)))))))
|
||||
nil)))))
|
||||
|
||||
(mf/defc text-content
|
||||
{::mf/wrap-props false
|
||||
::mf/wrap [mf/memo]}
|
||||
[props]
|
||||
(let [root (obj/get props "content")]
|
||||
(render-text-node root)))
|
||||
[:& text-node {:index 0 :node root}]))
|
||||
|
||||
(defn- retrieve-colors
|
||||
[shape]
|
||||
|
|
Loading…
Add table
Reference in a new issue