0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-04-10 14:01:29 -05:00

🐛 Added upload svg with images method

This commit is contained in:
alonso.torres 2025-02-05 15:27:48 +01:00 committed by Andrey Antukh
parent 9c626d22c7
commit 66076f1332
3 changed files with 41 additions and 0 deletions

View file

@ -57,6 +57,7 @@ is a number of cores)
- Fix problem with multiple color changes [Taiga #9631](https://tree.taiga.io/project/penpot/issue/9631)
- Fix problem in plugins with zoomIntoView [Plugins #189](https://github.com/penpot/penpot-plugins/issues/189)
- Fix problem in plugins with renaming components [Taiga #10060](https://tree.taiga.io/project/penpot/issue/10060)
- Added upload svg with images method [#5489](https://github.com/penpot/penpot/issues/5489)
## 2.4.3

View file

@ -476,3 +476,24 @@
(rx/take 1)
(rx/map #(svg/add-svg-shapes id % position {:ignore-selection? true
:change-selection? false}))))))
(defn create-svg-shape-with-images
[file-id id name svg-string position on-success on-error]
(ptk/reify ::create-svg-shape-with-images
ptk/WatchEvent
(watch [_ _ _]
(->> (svg->clj [name svg-string])
(rx/take 1)
(rx/mapcat
(fn [svg-data]
(->> (svg/upload-images svg-data file-id)
(rx/map #(assoc svg-data :image-data %)))))
(rx/map
(fn [svg-data]
(svg/add-svg-shapes
id
svg-data
position
{:ignore-selection? true
:change-selection? false})))
(rx/tap on-success)
(rx/catch on-error)))))

View file

@ -346,6 +346,25 @@
(st/emit! (dwm/create-svg-shape id "svg" svg-string (gpt/point 0 0)))
(shape/shape-proxy plugin-id file-id page-id id))))
:createShapeFromSvgWithImages
(fn [svg-string]
(js/Promise.
(fn [resolve reject]
(cond
(or (not (string? svg-string)) (empty? svg-string))
(do
(u/display-not-valid :createShapeFromSvg "Svg not valid")
(reject "Svg not valid"))
:else
(let [id (uuid/next)
file-id (:current-file-id @st/state)
page-id (:current-page-id @st/state)]
(st/emit! (dwm/create-svg-shape-with-images
file-id id "svg" svg-string (gpt/point 0 0)
#(resolve (shape/shape-proxy plugin-id file-id page-id id))
reject)))))))
:createBoolean
(fn [bool-type shapes]
(let [bool-type (keyword bool-type)]