mirror of
https://github.com/penpot/penpot.git
synced 2025-03-12 15:51:37 -05:00
🐛 Importing old penpot files generates frames with 0.01 as width and height
https://tree.taiga.io/project/penpot/issue/3455
This commit is contained in:
parent
910fb55b69
commit
f33360a22b
1 changed files with 16 additions and 2 deletions
|
@ -7,6 +7,7 @@
|
|||
(ns app.util.import.parser
|
||||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.geom.matrix :as gmt]
|
||||
[app.common.geom.point :as gpt]
|
||||
[app.common.spec.interactions :as cti]
|
||||
|
@ -213,16 +214,29 @@
|
|||
(reduce add-attrs node-attrs))
|
||||
|
||||
(= type :frame)
|
||||
(let [;; The nodes with the "frame-background" class can have some anidation depending on the strokes they have
|
||||
(let [;; Old .penpot files doesn't have "g" nodes. They have a clipPath reference as a node attribute
|
||||
to-url #(dm/str "url(#" % ")")
|
||||
frame-clip-rect-node (->> (find-all-nodes node :defs)
|
||||
(mapcat #(find-all-nodes % :clipPath))
|
||||
(filter #(= (to-url (:id (:attrs %))) (:clip-path node-attrs)))
|
||||
(mapcat #(find-all-nodes % #{:rect :path}))
|
||||
(first))
|
||||
|
||||
;; The nodes with the "frame-background" class can have some anidation depending on the strokes they have
|
||||
g-nodes (find-all-nodes node :g)
|
||||
defs-nodes (flatten (map #(find-all-nodes % :defs) g-nodes))
|
||||
gg-nodes (flatten (map #(find-all-nodes % :g) g-nodes))
|
||||
|
||||
|
||||
rect-nodes (flatten [[(find-all-nodes node :rect)]
|
||||
(map #(find-all-nodes % #{:rect :path}) defs-nodes)
|
||||
(map #(find-all-nodes % #{:rect :path}) g-nodes)
|
||||
(map #(find-all-nodes % #{:rect :path}) gg-nodes)])
|
||||
svg-node (d/seek #(= "frame-background" (get-in % [:attrs :class])) rect-nodes)]
|
||||
(merge (add-attrs {} (:attrs svg-node)) node-attrs))
|
||||
(merge
|
||||
(add-attrs {} (:attrs frame-clip-rect-node))
|
||||
(add-attrs {} (:attrs svg-node))
|
||||
node-attrs))
|
||||
|
||||
(= type :svg-raw)
|
||||
(let [svg-content (get-data node :penpot:svg-content)
|
||||
|
|
Loading…
Add table
Reference in a new issue