mirror of
https://github.com/penpot/penpot.git
synced 2025-07-31 15:29:52 +02:00
✨ Fix problems with export/import
This commit is contained in:
parent
3228582cbe
commit
82c6b8daae
4 changed files with 68 additions and 53 deletions
|
@ -109,7 +109,8 @@
|
|||
|
||||
(cond-> text?
|
||||
(-> (add! :grow-type)
|
||||
(add! :content (comp json/encode uuid->string))))
|
||||
(add! :content (comp json/encode uuid->string))
|
||||
(add! :position-data (comp json/encode uuid->string))))
|
||||
|
||||
(cond-> mask?
|
||||
(obj/set! "penpot:masked-group" "true"))
|
||||
|
@ -138,19 +139,20 @@
|
|||
(into {} (map prefix-entry) m)))
|
||||
|
||||
(defn- export-grid-data [{:keys [grids]}]
|
||||
(mf/html
|
||||
[:> "penpot:grids" #js {}
|
||||
(for [{:keys [type display params]} grids]
|
||||
(let [props (->> (dissoc params :color)
|
||||
(prefix-keys)
|
||||
(clj->js))]
|
||||
[:> "penpot:grid"
|
||||
(-> props
|
||||
(obj/set! "penpot:color" (get-in params [:color :color]))
|
||||
(obj/set! "penpot:opacity" (get-in params [:color :opacity]))
|
||||
(obj/set! "penpot:type" (d/name type))
|
||||
(cond-> (some? display)
|
||||
(obj/set! "penpot:display" (str display))))]))]))
|
||||
(when (d/not-empty? grids)
|
||||
(mf/html
|
||||
[:> "penpot:grids" #js {}
|
||||
(for [{:keys [type display params]} grids]
|
||||
(let [props (->> (dissoc params :color)
|
||||
(prefix-keys)
|
||||
(clj->js))]
|
||||
[:> "penpot:grid"
|
||||
(-> props
|
||||
(obj/set! "penpot:color" (get-in params [:color :color]))
|
||||
(obj/set! "penpot:opacity" (get-in params [:color :opacity]))
|
||||
(obj/set! "penpot:type" (d/name type))
|
||||
(cond-> (some? display)
|
||||
(obj/set! "penpot:display" (str display))))]))])))
|
||||
|
||||
(mf/defc export-flows
|
||||
[{:keys [flows]}]
|
||||
|
|
|
@ -23,9 +23,15 @@
|
|||
[props]
|
||||
|
||||
(let [render-id (mf/use-ctx muc/render-ctx)
|
||||
{:keys [position-data] :as shape} (obj/get props "shape")
|
||||
{:keys [x y width height position-data] :as shape} (obj/get props "shape")
|
||||
transform (str (gsh/transform-matrix shape))
|
||||
group-props (-> #js {:transform transform}
|
||||
|
||||
;; These position attributes are not really necesary but they are convenient for for the export
|
||||
group-props (-> #js {:transform transform
|
||||
:x x
|
||||
:y y
|
||||
:width width
|
||||
:height height}
|
||||
(attrs/add-style-attrs shape render-id))
|
||||
get-gradient-id
|
||||
(fn [index]
|
||||
|
@ -40,21 +46,21 @@
|
|||
:attr :fill-color-gradient
|
||||
:shape data}]))])
|
||||
|
||||
[:& shape-custom-stroke {:shape shape}
|
||||
[:> :g group-props
|
||||
(for [[index data] (d/enumerate position-data)]
|
||||
(let [props (-> #js {:x (:x data)
|
||||
:y (:y data)
|
||||
:dominantBaseline "ideographic"
|
||||
:style (-> #js {:fontFamily (:font-family data)
|
||||
:fontSize (:font-size data)
|
||||
:fontWeight (:font-weight data)
|
||||
:textTransform (:text-transform data)
|
||||
:textDecoration (:text-decoration data)
|
||||
:fontStyle (:font-style data)
|
||||
:direction (if (:rtl? data) "rtl" "ltr")
|
||||
:whiteSpace "pre"}
|
||||
(attrs/add-fill data (get-gradient-id index)))})]
|
||||
[:> :text props (:text data)]))]]]))
|
||||
[:> :g group-props
|
||||
(for [[index data] (d/enumerate position-data)]
|
||||
(let [props (-> #js {:x (:x data)
|
||||
:y (:y data)
|
||||
:dominantBaseline "ideographic"
|
||||
:style (-> #js {:fontFamily (:font-family data)
|
||||
:fontSize (:font-size data)
|
||||
:fontWeight (:font-weight data)
|
||||
:textTransform (:text-transform data)
|
||||
:textDecoration (:text-decoration data)
|
||||
:fontStyle (:font-style data)
|
||||
:direction (if (:rtl? data) "rtl" "ltr")
|
||||
:whiteSpace "pre"}
|
||||
(attrs/add-fill data (get-gradient-id index)))})]
|
||||
[:& shape-custom-stroke {:shape shape}
|
||||
[:> :text props (:text data)]]))]]))
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue