0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-24 07:29:08 -05:00

Improve page svg downloading code.

This commit is contained in:
Andrey Antukh 2016-08-28 22:55:11 +03:00
parent fec40eae54
commit 83e386e95a
No known key found for this signature in database
GPG key ID: 4DFEBCB8316A8B95
2 changed files with 11 additions and 8 deletions

View file

@ -7,7 +7,6 @@
(ns uxbox.main
(:require [uxbox.util.rstore :as rs]
[uxbox.main.exports]
[uxbox.main.state :as st]
[uxbox.main.locales :as lc]
[uxbox.main.ui :as ui]))

View file

@ -38,14 +38,18 @@
;; --- Download Lightbox (Component)
(defn- download-page-svg
[page]
(let [content (exports/render-page page)
[id]
(let [page (get-in @st/state [:pages-by-id id])
page-name (:name page)
content (exports/render-page id)
blob (blob/create content "image/svg+xml")
uri (blob/create-uri blob)
link (.createElement js/document "a")
event (js/MouseEvent. "click")]
;; FIXME: use str/slug for proper file naming
(.setAttribute link "href" uri)
(.setAttribute link "download" "page.svg")
(.setAttribute link "download" (str page-name ".svg"))
(.appendChild (.-body js/document) link)
(.dispatchEvent link event)
@ -60,10 +64,10 @@
(udl/close!))
(download-page [event]
(dom/prevent-default event)
(let [page (-> (mx/ref-node own "page")
(let [id (-> (mx/ref-node own "page")
(dom/get-value)
(read-string))]
(download-page-svg page)
(download-page-svg id)
(udl/close!)))
(download-zip [event]
(dom/prevent-default event))