mirror of https://github.com/penpot/penpot.git
🐛 Fix problem with plugins generating code for pages different than current one
This commit is contained in:
parent
93fb54c116
commit
23f49237f8
|
|
@ -21,6 +21,7 @@
|
|||
- Fix problem with multiple selection and shadows [Github #7437](https://github.com/penpot/penpot/issues/7437)
|
||||
- Fix search shortcut [Taiga #10265](https://tree.taiga.io/project/penpot/issue/10265)
|
||||
- Fix shortcut conflict in text editor (increase/decrease font size vs word selection)
|
||||
- Fix problem with plugins generating code for pages different than current one [Taiga #12312](https://tree.taiga.io/project/penpot/issue/12312)
|
||||
|
||||
## 2.11.0 (Unreleased)
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
"RPC for plugins runtime."
|
||||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.files.changes-builder :as cb]
|
||||
[app.common.files.helpers :as cfh]
|
||||
[app.common.geom.point :as gpt]
|
||||
|
|
@ -409,9 +410,27 @@
|
|||
(u/display-not-valid :generateMarkup-type type)
|
||||
|
||||
:else
|
||||
(let [objects (u/locate-objects)
|
||||
shapes (into [] (map u/proxy->shape) shapes)]
|
||||
(cg/generate-formatted-markup-code objects type shapes)))))
|
||||
(let [resolved-code
|
||||
(->> shapes
|
||||
(into
|
||||
#{}
|
||||
(map (fn [s]
|
||||
(-> (u/proxy->shape s)
|
||||
(assoc :page-id (obj/get s "$page"))
|
||||
(assoc :file-id (obj/get s "$file"))))))
|
||||
(group-by :page-id)
|
||||
|
||||
(reduce-kv
|
||||
(fn [acc _ shapes]
|
||||
(let [shape (first shapes)
|
||||
objects (u/locate-objects (:file-id shape) (:page-id shape))
|
||||
resolved-shapes
|
||||
(->> (cfh/clean-loops objects shapes)
|
||||
(mapcat #(cfh/get-children-with-self objects (:id %))))]
|
||||
(conj acc (cg/generate-formatted-markup-code objects type resolved-shapes))))
|
||||
[]))]
|
||||
|
||||
(->> resolved-code (str/join "\n"))))))
|
||||
|
||||
:generateStyle
|
||||
(fn [shapes options]
|
||||
|
|
@ -432,18 +451,35 @@
|
|||
(u/display-not-valid :generateStyle-includeChildren children?)
|
||||
|
||||
:else
|
||||
(let [objects (u/locate-objects)
|
||||
shapes
|
||||
(->> (into #{} (map u/proxy->shape) shapes)
|
||||
(cfh/clean-loops objects))
|
||||
(let [resolved-styles
|
||||
(->> shapes
|
||||
(into
|
||||
#{}
|
||||
(map (fn [s]
|
||||
(-> (u/proxy->shape s)
|
||||
(assoc :page-id (obj/get s "$page"))
|
||||
(assoc :file-id (obj/get s "$file"))))))
|
||||
(group-by :page-id)
|
||||
|
||||
shapes-with-children
|
||||
(if children?
|
||||
(->> shapes
|
||||
(mapcat #(cfh/get-children-with-self objects (:id %))))
|
||||
shapes)]
|
||||
(cg/generate-style-code
|
||||
objects type shapes shapes-with-children {:with-prelude? prelude?})))))
|
||||
(reduce-kv
|
||||
(fn [acc _ shapes]
|
||||
(let [shape (first shapes)
|
||||
objects (u/locate-objects (:file-id shape) (:page-id shape))
|
||||
|
||||
resolved-shapes
|
||||
(cond->> (cfh/clean-loops objects shapes)
|
||||
children?
|
||||
(mapcat #(cfh/get-children-with-self objects (:id %))))]
|
||||
|
||||
(conj
|
||||
acc
|
||||
(cg/generate-style-code
|
||||
objects type shapes resolved-shapes {:with-prelude? prelude?}))))
|
||||
[]))]
|
||||
(dm/str
|
||||
(if prelude? (cg/prelude type) "")
|
||||
(->> resolved-styles
|
||||
(str/join "\n\n")))))))
|
||||
|
||||
:generateFontFaces
|
||||
(fn [shapes]
|
||||
|
|
|
|||
|
|
@ -32,3 +32,8 @@
|
|||
(case type
|
||||
"css" css/generate-style)]
|
||||
(generate-style objects root-shapes all-shapes options))))
|
||||
|
||||
(defn prelude
|
||||
[type]
|
||||
(case type
|
||||
"css" css/prelude))
|
||||
|
|
|
|||
Loading…
Reference in New Issue