mirror of
https://github.com/penpot/penpot.git
synced 2025-03-12 15:51:37 -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
|
(ns app.main.ui.shapes.path
|
||||||
(:require
|
(:require
|
||||||
[app.common.logging :as log]
|
[app.common.logging :as log]
|
||||||
|
[app.main.ui.context :as muc]
|
||||||
[app.main.ui.shapes.attrs :as attrs]
|
[app.main.ui.shapes.attrs :as attrs]
|
||||||
[app.main.ui.shapes.custom-stroke :refer [shape-custom-strokes]]
|
[app.main.ui.shapes.custom-stroke :refer [shape-custom-strokes]]
|
||||||
[app.util.object :as obj]
|
[app.util.object :as obj]
|
||||||
|
@ -28,7 +29,8 @@
|
||||||
:cause e)
|
: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))]
|
(obj/set! "d" pdata))]
|
||||||
|
|
||||||
[:& shape-custom-strokes {:shape shape}
|
[:& shape-custom-strokes {:shape shape}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
(:require
|
(:require
|
||||||
[app.common.data.macros :as dm]
|
[app.common.data.macros :as dm]
|
||||||
[app.common.geom.shapes :as gsh]
|
[app.common.geom.shapes :as gsh]
|
||||||
|
[app.main.ui.context :as muc]
|
||||||
[app.main.ui.shapes.attrs :as usa]
|
[app.main.ui.shapes.attrs :as usa]
|
||||||
[app.util.object :as obj]
|
[app.util.object :as obj]
|
||||||
[app.util.svg :as usvg]
|
[app.util.svg :as usvg]
|
||||||
|
@ -20,8 +21,8 @@
|
||||||
;; Context to store a re-mapping of the ids
|
;; Context to store a re-mapping of the ids
|
||||||
(def svg-ids-ctx (mf/create-context nil))
|
(def svg-ids-ctx (mf/create-context nil))
|
||||||
|
|
||||||
(defn set-styles [attrs shape]
|
(defn set-styles [attrs shape render-id]
|
||||||
(let [custom-attrs (-> (usa/extract-style-attrs shape)
|
(let [custom-attrs (-> (usa/extract-style-attrs shape render-id)
|
||||||
(obj/without ["transform"]))
|
(obj/without ["transform"]))
|
||||||
|
|
||||||
attrs (or attrs {})
|
attrs (or attrs {})
|
||||||
|
@ -51,8 +52,9 @@
|
||||||
{:keys [attrs] :as content} (:content shape)
|
{:keys [attrs] :as content} (:content shape)
|
||||||
|
|
||||||
ids-mapping (mf/use-memo #(usvg/generate-id-mapping content))
|
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! "x" x)
|
||||||
(obj/set! "y" y)
|
(obj/set! "y" y)
|
||||||
(obj/set! "width" width)
|
(obj/set! "width" width)
|
||||||
|
@ -73,12 +75,13 @@
|
||||||
{:keys [attrs tag]} content
|
{:keys [attrs tag]} content
|
||||||
|
|
||||||
ids-mapping (mf/use-ctx svg-ids-ctx)
|
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 (mf/use-memo #(usvg/replace-attrs-ids attrs ids-mapping))
|
||||||
|
|
||||||
attrs (translate-shape attrs shape)
|
attrs (translate-shape attrs shape)
|
||||||
element-id (get-in content [:attrs :id])
|
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))
|
(and element-id (contains? ids-mapping element-id))
|
||||||
(obj/set! "id" (get ids-mapping element-id)))]
|
(obj/set! "id" (get ids-mapping element-id)))]
|
||||||
[:> (name tag) attrs children]))
|
[:> (name tag) attrs children]))
|
||||||
|
|
Loading…
Add table
Reference in a new issue