diff --git a/frontend/src/app/main/ui/shapes/export.cljs b/frontend/src/app/main/ui/shapes/export.cljs index 052dce5ab5..1ea58e5ed5 100644 --- a/frontend/src/app/main/ui/shapes/export.cljs +++ b/frontend/src/app/main/ui/shapes/export.cljs @@ -199,6 +199,18 @@ :penpot:suffix suffix :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 [style] (->> style @@ -229,7 +241,8 @@ [:& render-xml {:xml def-xml}]])])) (when (= (:type shape) :svg-raw) - (let [props + (let [shape (-> shape (d/update-in-when [:content :attrs :style] str->style)) + props (-> (obj/new) (obj/set! "penpot:x" (:x shape)) (obj/set! "penpot:y" (:y shape)) @@ -263,7 +276,6 @@ (mf/defc export-data [{:keys [shape]}] (let [props (-> (obj/new) (add-data shape) (add-library-refs shape))] - (js/console.log props) [:> "penpot:shape" props (export-shadow-data shape) (export-blur-data shape) diff --git a/frontend/src/app/util/import/parser.cljs b/frontend/src/app/util/import/parser.cljs index 4f1431b480..dec08ba7c5 100644 --- a/frontend/src/app/util/import/parser.cljs +++ b/frontend/src/app/util/import/parser.cljs @@ -210,7 +210,8 @@ svg-node (if (= :svg tag) (->> 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)) (= type :bool) @@ -633,7 +634,8 @@ (defn add-svg-content [props node] (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) node-content @@ -641,13 +643,17 @@ (= tag :svg) (->> node :content last :content last :content fix-style-attr) - (= tag :text) - (-> node :content last :content))] - (assoc - props :content - {:attrs attrs - :tag tag - :content node-content}))) + (some? (:content svg-content)) + (->> (:content svg-content) + (filter #(= :penpot:svg-child (:tag %))) + (mapv :content) + (first)))] + (-> props + (assoc + :content + {:attrs attrs + :tag tag + :content node-content})))) (defn add-frame-data [props node] (let [grids (parse-grids node)]