mirror of
https://github.com/penpot/penpot.git
synced 2026-05-04 15:49:34 +00:00
🚧 WIP
This commit is contained in:
parent
05726ffd70
commit
c0733771ac
@ -137,7 +137,7 @@
|
||||
{:content {:data (chunk-array data default-chunk-size)
|
||||
:name name
|
||||
:type type}
|
||||
:font-family (or family "")
|
||||
:font-family (or family "Custom Font")
|
||||
:font-weight (cm/parse-font-weight variant)
|
||||
:font-style (cm/parse-font-style variant)
|
||||
:height-warning? height-warning?})
|
||||
|
||||
@ -1659,25 +1659,30 @@
|
||||
;; Add comprehensive nil-safety checks
|
||||
;; Be aware that for RTL texts `start-pos` can be greatert han `end-pos`
|
||||
(when (and element element-text)
|
||||
(let [text (subs element-text start-pos end-pos)]
|
||||
(let [text (subs element-text start-pos end-pos)
|
||||
not-nil-or-blank?
|
||||
(fn [[_ v]]
|
||||
(and (some? v)
|
||||
(not (and (string? v) (identical? v "")))))]
|
||||
(d/patch-object
|
||||
txt/default-text-attrs
|
||||
(d/without-nils
|
||||
{:x x
|
||||
:y (+ y height)
|
||||
:width width
|
||||
:height height
|
||||
:direction (dr/translate-direction direction)
|
||||
:font-id (get element :font-id)
|
||||
:font-family (get element :font-family)
|
||||
:font-size (get element :font-size)
|
||||
:font-weight (get element :font-weight)
|
||||
:text-transform (get element :text-transform)
|
||||
:text-decoration (get element :text-decoration)
|
||||
:letter-spacing (get element :letter-spacing)
|
||||
:font-style (get element :font-style)
|
||||
:fills (get element :fills)
|
||||
:text text})))))))
|
||||
(into {}
|
||||
(filter not-nil-or-blank?)
|
||||
{:x x
|
||||
:y (+ y height)
|
||||
:width width
|
||||
:height height
|
||||
:direction (dr/translate-direction direction)
|
||||
:font-id (get element :font-id)
|
||||
:font-family (get element :font-family)
|
||||
:font-size (get element :font-size)
|
||||
:font-weight (get element :font-weight)
|
||||
:text-transform (get element :text-transform)
|
||||
:text-decoration (get element :text-decoration)
|
||||
:letter-spacing (get element :letter-spacing)
|
||||
:font-style (get element :font-style)
|
||||
:fills (get element :fills)
|
||||
:text text})))))))
|
||||
result))))
|
||||
|
||||
(defn apply-canvas-blur
|
||||
|
||||
@ -199,12 +199,20 @@
|
||||
(let [style-name (get-style-name-as-css-variable k)
|
||||
[_ style-decode] (get mapping k)
|
||||
style-value (.getPropertyValue style-declaration style-name)]
|
||||
(when (or (not removed-mixed) (not (contains? mixed-values style-value)))
|
||||
(assoc acc k (style-decode style-value))))
|
||||
(if (or (not removed-mixed) (not (contains? mixed-values style-value)))
|
||||
(let [decoded (style-decode style-value)]
|
||||
(if (or (nil? decoded) (and (string? decoded) (str/blank? decoded)))
|
||||
acc
|
||||
(assoc acc k decoded)))
|
||||
acc))
|
||||
(let [style-name (get-style-name k)
|
||||
style-value (normalize-attr-value k (.getPropertyValue style-declaration style-name))]
|
||||
(when (or (not removed-mixed) (not (contains? mixed-values style-value)))
|
||||
(assoc acc k style-value))))) {} txt/text-style-attrs))
|
||||
raw-value (.getPropertyValue style-declaration style-name)]
|
||||
(if (and (some? raw-value) (not (str/blank? raw-value)))
|
||||
(let [style-value (normalize-attr-value k raw-value)]
|
||||
(if (or (not removed-mixed) (not (contains? mixed-values style-value)))
|
||||
(assoc acc k style-value)
|
||||
acc))
|
||||
acc)))) {} txt/text-style-attrs))
|
||||
|
||||
(defn get-styles-from-event
|
||||
"Returns a ClojureScript object compatible with text nodes"
|
||||
|
||||
@ -98,13 +98,13 @@
|
||||
(dm/get-prop position :height)))]
|
||||
(into position (filter val)
|
||||
{:direction direction
|
||||
:font-family (dm/str (get-prop styles "font-family"))
|
||||
:font-size (dm/str (get-prop styles "font-size"))
|
||||
:font-weight (dm/str (get-prop styles "font-weight"))
|
||||
:text-transform (dm/str (get-prop styles "text-transform"))
|
||||
:text-decoration (dm/str (get-prop styles "text-decoration"))
|
||||
:letter-spacing (dm/str (get-prop styles "letter-spacing"))
|
||||
:font-style (dm/str (get-prop styles "font-style"))
|
||||
:font-family (get-prop styles "font-family")
|
||||
:font-size (get-prop styles "font-size")
|
||||
:font-weight (get-prop styles "font-weight")
|
||||
:text-transform (get-prop styles "text-transform")
|
||||
:text-decoration (get-prop styles "text-decoration")
|
||||
:letter-spacing (get-prop styles "letter-spacing")
|
||||
:font-style (get-prop styles "font-style")
|
||||
:fills (transit/decode-str (get-prop styles "--fills"))
|
||||
:text text})))]
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user