mirror of
https://github.com/penpot/penpot.git
synced 2025-05-26 02:26:11 +02:00
🐛 Fix problem with SVG's import/export
This commit is contained in:
parent
36bb5cbe01
commit
9e7551551f
2 changed files with 29 additions and 11 deletions
|
@ -199,6 +199,18 @@
|
||||||
:penpot:suffix suffix
|
:penpot:suffix suffix
|
||||||
:penpot:scale (str scale)}])))
|
:penpot:scale (str scale)}])))
|
||||||
|
|
||||||
|
(defn str->style
|
||||||
|
[style-str]
|
||||||
|
(if (string? style-str)
|
||||||
|
(->> (str/split style-str ";")
|
||||||
|
(map str/trim)
|
||||||
|
(map #(str/split % ":"))
|
||||||
|
(group-by first)
|
||||||
|
(map (fn [[key val]]
|
||||||
|
(vector (keyword key) (second (first val)))))
|
||||||
|
(into {}))
|
||||||
|
style-str))
|
||||||
|
|
||||||
(defn style->str
|
(defn style->str
|
||||||
[style]
|
[style]
|
||||||
(->> style
|
(->> style
|
||||||
|
@ -229,7 +241,8 @@
|
||||||
[:& render-xml {:xml def-xml}]])]))
|
[:& render-xml {:xml def-xml}]])]))
|
||||||
|
|
||||||
(when (= (:type shape) :svg-raw)
|
(when (= (:type shape) :svg-raw)
|
||||||
(let [props
|
(let [shape (-> shape (d/update-in-when [:content :attrs :style] str->style))
|
||||||
|
props
|
||||||
(-> (obj/new)
|
(-> (obj/new)
|
||||||
(obj/set! "penpot:x" (:x shape))
|
(obj/set! "penpot:x" (:x shape))
|
||||||
(obj/set! "penpot:y" (:y shape))
|
(obj/set! "penpot:y" (:y shape))
|
||||||
|
@ -263,7 +276,6 @@
|
||||||
(mf/defc export-data
|
(mf/defc export-data
|
||||||
[{:keys [shape]}]
|
[{:keys [shape]}]
|
||||||
(let [props (-> (obj/new) (add-data shape) (add-library-refs shape))]
|
(let [props (-> (obj/new) (add-data shape) (add-library-refs shape))]
|
||||||
(js/console.log props)
|
|
||||||
[:> "penpot:shape" props
|
[:> "penpot:shape" props
|
||||||
(export-shadow-data shape)
|
(export-shadow-data shape)
|
||||||
(export-blur-data shape)
|
(export-blur-data shape)
|
||||||
|
|
|
@ -210,7 +210,8 @@
|
||||||
|
|
||||||
svg-node (if (= :svg tag)
|
svg-node (if (= :svg tag)
|
||||||
(->> node :content last :content last)
|
(->> node :content last :content last)
|
||||||
(->> node :content last))]
|
(->> node :content last))
|
||||||
|
svg-node (d/update-in-when svg-node [:attrs :style] parse-style)]
|
||||||
(merge (add-attrs {} (:attrs svg-node)) node-attrs))
|
(merge (add-attrs {} (:attrs svg-node)) node-attrs))
|
||||||
|
|
||||||
(= type :bool)
|
(= type :bool)
|
||||||
|
@ -633,7 +634,8 @@
|
||||||
(defn add-svg-content
|
(defn add-svg-content
|
||||||
[props node]
|
[props node]
|
||||||
(let [svg-content (get-data node :penpot:svg-content)
|
(let [svg-content (get-data node :penpot:svg-content)
|
||||||
attrs (-> (:attrs svg-content) (without-penpot-prefix))
|
attrs (-> (:attrs svg-content) (without-penpot-prefix)
|
||||||
|
(d/update-when :style parse-style))
|
||||||
tag (-> svg-content :attrs :penpot:tag keyword)
|
tag (-> svg-content :attrs :penpot:tag keyword)
|
||||||
|
|
||||||
node-content
|
node-content
|
||||||
|
@ -641,13 +643,17 @@
|
||||||
(= tag :svg)
|
(= tag :svg)
|
||||||
(->> node :content last :content last :content fix-style-attr)
|
(->> node :content last :content last :content fix-style-attr)
|
||||||
|
|
||||||
(= tag :text)
|
(some? (:content svg-content))
|
||||||
(-> node :content last :content))]
|
(->> (:content svg-content)
|
||||||
|
(filter #(= :penpot:svg-child (:tag %)))
|
||||||
|
(mapv :content)
|
||||||
|
(first)))]
|
||||||
|
(-> props
|
||||||
(assoc
|
(assoc
|
||||||
props :content
|
:content
|
||||||
{:attrs attrs
|
{:attrs attrs
|
||||||
:tag tag
|
:tag tag
|
||||||
:content node-content})))
|
:content node-content}))))
|
||||||
|
|
||||||
(defn add-frame-data [props node]
|
(defn add-frame-data [props node]
|
||||||
(let [grids (parse-grids node)]
|
(let [grids (parse-grids node)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue