mirror of
https://github.com/penpot/penpot.git
synced 2026-08-01 19:06:18 +00:00
🐛 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 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 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 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)
|
## 2.11.0 (Unreleased)
|
||||||
|
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
"RPC for plugins runtime."
|
"RPC for plugins runtime."
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
|
[app.common.data.macros :as dm]
|
||||||
[app.common.files.changes-builder :as cb]
|
[app.common.files.changes-builder :as cb]
|
||||||
[app.common.files.helpers :as cfh]
|
[app.common.files.helpers :as cfh]
|
||||||
[app.common.geom.point :as gpt]
|
[app.common.geom.point :as gpt]
|
||||||
@ -409,9 +410,27 @@
|
|||||||
(u/display-not-valid :generateMarkup-type type)
|
(u/display-not-valid :generateMarkup-type type)
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(let [objects (u/locate-objects)
|
(let [resolved-code
|
||||||
shapes (into [] (map u/proxy->shape) shapes)]
|
(->> shapes
|
||||||
(cg/generate-formatted-markup-code objects type 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
|
:generateStyle
|
||||||
(fn [shapes options]
|
(fn [shapes options]
|
||||||
@ -432,18 +451,35 @@
|
|||||||
(u/display-not-valid :generateStyle-includeChildren children?)
|
(u/display-not-valid :generateStyle-includeChildren children?)
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(let [objects (u/locate-objects)
|
(let [resolved-styles
|
||||||
shapes
|
(->> shapes
|
||||||
(->> (into #{} (map u/proxy->shape) shapes)
|
(into
|
||||||
(cfh/clean-loops objects))
|
#{}
|
||||||
|
(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
|
(reduce-kv
|
||||||
(if children?
|
(fn [acc _ shapes]
|
||||||
(->> shapes
|
(let [shape (first shapes)
|
||||||
(mapcat #(cfh/get-children-with-self objects (:id %))))
|
objects (u/locate-objects (:file-id shape) (:page-id shape))
|
||||||
shapes)]
|
|
||||||
(cg/generate-style-code
|
resolved-shapes
|
||||||
objects type shapes shapes-with-children {:with-prelude? prelude?})))))
|
(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
|
:generateFontFaces
|
||||||
(fn [shapes]
|
(fn [shapes]
|
||||||
|
|||||||
@ -32,3 +32,8 @@
|
|||||||
(case type
|
(case type
|
||||||
"css" css/generate-style)]
|
"css" css/generate-style)]
|
||||||
(generate-style objects root-shapes all-shapes options))))
|
(generate-style objects root-shapes all-shapes options))))
|
||||||
|
|
||||||
|
(defn prelude
|
||||||
|
[type]
|
||||||
|
(case type
|
||||||
|
"css" css/prelude))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user