mirror of
https://github.com/penpot/penpot.git
synced 2025-03-14 00:31:34 -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
frontend/src/app
|
@ -479,8 +479,8 @@
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
(defn create-page
|
(defn create-page
|
||||||
[{:keys [file-id]}]
|
[{:keys [page-id file-id]}]
|
||||||
(let [id (uuid/next)]
|
(let [id (or page-id (uuid/next))]
|
||||||
(ptk/reify ::create-page
|
(ptk/reify ::create-page
|
||||||
ev/Event
|
ev/Event
|
||||||
(-data [_]
|
(-data [_]
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
[app.common.types.shape :as cts]
|
[app.common.types.shape :as cts]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[app.main.data.changes :as ch]
|
[app.main.data.changes :as ch]
|
||||||
|
[app.main.data.workspace :as dw]
|
||||||
[app.main.data.workspace.bool :as dwb]
|
[app.main.data.workspace.bool :as dwb]
|
||||||
[app.main.data.workspace.colors :as dwc]
|
[app.main.data.workspace.colors :as dwc]
|
||||||
[app.main.data.workspace.groups :as dwg]
|
[app.main.data.workspace.groups :as dwg]
|
||||||
|
@ -347,7 +348,26 @@
|
||||||
(mapcat #(cfh/get-children-with-self objects (:id %))))
|
(mapcat #(cfh/get-children-with-self objects (:id %))))
|
||||||
shapes)]
|
shapes)]
|
||||||
(cg/generate-style-code
|
(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
|
(defn create-context
|
||||||
[plugin-id]
|
[plugin-id]
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
(:require
|
(:require
|
||||||
[app.common.data.macros :as dm]
|
[app.common.data.macros :as dm]
|
||||||
[app.common.record :as crc]
|
[app.common.record :as crc]
|
||||||
|
[app.common.uuid :as uuid]
|
||||||
[app.main.data.workspace :as dw]
|
[app.main.data.workspace :as dw]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.plugins.page :as page]
|
[app.plugins.page :as page]
|
||||||
|
@ -93,7 +94,18 @@
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(let [file (u/proxy->file self)]
|
(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!
|
(crc/define-properties!
|
||||||
FileProxy
|
FileProxy
|
||||||
|
|
|
@ -131,7 +131,16 @@
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(let [page (u/proxy->page self)]
|
(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!
|
(crc/define-properties!
|
||||||
PageProxy
|
PageProxy
|
||||||
|
|
Loading…
Add table
Reference in a new issue