mirror of
https://github.com/penpot/penpot.git
synced 2026-02-05 04:02:03 -05:00
Compare commits
5 Commits
alotor-plu
...
superalex-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
86cb6b6f51 | ||
|
|
f3e0c2409e | ||
|
|
8584e070f9 | ||
|
|
49ea9a30a9 | ||
|
|
24c8fc484f |
@@ -38,6 +38,26 @@
|
||||
(assoc :path "/render.html")
|
||||
(assoc :query (u/map->query-string params)))))
|
||||
|
||||
(sync-page-size! [dom]
|
||||
(bw/eval! dom
|
||||
(fn [elem]
|
||||
(let [rect (.getBoundingClientRect ^js elem)
|
||||
width (js/Math.max (or (some-> (.getAttribute ^js elem "width") js/parseFloat) 0)
|
||||
(.-width rect))
|
||||
height (js/Math.max (or (some-> (.getAttribute ^js elem "height") js/parseFloat) 0)
|
||||
(.-height rect))
|
||||
width-px (str width "px")
|
||||
height-px (str height "px")
|
||||
style-node (or (.getElementById js/document "penpot-pdf-page-size")
|
||||
(let [node (.createElement js/document "style")]
|
||||
(set! (.-id node) "penpot-pdf-page-size")
|
||||
(.appendChild (.-head js/document) node)
|
||||
node))]
|
||||
(set! (.-textContent style-node)
|
||||
(str "@page { size: " width-px " " height-px "; margin: 0; }\n"
|
||||
"html, body, #app { margin: 0; padding: 0;"
|
||||
"width: " width-px "; height: " height-px "; }"))))))
|
||||
|
||||
(render-object [page base-uri {:keys [id] :as object}]
|
||||
(p/let [uri (prepare-uri base-uri id)
|
||||
path (sh/tempfile :prefix "penpot.tmp.pdf." :suffix (mime/get-extension type))]
|
||||
@@ -45,6 +65,7 @@
|
||||
(bw/nav! page uri)
|
||||
(p/let [dom (bw/select page (dm/str "#screenshot-" id))]
|
||||
(bw/wait-for dom)
|
||||
(sync-page-size! dom)
|
||||
(bw/screenshot dom {:full-page? true})
|
||||
(bw/sleep page 2000) ; the good old fix with sleep
|
||||
(bw/pdf page {:path path})
|
||||
|
||||
@@ -78,13 +78,15 @@
|
||||
(fn []
|
||||
(close-modals)
|
||||
;; FIXME: move set-mode to uri?
|
||||
(st/emit! (dw/set-options-mode :design)
|
||||
(st/emit! :interrupt
|
||||
(dw/set-options-mode :design)
|
||||
(dcm/go-to-dashboard-recent))))
|
||||
|
||||
nav-to-project
|
||||
(mf/use-fn
|
||||
(mf/deps project-id)
|
||||
#(st/emit! (dcm/go-to-dashboard-files ::rt/new-window true :project-id project-id)))]
|
||||
#(st/emit! :interrupt
|
||||
(dcm/go-to-dashboard-files ::rt/new-window true :project-id project-id)))]
|
||||
|
||||
(mf/with-effect [editing?]
|
||||
(when ^boolean editing?
|
||||
|
||||
Reference in New Issue
Block a user