🐛 Avoid nil values for position-data

This commit is contained in:
Alejandro Alonso 2023-05-11 10:02:46 +02:00 committed by Alonso Torres
parent f3f708ee9d
commit 00d625ee33

View file

@ -90,27 +90,26 @@
[shape-id] [shape-id]
(when (some? shape-id) (when (some? shape-id)
(p/let [text-data (calc-text-node-positions shape-id)] (p/let [text-data (calc-text-node-positions shape-id)]
(when (d/not-empty? text-data) (->> text-data
(->> text-data (mapv (fn [{:keys [node position text direction]}]
(mapv (fn [{:keys [node position text direction]}] (let [{:keys [x y width height]} position
(let [{:keys [x y width height]} position styles (js/getComputedStyle ^js node)
styles (js/getComputedStyle ^js node) get (fn [prop]
get (fn [prop] (let [value (.getPropertyValue styles prop)]
(let [value (.getPropertyValue styles prop)] (when (and value (not= value ""))
(when (and value (not= value "")) value)))]
value)))] (d/without-nils
(d/without-nils {:x x
{:x x :y (+ y height)
:y (+ y height) :width width
:width width :height height
:height height :direction direction
:direction direction :font-family (str (get "font-family"))
:font-family (str (get "font-family")) :font-size (str (get "font-size"))
:font-size (str (get "font-size")) :font-weight (str (get "font-weight"))
:font-weight (str (get "font-weight")) :text-transform (str (get "text-transform"))
:text-transform (str (get "text-transform")) :text-decoration (str (get "text-decoration"))
:text-decoration (str (get "text-decoration")) :letter-spacing (str (get "letter-spacing"))
:letter-spacing (str (get "letter-spacing")) :font-style (str (get "font-style"))
:font-style (str (get "font-style")) :fills (transit/decode-str (get "--fills"))
:fills (transit/decode-str (get "--fills")) :text text}))))))))
:text text})))))))))