mirror of
https://github.com/penpot/penpot.git
synced 2025-03-13 16:21:57 -05:00
✨ Page functions for plugins api
This commit is contained in:
parent
d13b9ef3ea
commit
6454e878dd
4 changed files with 46 additions and 5 deletions
|
@ -479,8 +479,8 @@
|
|||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn create-page
|
||||
[{:keys [file-id]}]
|
||||
(let [id (uuid/next)]
|
||||
[{:keys [page-id file-id]}]
|
||||
(let [id (or page-id (uuid/next))]
|
||||
(ptk/reify ::create-page
|
||||
ev/Event
|
||||
(-data [_]
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
[app.common.types.shape :as cts]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.main.data.changes :as ch]
|
||||
[app.main.data.workspace :as dw]
|
||||
[app.main.data.workspace.bool :as dwb]
|
||||
[app.main.data.workspace.colors :as dwc]
|
||||
[app.main.data.workspace.groups :as dwg]
|
||||
|
@ -347,7 +348,26 @@
|
|||
(mapcat #(cfh/get-children-with-self objects (:id %))))
|
||||
shapes)]
|
||||
(cg/generate-style-code
|
||||
objects type shapes shapes-with-children {:with-prelude? prelude?}))))))
|
||||
objects type shapes shapes-with-children {:with-prelude? prelude?})))))
|
||||
|
||||
(openViewer
|
||||
[_]
|
||||
(let [params {:page-id (:current-page-id @st/state)
|
||||
:file-id (:current-file-id @st/state)
|
||||
:section "interactions"}]
|
||||
(st/emit! (dw/go-to-viewer params))))
|
||||
|
||||
(createPage
|
||||
[_]
|
||||
(let [file-id (:current-file-id @st/state)
|
||||
id (uuid/next)]
|
||||
(st/emit! (dw/create-page {:page-id id :file-id file-id}))
|
||||
(page/page-proxy $plugin file-id id)))
|
||||
|
||||
(openPage
|
||||
[_ page]
|
||||
(let [id (obj/get page "$id")]
|
||||
(st/emit! (dw/go-to-page id)))))
|
||||
|
||||
(defn create-context
|
||||
[plugin-id]
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
(:require
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.record :as crc]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.main.data.workspace :as dw]
|
||||
[app.main.store :as st]
|
||||
[app.plugins.page :as page]
|
||||
|
@ -93,7 +94,18 @@
|
|||
|
||||
:else
|
||||
(let [file (u/proxy->file self)]
|
||||
(apply array (keys (dm/get-in file [:data :plugin-data (keyword "shared" namespace)])))))))
|
||||
(apply array (keys (dm/get-in file [:data :plugin-data (keyword "shared" namespace)]))))))
|
||||
|
||||
(createPage
|
||||
[_]
|
||||
(cond
|
||||
(not (r/check-permission $plugin "content:write"))
|
||||
(u/display-not-valid :createPage "Plugin doesn't have 'content:write' permission")
|
||||
|
||||
:else
|
||||
(let [page-id (uuid/next)]
|
||||
(st/emit! (dw/create-page {:page-id page-id :file-id $id}))
|
||||
(page/page-proxy $plugin $id page-id)))))
|
||||
|
||||
(crc/define-properties!
|
||||
FileProxy
|
||||
|
|
|
@ -131,7 +131,16 @@
|
|||
|
||||
:else
|
||||
(let [page (u/proxy->page self)]
|
||||
(apply array (keys (dm/get-in page [:options :plugin-data (keyword "shared" namespace)])))))))
|
||||
(apply array (keys (dm/get-in page [:options :plugin-data (keyword "shared" namespace)]))))))
|
||||
|
||||
(openPage
|
||||
[_]
|
||||
(cond
|
||||
(not (r/check-permission $plugin "content:read"))
|
||||
(u/display-not-valid :openPage "Plugin doesn't have 'content:read' permission")
|
||||
|
||||
:else
|
||||
(st/emit! (dw/go-to-page $id)))))
|
||||
|
||||
(crc/define-properties!
|
||||
PageProxy
|
||||
|
|
Loading…
Add table
Reference in a new issue