mirror of
https://github.com/penpot/penpot.git
synced 2025-05-28 09:06:12 +02:00
Merge remote-tracking branch 'origin/staging' into develop
This commit is contained in:
commit
e6a9e27802
17 changed files with 143 additions and 53 deletions
|
@ -18,6 +18,7 @@
|
|||
[app.common.types.shape-tree :as ctst]
|
||||
[app.main.data.changes :as dch]
|
||||
[app.main.data.comments :as dc]
|
||||
[app.main.data.events :as ev]
|
||||
[app.main.data.workspace.edition :as dwe]
|
||||
[app.main.data.workspace.selection :as dws]
|
||||
[app.main.data.workspace.state-helpers :as wsh]
|
||||
|
@ -129,7 +130,9 @@
|
|||
(dwu/commit-undo-transaction undo-id))
|
||||
(when (cfh/text-shape? shape)
|
||||
(->> (rx/of (dwe/start-edition-mode (:id shape)))
|
||||
(rx/observe-on :async)))))))))
|
||||
(rx/observe-on :async)))
|
||||
(when (cfh/frame-shape? shape)
|
||||
(rx/of (ptk/event ::ev/event {::ev/name "add-frame"})))))))))
|
||||
|
||||
(defn move-shapes-into-frame
|
||||
[frame-id shapes]
|
||||
|
|
|
@ -40,8 +40,7 @@
|
|||
[app.plugins.viewport :as viewport]
|
||||
[app.util.code-gen :as cg]
|
||||
[app.util.object :as obj]
|
||||
[beicon.v2.core :as rx]
|
||||
[promesa.core :as p]))
|
||||
[beicon.v2.core :as rx]))
|
||||
|
||||
;;
|
||||
;; PLUGINS PUBLIC API - The plugins will able to access this functions
|
||||
|
@ -174,7 +173,7 @@
|
|||
|
||||
:else
|
||||
(let [file-id (:current-file-id @st/state)]
|
||||
(p/create
|
||||
(js/Promise.
|
||||
(fn [resolve reject]
|
||||
(->> (dwm/upload-media-url name file-id url)
|
||||
(rx/take 1)
|
||||
|
@ -184,7 +183,7 @@
|
|||
(uploadMediaData
|
||||
[_ name data mime-type]
|
||||
(let [file-id (:current-file-id @st/state)]
|
||||
(p/create
|
||||
(js/Promise.
|
||||
(fn [resolve reject]
|
||||
(->> (dwm/process-blobs
|
||||
{:file-id file-id
|
||||
|
|
|
@ -19,13 +19,12 @@
|
|||
[app.plugins.shape :as shape]
|
||||
[app.plugins.user :as user]
|
||||
[app.plugins.utils :as u]
|
||||
[beicon.v2.core :as rx]
|
||||
[promesa.core :as p]))
|
||||
[beicon.v2.core :as rx]))
|
||||
|
||||
(deftype CommentProxy [$plugin $file $page $thread $id]
|
||||
Object
|
||||
(remove [_]
|
||||
(p/create
|
||||
(js/Promise.
|
||||
(fn [resolve reject]
|
||||
(cond
|
||||
(not (r/check-permission $plugin "comment:write"))
|
||||
|
@ -79,7 +78,7 @@
|
|||
Object
|
||||
(findComments
|
||||
[_]
|
||||
(p/create
|
||||
(js/Promise.
|
||||
(fn [resolve reject]
|
||||
(cond
|
||||
(not (r/check-permission $plugin "comment:read"))
|
||||
|
@ -106,7 +105,7 @@
|
|||
(u/display-not-valid :reply "Not valid")
|
||||
|
||||
:else
|
||||
(p/create
|
||||
(js/Promise.
|
||||
(fn [resolve reject]
|
||||
(->> (rp/cmd! :create-comment {:thread-id $id :content content})
|
||||
(rx/subs! #(resolve (comment-proxy $plugin $file $page $id $users %)) reject))))))
|
||||
|
@ -121,9 +120,9 @@
|
|||
(u/display-not-valid :remove "Cannot change content from another user's comments")
|
||||
|
||||
:else
|
||||
(p/create
|
||||
(js/Promise.
|
||||
(fn [resolve]
|
||||
(p/create
|
||||
(js/Promise.
|
||||
(st/emit! (dc/delete-comment-thread-on-workspace {:id $id} #(resolve))))))))))
|
||||
|
||||
(defn comment-thread-proxy? [p]
|
||||
|
|
|
@ -21,8 +21,7 @@
|
|||
[app.plugins.utils :as u]
|
||||
[app.util.http :as http]
|
||||
[app.util.object :as obj]
|
||||
[beicon.v2.core :as rx]
|
||||
[promesa.core :as p]))
|
||||
[beicon.v2.core :as rx]))
|
||||
|
||||
(deftype FileProxy [$plugin $id]
|
||||
Object
|
||||
|
@ -133,7 +132,7 @@
|
|||
:binfile-v3
|
||||
:binfile-v1)
|
||||
"zip" :legacy-zip)]
|
||||
(p/create
|
||||
(js/Promise.
|
||||
(fn [resolve reject]
|
||||
(->> (uw/ask-many!
|
||||
{:cmd :export-files
|
||||
|
|
|
@ -30,8 +30,7 @@
|
|||
[app.plugins.utils :as u]
|
||||
[app.util.object :as obj]
|
||||
[beicon.v2.core :as rx]
|
||||
[potok.v2.core :as ptk]
|
||||
[promesa.core :as p]))
|
||||
[potok.v2.core :as ptk]))
|
||||
|
||||
(declare lib-color-proxy)
|
||||
(declare lib-typography-proxy)
|
||||
|
@ -915,7 +914,7 @@
|
|||
(availableLibraries
|
||||
[_]
|
||||
(let [team-id (:current-team-id @st/state)]
|
||||
(p/create
|
||||
(js/Promise.
|
||||
(fn [resolve reject]
|
||||
(let [current-libs (into #{} (map first) (get @st/state :workspace-libraries))]
|
||||
(->> (rp/cmd! :get-team-shared-files {:team-id team-id})
|
||||
|
@ -939,7 +938,7 @@
|
|||
(u/display-not-valid :connectLibrary "Plugin doesn't have 'library:write' permission")
|
||||
|
||||
:else
|
||||
(p/create
|
||||
(js/Promise.
|
||||
(fn [resolve reject]
|
||||
(cond
|
||||
(not (string? library-id))
|
||||
|
|
|
@ -29,8 +29,7 @@
|
|||
[app.plugins.utils :as u]
|
||||
[app.util.object :as obj]
|
||||
[beicon.v2.core :as rx]
|
||||
[cuerdas.core :as str]
|
||||
[promesa.core :as p]))
|
||||
[cuerdas.core :as str]))
|
||||
|
||||
(deftype FlowProxy [$plugin $file $page $id]
|
||||
Object
|
||||
|
@ -288,7 +287,7 @@
|
|||
(some? board)
|
||||
(-> (update :x - (:x board))
|
||||
(update :y - (:y board))))]
|
||||
(p/create
|
||||
(js/Promise.
|
||||
(fn [resolve]
|
||||
(st/emit!
|
||||
(dc/create-thread-on-workspace
|
||||
|
@ -315,10 +314,10 @@
|
|||
(u/display-not-valid :removeCommentThread "Plugin doesn't have 'content:write' permission")
|
||||
|
||||
:else
|
||||
(p/create
|
||||
(js/Promise.
|
||||
(fn [resolve]
|
||||
(let [thread-id (obj/get thread "$id")]
|
||||
(p/create
|
||||
(js/Promise.
|
||||
(st/emit! (dc/delete-comment-thread-on-workspace {:id thread-id} #(resolve)))))))))
|
||||
|
||||
(findCommentThreads
|
||||
|
@ -326,7 +325,7 @@
|
|||
(let [only-yours (boolean (obj/get criteria "onlyYours" false))
|
||||
show-resolved (boolean (obj/get criteria "showResolved" true))
|
||||
user-id (-> @st/state :profile :id)]
|
||||
(p/create
|
||||
(js/Promise.
|
||||
(fn [resolve reject]
|
||||
(cond
|
||||
(not (r/check-permission $plugin "comment:read"))
|
||||
|
|
|
@ -52,8 +52,7 @@
|
|||
[app.util.object :as obj]
|
||||
[app.util.path.format :as upf]
|
||||
[beicon.v2.core :as rx]
|
||||
[cuerdas.core :as str]
|
||||
[promesa.core :as p]))
|
||||
[cuerdas.core :as str]))
|
||||
|
||||
(declare shape-proxy)
|
||||
(declare shape-proxy?)
|
||||
|
@ -542,7 +541,7 @@
|
|||
:type (:type value :png)
|
||||
:suffix (:suffix value "")
|
||||
:scale (:scale value 1)}]}]
|
||||
(p/create
|
||||
(js/Promise.
|
||||
(fn [resolve reject]
|
||||
(->> (rp/cmd! :export payload)
|
||||
(rx/mapcat #(rp/cmd! :export {:cmd :get-resource :wait true :id (:id %) :blob? true}))
|
||||
|
@ -952,7 +951,7 @@
|
|||
|
||||
;; Geometry properties
|
||||
{:name "x"
|
||||
:get #(-> % u/proxy->shape :x)
|
||||
:get #(-> % u/proxy->shape :points grc/points->rect :x)
|
||||
:set
|
||||
(fn [self value]
|
||||
(let [id (obj/get self "$id")]
|
||||
|
@ -967,7 +966,7 @@
|
|||
(st/emit! (dw/update-position id {:x value})))))}
|
||||
|
||||
{:name "y"
|
||||
:get #(-> % u/proxy->shape :y)
|
||||
:get #(-> % u/proxy->shape :points grc/points->rect :y)
|
||||
:set
|
||||
(fn [self value]
|
||||
(let [id (obj/get self "$id")]
|
||||
|
@ -991,9 +990,10 @@
|
|||
{:name "parentX"
|
||||
:get (fn [self]
|
||||
(let [shape (u/proxy->shape self)
|
||||
shape-x (-> shape :points grc/points->rect :x)
|
||||
parent-id (:parent-id shape)
|
||||
parent (u/locate-shape (obj/get self "$file") (obj/get self "$page") parent-id)]
|
||||
(- (:x shape) (:x parent))))
|
||||
(- shape-x (:x parent))))
|
||||
:set
|
||||
(fn [self value]
|
||||
(cond
|
||||
|
@ -1013,10 +1013,11 @@
|
|||
{:name "parentY"
|
||||
:get (fn [self]
|
||||
(let [shape (u/proxy->shape self)
|
||||
shape-y (-> shape :points grc/points->rect :y)
|
||||
parent-id (:parent-id shape)
|
||||
parent (u/locate-shape (obj/get self "$file") (obj/get self "$page") parent-id)
|
||||
parent-y (:y parent)]
|
||||
(- (:y shape) parent-y)))
|
||||
(- shape-y parent-y)))
|
||||
:set
|
||||
(fn [self value]
|
||||
(cond
|
||||
|
@ -1036,10 +1037,11 @@
|
|||
{:name "boardX"
|
||||
:get (fn [self]
|
||||
(let [shape (u/proxy->shape self)
|
||||
shape-x (-> shape :points grc/points->rect :x)
|
||||
frame-id (:parent-id shape)
|
||||
frame (u/locate-shape (obj/get self "$file") (obj/get self "$page") frame-id)
|
||||
frame-x (:x frame)]
|
||||
(- (:x shape) frame-x)))
|
||||
(- shape-x frame-x)))
|
||||
:set
|
||||
(fn [self value]
|
||||
(cond
|
||||
|
@ -1059,10 +1061,11 @@
|
|||
{:name "boardY"
|
||||
:get (fn [self]
|
||||
(let [shape (u/proxy->shape self)
|
||||
shape-y (-> shape :points grc/points->rect :y)
|
||||
frame-id (:parent-id shape)
|
||||
frame (u/locate-shape (obj/get self "$file") (obj/get self "$page") frame-id)
|
||||
frame-y (:y frame)]
|
||||
(- (:y shape) frame-y)))
|
||||
(- shape-y frame-y)))
|
||||
:set
|
||||
(fn [self value]
|
||||
(cond
|
||||
|
@ -1080,10 +1083,10 @@
|
|||
(st/emit! (dw/update-position id {:y (+ frame-y value)})))))}
|
||||
|
||||
{:name "width"
|
||||
:get #(-> % u/proxy->shape :width)}
|
||||
:get #(-> % u/proxy->shape :selrect :width)}
|
||||
|
||||
{:name "height"
|
||||
:get #(-> % u/proxy->shape :height)}
|
||||
:get #(-> % u/proxy->shape :selrect :height)}
|
||||
|
||||
{:name "bounds"
|
||||
:get #(-> % u/proxy->shape :points grc/points->rect format/format-bounds)}
|
||||
|
|
|
@ -12,8 +12,7 @@
|
|||
[app.common.types.container :as ctn]
|
||||
[app.common.types.file :as ctf]
|
||||
[app.main.store :as st]
|
||||
[app.util.object :as obj]
|
||||
[promesa.core :as p]))
|
||||
[app.util.object :as obj]))
|
||||
|
||||
(defn locate-file
|
||||
[id]
|
||||
|
@ -175,7 +174,7 @@
|
|||
[]
|
||||
(let [ret-v (atom nil)
|
||||
ret-p
|
||||
(p/create
|
||||
(js/Promise.
|
||||
(fn [resolve _]
|
||||
(add-watch
|
||||
ret-v
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue