mirror of
https://github.com/penpot/penpot.git
synced 2026-08-01 19:06:18 +00:00
🐛 Remove fills from paragraph-set nodes on text shapes
This commit is contained in:
parent
19961f440a
commit
8c54cb764f
@ -1429,7 +1429,7 @@
|
|||||||
(def ^:private valid-stroke?
|
(def ^:private valid-stroke?
|
||||||
(sm/lazy-validator cts/schema:stroke))
|
(sm/lazy-validator cts/schema:stroke))
|
||||||
|
|
||||||
(defmethod migrate-data "0007-clear-invalid-strokes-and-fills"
|
(defmethod migrate-data "0007-clear-invalid-strokes-and-fills-v2"
|
||||||
[data _]
|
[data _]
|
||||||
(letfn [(clear-color-image [image]
|
(letfn [(clear-color-image [image]
|
||||||
(select-keys image types.color/image-attrs))
|
(select-keys image types.color/image-attrs))
|
||||||
@ -1473,13 +1473,18 @@
|
|||||||
(d/update-when :strokes fix-strokes)
|
(d/update-when :strokes fix-strokes)
|
||||||
(d/update-when :fills fix-fills)))
|
(d/update-when :fills fix-fills)))
|
||||||
|
|
||||||
|
(fix-text-content [content]
|
||||||
|
(->> content
|
||||||
|
(txt/transform-nodes txt/is-content-node? fix-object)
|
||||||
|
(txt/transform-nodes txt/is-paragraph-set-node? #(dissoc % :fills))))
|
||||||
|
|
||||||
(update-shape [object]
|
(update-shape [object]
|
||||||
(-> object
|
(-> object
|
||||||
(fix-object)
|
(fix-object)
|
||||||
;; The text shape also can has strokes and fils on the
|
;; The text shape also can has strokes and fils on the
|
||||||
;; text fragments so we need to fix them there
|
;; text fragments so we need to fix them there
|
||||||
(cond-> (cfh/text-shape? object)
|
(cond-> (cfh/text-shape? object)
|
||||||
(update :content (partial txt/transform-nodes identity fix-object)))))
|
(update :content fix-text-content))))
|
||||||
|
|
||||||
(update-container [container]
|
(update-container [container]
|
||||||
(d/update-when container :objects d/update-vals update-shape))]
|
(d/update-when container :objects d/update-vals update-shape))]
|
||||||
@ -1560,5 +1565,5 @@
|
|||||||
"0004-clean-shadow-and-colors"
|
"0004-clean-shadow-and-colors"
|
||||||
"0005-deprecate-image-type"
|
"0005-deprecate-image-type"
|
||||||
"0006-fix-old-texts-fills"
|
"0006-fix-old-texts-fills"
|
||||||
"0007-clear-invalid-strokes-and-fills"
|
"0007-clear-invalid-strokes-and-fills-v2"
|
||||||
"0008-fix-library-colors-opacity"]))
|
"0008-fix-library-colors-opacity"]))
|
||||||
|
|||||||
@ -133,6 +133,10 @@
|
|||||||
(and (string? (:text node))
|
(and (string? (:text node))
|
||||||
(not= (:text node) "")))
|
(not= (:text node) "")))
|
||||||
|
|
||||||
|
(defn is-paragraph-set-node?
|
||||||
|
[node]
|
||||||
|
(= "paragraph-set" (:type node)))
|
||||||
|
|
||||||
(defn is-paragraph-node?
|
(defn is-paragraph-node?
|
||||||
[node]
|
[node]
|
||||||
(= "paragraph" (:type node)))
|
(= "paragraph" (:type node)))
|
||||||
@ -143,7 +147,17 @@
|
|||||||
|
|
||||||
(defn is-node?
|
(defn is-node?
|
||||||
[node]
|
[node]
|
||||||
(or (is-text-node? node) (is-paragraph-node? node) (is-root-node? node)))
|
(or ^boolean (is-text-node? node)
|
||||||
|
^boolean (is-paragraph-node? node)
|
||||||
|
^boolean (is-paragraph-set-node? node)
|
||||||
|
^boolean (is-root-node? node)))
|
||||||
|
|
||||||
|
(defn is-content-node?
|
||||||
|
"Only matches content nodes, ignoring the paragraph-set nodes."
|
||||||
|
[node]
|
||||||
|
(or ^boolean (is-text-node? node)
|
||||||
|
^boolean (is-paragraph-node? node)
|
||||||
|
^boolean (is-root-node? node)))
|
||||||
|
|
||||||
(defn transform-nodes
|
(defn transform-nodes
|
||||||
([transform root]
|
([transform root]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user