mirror of
https://github.com/penpot/penpot.git
synced 2025-06-06 10:51:39 +02:00
🎉 Export to PDF all artboards of one page
This commit is contained in:
parent
255177d12b
commit
203473c965
12 changed files with 136 additions and 15 deletions
|
@ -9,6 +9,7 @@
|
|||
[app.common.data :as d]
|
||||
[app.common.math :as mth]
|
||||
[app.config :as cf]
|
||||
[app.main.data.messages :as dm]
|
||||
[app.main.data.modal :as modal]
|
||||
[app.main.data.workspace :as dw]
|
||||
[app.main.data.workspace.shortcuts :as sc]
|
||||
|
@ -92,10 +93,12 @@
|
|||
;; --- Header Users
|
||||
|
||||
(mf/defc menu
|
||||
[{:keys [layout project file team-id] :as props}]
|
||||
[{:keys [layout project file team-id page-id] :as props}]
|
||||
(let [show-menu? (mf/use-state false)
|
||||
editing? (mf/use-state false)
|
||||
|
||||
frames (mf/deref refs/workspace-frames)
|
||||
|
||||
edit-input-ref (mf/use-ref nil)
|
||||
|
||||
add-shared-fn
|
||||
|
@ -142,7 +145,7 @@
|
|||
(dom/prevent-default event)
|
||||
(reset! editing? true))
|
||||
|
||||
on-export-files
|
||||
on-export-file
|
||||
(mf/use-callback
|
||||
(mf/deps file team-id)
|
||||
(fn [_]
|
||||
|
@ -159,7 +162,24 @@
|
|||
{:type :export
|
||||
:team-id team-id
|
||||
:has-libraries? (->> files (some :has-libraries?))
|
||||
:files files})))))))]
|
||||
:files files})))))))
|
||||
|
||||
on-export-frames
|
||||
(mf/use-callback
|
||||
(mf/deps file)
|
||||
(fn [_]
|
||||
(let [filename (str (:name file) ".pdf")
|
||||
frame-ids (mapv :id frames)]
|
||||
(->> (rp/query! :export-frames
|
||||
{:name (:name file)
|
||||
:file-id (:id file)
|
||||
:page-id page-id
|
||||
:frame-ids frame-ids})
|
||||
(rx/subs
|
||||
(fn [body]
|
||||
(dom/trigger-download filename body))
|
||||
(fn [_error]
|
||||
(st/emit! (dm/error (tr "errors.unexpected-error")))))))))]
|
||||
|
||||
(mf/use-effect
|
||||
(mf/deps @editing?)
|
||||
|
@ -256,9 +276,12 @@
|
|||
[:li {:on-click on-add-shared}
|
||||
[:span (tr "dashboard.add-shared")]])
|
||||
|
||||
[:li.export-file {:on-click on-export-files}
|
||||
[:li.export-file {:on-click on-export-file}
|
||||
[:span (tr "dashboard.export-single")]]
|
||||
|
||||
[:li.export-file {:on-click on-export-frames}
|
||||
[:span (tr "dashboard.export-frames")]]
|
||||
|
||||
(when (contains? @cf/flags :user-feedback)
|
||||
[:li.feedback {:on-click (st/emitf (rt/nav :settings-feedback))}
|
||||
[:span (tr "labels.give-feedback")]
|
||||
|
@ -290,7 +313,8 @@
|
|||
[:& menu {:layout layout
|
||||
:project project
|
||||
:file file
|
||||
:team-id team-id}]
|
||||
:team-id team-id
|
||||
:page-id page-id}]
|
||||
|
||||
[:div.users-section
|
||||
[:& active-sessions]]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue