mirror of
https://github.com/penpot/penpot.git
synced 2025-03-12 07:41:43 -05:00
✨ Pass explicitly the render-id on props handling in path and svg-raw shapes
This commit is contained in:
parent
85a1f7d69e
commit
b1e54a9714
2 changed files with 10 additions and 5 deletions
|
@ -7,6 +7,7 @@
|
|||
(ns app.main.ui.shapes.path
|
||||
(:require
|
||||
[app.common.logging :as log]
|
||||
[app.main.ui.context :as muc]
|
||||
[app.main.ui.shapes.attrs :as attrs]
|
||||
[app.main.ui.shapes.custom-stroke :refer [shape-custom-strokes]]
|
||||
[app.util.object :as obj]
|
||||
|
@ -28,7 +29,8 @@
|
|||
:cause e)
|
||||
"")))
|
||||
|
||||
props (-> (attrs/extract-style-attrs shape)
|
||||
render-id (mf/use-ctx muc/render-id)
|
||||
props (-> (attrs/extract-style-attrs shape render-id)
|
||||
(obj/set! "d" pdata))]
|
||||
|
||||
[:& shape-custom-strokes {:shape shape}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
(:require
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.geom.shapes :as gsh]
|
||||
[app.main.ui.context :as muc]
|
||||
[app.main.ui.shapes.attrs :as usa]
|
||||
[app.util.object :as obj]
|
||||
[app.util.svg :as usvg]
|
||||
|
@ -20,8 +21,8 @@
|
|||
;; Context to store a re-mapping of the ids
|
||||
(def svg-ids-ctx (mf/create-context nil))
|
||||
|
||||
(defn set-styles [attrs shape]
|
||||
(let [custom-attrs (-> (usa/extract-style-attrs shape)
|
||||
(defn set-styles [attrs shape render-id]
|
||||
(let [custom-attrs (-> (usa/extract-style-attrs shape render-id)
|
||||
(obj/without ["transform"]))
|
||||
|
||||
attrs (or attrs {})
|
||||
|
@ -51,8 +52,9 @@
|
|||
{:keys [attrs] :as content} (:content shape)
|
||||
|
||||
ids-mapping (mf/use-memo #(usvg/generate-id-mapping content))
|
||||
render-id (mf/use-ctx muc/render-id)
|
||||
|
||||
attrs (-> (set-styles attrs shape)
|
||||
attrs (-> (set-styles attrs shape render-id)
|
||||
(obj/set! "x" x)
|
||||
(obj/set! "y" y)
|
||||
(obj/set! "width" width)
|
||||
|
@ -73,12 +75,13 @@
|
|||
{:keys [attrs tag]} content
|
||||
|
||||
ids-mapping (mf/use-ctx svg-ids-ctx)
|
||||
render-id (mf/use-ctx muc/render-id)
|
||||
|
||||
attrs (mf/use-memo #(usvg/replace-attrs-ids attrs ids-mapping))
|
||||
|
||||
attrs (translate-shape attrs shape)
|
||||
element-id (get-in content [:attrs :id])
|
||||
attrs (cond-> (set-styles attrs shape)
|
||||
attrs (cond-> (set-styles attrs shape render-id)
|
||||
(and element-id (contains? ids-mapping element-id))
|
||||
(obj/set! "id" (get ids-mapping element-id)))]
|
||||
[:> (name tag) attrs children]))
|
||||
|
|
Loading…
Add table
Reference in a new issue