mirror of
https://github.com/penpot/penpot.git
synced 2025-06-04 01:01:38 +02:00
🐛 Fix new line parsing (#6180)
This commit is contained in:
parent
9fd0e9af66
commit
895b5b2ee1
1 changed files with 28 additions and 28 deletions
|
@ -27,6 +27,7 @@
|
||||||
[app.util.http :as http]
|
[app.util.http :as http]
|
||||||
[app.util.webapi :as wapi]
|
[app.util.webapi :as wapi]
|
||||||
[beicon.v2.core :as rx]
|
[beicon.v2.core :as rx]
|
||||||
|
[cuerdas.core :as str]
|
||||||
[goog.object :as gobj]
|
[goog.object :as gobj]
|
||||||
[promesa.core :as p]
|
[promesa.core :as p]
|
||||||
[rumext.v2 :as mf]))
|
[rumext.v2 :as mf]))
|
||||||
|
@ -628,8 +629,9 @@
|
||||||
(.encode encoder text)))
|
(.encode encoder text)))
|
||||||
|
|
||||||
(defn- add-text-leaf [leaf]
|
(defn- add-text-leaf [leaf]
|
||||||
(let [text (dm/get-prop leaf :text)
|
(let [text (dm/get-prop leaf :text)]
|
||||||
font-id (f/serialize-font-id (dm/get-prop leaf :font-id))
|
(when (and text (not (str/blank? text)))
|
||||||
|
(let [font-id (f/serialize-font-id (dm/get-prop leaf :font-id))
|
||||||
font-style (f/serialize-font-style (dm/get-prop leaf :font-style))
|
font-style (f/serialize-font-style (dm/get-prop leaf :font-style))
|
||||||
font-weight (f/serialize-font-weight (dm/get-prop leaf :font-weight))
|
font-weight (f/serialize-font-weight (dm/get-prop leaf :font-weight))
|
||||||
font-size (js/Number (dm/get-prop leaf :font-size))
|
font-size (js/Number (dm/get-prop leaf :font-size))
|
||||||
|
@ -644,26 +646,24 @@
|
||||||
(aget font-id 1)
|
(aget font-id 1)
|
||||||
(aget font-id 2)
|
(aget font-id 2)
|
||||||
(aget font-id 3)
|
(aget font-id 3)
|
||||||
font-weight font-style font-size)))
|
font-weight font-style font-size)))))
|
||||||
|
|
||||||
(defn set-shape-text-content [content]
|
(defn set-shape-text-content [content]
|
||||||
(h/call wasm/internal-module "_clear_shape_text")
|
(h/call wasm/internal-module "_clear_shape_text")
|
||||||
(let [paragraph-set (first (dm/get-prop content :children))
|
(let [paragraph-set (first (dm/get-prop content :children))
|
||||||
paragraphs (dm/get-prop paragraph-set :children)
|
paragraphs (dm/get-prop paragraph-set :children)
|
||||||
total-paragraphs (count paragraphs)
|
fonts (fonts/get-content-fonts content)
|
||||||
fonts (fonts/get-content-fonts content)]
|
total-paragraphs (count paragraphs)]
|
||||||
|
|
||||||
(loop [index 0]
|
(loop [index 0]
|
||||||
(when (< index total-paragraphs)
|
(when (< index total-paragraphs)
|
||||||
(let [paragraph (nth paragraphs index)
|
(let [paragraph (nth paragraphs index)
|
||||||
leaves (dm/get-prop paragraph :children)
|
leaves (dm/get-prop paragraph :children)]
|
||||||
total-leaves (count leaves)]
|
(when (seq leaves)
|
||||||
(h/call wasm/internal-module "_add_text_paragraph")
|
(h/call wasm/internal-module "_add_text_paragraph")
|
||||||
(loop [index-leaves 0]
|
(loop [leaf-index 0]
|
||||||
(when (< index-leaves total-leaves)
|
(when (< leaf-index (count leaves))
|
||||||
(let [leaf (nth leaves index-leaves)]
|
(add-text-leaf (nth leaves leaf-index))
|
||||||
(add-text-leaf leaf)
|
(recur (inc leaf-index))))))
|
||||||
(recur (inc index-leaves))))))
|
|
||||||
(recur (inc index))))
|
(recur (inc index))))
|
||||||
(f/store-fonts fonts)))
|
(f/store-fonts fonts)))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue