🐛 Fix problems with old texts

This commit is contained in:
alonso.torres 2022-02-24 14:04:43 +01:00
parent ec63d23666
commit 64ffa9bb3f
10 changed files with 107 additions and 77 deletions

View file

@ -89,11 +89,11 @@
(cond
(contains? shape :fill-image)
(let [fill-image-id (str "fill-image-" render-id)]
{:fill (str/format "url(#%s)" fill-image-id)})
{:fill (str "url(#" fill-image-id ")")})
(contains? shape :fill-color-gradient)
(let [fill-color-gradient-id (str "fill-color-gradient_" render-id (if index (str "_" index) ""))]
{:fill (str/format "url(#%s)" fill-color-gradient-id)})
{:fill (str "url(#" fill-color-gradient-id ")")})
(contains? shape :fill-color)
{:fill (:fill-color shape)}

View file

@ -45,19 +45,18 @@
(= :path (:type shape))
(obj/set! "patternTransform" transform))]
[:*
(for [[_shape-index shape] (d/enumerate (or (:position-data shape) [shape]))]
(for [[shape-index shape] (d/enumerate (or (:position-data shape) [shape]))]
[:*
(for [[fill-index value] (-> (d/enumerate (:fills shape [])) reverse)]
(cond (some? (:fill-color-gradient value))
(case (d/name (:type (:fill-color-gradient value)))
"linear" [:> grad/linear-gradient #js {:id (str "fill-color-gradient_" render-id "_" fill-index)
:gradient (:fill-color-gradient value)
:shape shape}]
"radial" [:> grad/radial-gradient #js {:id (str "fill-color-gradient_" render-id "_" fill-index)
:gradient (:fill-color-gradient value)
:shape shape}]))))
(when (some? (:fill-color-gradient value))
(let [props #js {:id (str "fill-color-gradient_" render-id "_" fill-index)
:gradient (:fill-color-gradient value)
:shape shape}]
(case (d/name (:type (:fill-color-gradient value)))
"linear" [:> grad/linear-gradient props]
"radial" [:> grad/radial-gradient props]))))
(for [[shape-index shape] (d/enumerate (or (:position-data shape) [shape]))]
(let [fill-id (str "fill-" shape-index "-" render-id)]
[:> :pattern (-> (obj/clone pattern-attrs)
(obj/set! "id" fill-id))
@ -70,4 +69,4 @@
(when has-image
[:image {:xlinkHref (get embed uri uri)
:width width
:height height}])]]))]))))
:height height}])]])])))))

View file

@ -87,11 +87,22 @@
:caretColor (or text-color "black")
:overflowWrap "initial"}
base (-> base
(obj/set! "--fills" (transit/encode-str (:fills data)))
#_(obj/set! "--fill-color" fill-color)
#_(obj/set! "--fill-color-gradient" (transit/encode-str (:fill-color-gradient data)))
#_(obj/set! "--fill-opacity" fill-opacity))]
fills
(cond
(some? (:fills data))
(:fills data)
(or (some? (:fill-color data))
(some? (:fill-opacity data))
(some? (:fill-color-gradient data)))
[(d/without-nils (select-keys data [:fill-color :fill-opacity :fill-color-gradient :fill-color-ref-id :fill-color-ref-file]))]
(nil? (:fills data))
[{:fill-color "#000000" :fill-opacity 1}])
base (cond-> base
(some? fills)
(obj/set! "--fills" (transit/encode-str fills)))]
(when (and (string? letter-spacing)
(pos? (alength letter-spacing)))

View file

@ -57,10 +57,9 @@
:textTransform (:text-transform data)
:textDecoration (:text-decoration data)
:fontStyle (:font-style data)
:direction (if (:rtl? data) "rtl" "ltr")
:direction (if (:rtl data) "rtl" "ltr")
:whiteSpace "pre"}
(obj/set! "fill" (str "url(#fill-" index "-" render-id ")"))
#_(attrs/add-fill data (get-gradient-id index)))})]
(obj/set! "fill" (str "url(#fill-" index "-" render-id ")")))})]
[:& shape-custom-stroke {:shape shape :index index}
[:> :text props (:text data)]]))]]))