0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-04-12 15:01:28 -05:00

Merge pull request #4840 from penpot/alotor-plugins-4

Alotor plugins 4
This commit is contained in:
Andrey Antukh 2024-07-03 16:49:47 +02:00 committed by GitHub
commit 0d13a12d64
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 80 additions and 21 deletions

View file

@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M19.439 7.85c-.049.322.059.648.289.878l1.568 1.568c.47.47.706 1.087.706 1.704s-.235 1.233-.706 1.704l-1.611 1.611a.98.98 0 0 1-.837.276c-.47-.07-.802-.48-.968-.925a2.501 2.501 0 1 0-3.214 3.214c.446.166.855.497.925.968a.979.979 0 0 1-.276.837l-1.61 1.61a2.404 2.404 0 0 1-1.705.707 2.402 2.402 0 0 1-1.704-.706l-1.568-1.568a1.026 1.026 0 0 0-.877-.29c-.493.074-.84.504-1.02.968a2.5 2.5 0 1 1-3.237-3.237c.464-.18.894-.527.967-1.02a1.026 1.026 0 0 0-.289-.877l-1.568-1.568A2.402 2.402 0 0 1 1.998 12c0-.617.236-1.234.706-1.704L4.23 8.77c.24-.24.581-.353.917-.303.515.077.877.528 1.073 1.01a2.5 2.5 0 1 0 3.259-3.259c-.482-.196-.933-.558-1.01-1.073-.05-.336.062-.676.303-.917l1.525-1.525A2.402 2.402 0 0 1 12 1.998c.617 0 1.234.236 1.704.706l1.568 1.568c.23.23.556.338.877.29.493-.074.84-.504 1.02-.968a2.5 2.5 0 1 1 3.237 3.237c-.464.18-.894.527-.967 1.02Z" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" stroke-width="1.5"><path d="M19.439 7.85c-.049.322.059.648.289.878l1.568 1.568c.47.47.706 1.087.706 1.704s-.235 1.233-.706 1.704l-1.611 1.611a.98.98 0 0 1-.837.276c-.47-.07-.802-.48-.968-.925a2.501 2.501 0 1 0-3.214 3.214c.446.166.855.497.925.968a.979.979 0 0 1-.276.837l-1.61 1.61a2.404 2.404 0 0 1-1.705.707 2.402 2.402 0 0 1-1.704-.706l-1.568-1.568a1.026 1.026 0 0 0-.877-.29c-.493.074-.84.504-1.02.968a2.5 2.5 0 1 1-3.237-3.237c.464-.18.894-.527.967-1.02a1.026 1.026 0 0 0-.289-.877l-1.568-1.568A2.402 2.402 0 0 1 1.998 12c0-.617.236-1.234.706-1.704L4.23 8.77c.24-.24.581-.353.917-.303.515.077.877.528 1.073 1.01a2.5 2.5 0 1 0 3.259-3.259c-.482-.196-.933-.558-1.01-1.073-.05-.336.062-.676.303-.917l1.525-1.525A2.402 2.402 0 0 1 12 1.998c.617 0 1.234.236 1.704.706l1.568 1.568c.23.23.556.338.877.29.493-.074.84-.504 1.02-.968a2.5 2.5 0 1 1 3.237 3.237c-.464.18-.894.527-.967 1.02Z" stroke-linecap="round" stroke-linejoin="round"/></svg>

Before

Width:  |  Height:  |  Size: 1,021 B

After

Width:  |  Height:  |  Size: 1,023 B

View file

@ -23,6 +23,7 @@
[app.main.data.workspace.colors :as dwc]
[app.main.data.workspace.groups :as dwg]
[app.main.data.workspace.media :as dwm]
[app.main.data.workspace.selection :as dws]
[app.main.store :as st]
[app.plugins.events :as events]
[app.plugins.file :as file]
@ -356,7 +357,19 @@
{:name "root" :get #(.getRoot ^js %)}
{:name "currentFile" :get #(.getFile ^js %)}
{:name "currentPage" :get #(.getPage ^js %)}
{:name "selection" :get #(.getSelectedShapes ^js %)}
{:name "selection"
:get #(.getSelectedShapes ^js %)
:set
(fn [_ shapes]
(cond
(or (not (array? shapes)) (not (every? shape/shape-proxy? shapes)))
(u/display-not-valid :selection shapes)
:else
(let [ids (into (d/ordered-set) (map #(obj/get % "$id")) shapes)]
(st/emit! (dws/select-shapes ids)))))}
{:name "viewport" :get #(.getViewport ^js %)}
{:name "currentUser" :get #(.getCurrentUser ^js %)}
{:name "activeUsers" :get #(.getActiveUsers ^js %)}

View file

@ -229,8 +229,8 @@
(when (some? export)
(d/without-nils
{:type (-> (obj/get export "type") parse-keyword)
:scale (obj/get export "scale")
:suffix (obj/get export "suffix")})))
:scale (obj/get export "scale" 1)
:suffix (obj/get export "suffix" "")})))
(defn parse-exports
[^js exports]

View file

@ -36,6 +36,7 @@
[app.main.data.workspace.shape-layout :as dwsl]
[app.main.data.workspace.shapes :as dwsh]
[app.main.data.workspace.texts :as dwt]
[app.main.repo :as rp]
[app.main.store :as st]
[app.plugins.flex :as flex]
[app.plugins.format :as format]
@ -46,7 +47,9 @@
[app.plugins.utils :as u]
[app.util.object :as obj]
[app.util.path.format :as upf]
[cuerdas.core :as str]))
[beicon.v2.core :as rx]
[cuerdas.core :as str]
[promesa.core :as p]))
(def lib-typography-proxy? nil)
(def lib-component-proxy nil)
@ -436,7 +439,34 @@
shape (u/proxy->shape self)]
(when (ctn/in-any-component? objects shape)
(let [[root component] (u/locate-component objects shape)]
(lib-component-proxy $plugin (:component-file root) (:id component)))))))
(lib-component-proxy $plugin (:component-file root) (:id component))))))
(export
[self value]
(let [value (parser/parse-export value)]
(cond
(not (sm/validate ::ctse/export value))
(u/display-not-valid :export value)
:else
(let [payload
{:cmd :export-shapes
:profile-id (:profile-id @st/state)
:wait true
:exports [{:file-id $file
:page-id $page
:object-id $id
:name (obj/get self "name")
:type (:type value :png)
:suffix (:suffix value "")
:scale (:scale value 1)}]}]
(p/create
(fn [resolve reject]
(->> (rp/cmd! :export payload)
(rx/mapcat #(rp/cmd! :export {:cmd :get-resource :wait true :id (:id %) :blob? true}))
(rx/mapcat #(.arrayBuffer %))
(rx/map #(js/Uint8Array. %))
(rx/subs! resolve reject)))))))))
(defn shape-proxy? [p]
(instance? ShapeProxy p))
@ -886,6 +916,12 @@
{:name "height"
:get #(-> % u/proxy->shape :height)}
{:name "bounds"
:get #(-> % u/proxy->shape :points grc/points->rect format/format-bounds)}
{:name "center"
:get #(-> % u/proxy->shape gsh/shape->center format/format-point)}
{:name "rotation"
:get #(-> % u/proxy->shape :rotation)
:set

View file

@ -39,21 +39,25 @@
store))
(defn run-store
[store done events completed-cb]
(let [stream (ptk/input-stream store)]
(->> stream
(rx/take-until (rx/filter #(= :the/end %) stream))
(rx/last)
(rx/tap (fn []
(completed-cb @store)))
(rx/subs! (fn [_] (done))
(fn [cause]
(js/console.log "[error]:" cause))
(fn [_]
(js/console.log "[complete]"))))
(doall (for [event events]
(ptk/emit! store event)))
(ptk/emit! store :the/end)))
([store done events completed-cb]
(run-store store done events completed-cb nil))
([store done events completed-cb stopper]
(let [stream (ptk/input-stream store)]
(->> stream
(rx/take-until (if stopper
(stopper stream)
(rx/filter #(= :the/end %) stream)))
(rx/last)
(rx/tap (fn []
(completed-cb @store)))
(rx/subs! (fn [_] (done))
(fn [cause]
(js/console.log "[error]:" cause))
(fn [_]
(js/console.log "[complete]"))))
(doall (for [event events]
(ptk/emit! store event)))
(ptk/emit! store :the/end))))
(defn get-file-from-store
[store]

View file

@ -5281,6 +5281,9 @@ msgstr "Plugin correctly loaded."
msgid "workspace.plugins.menu.title"
msgstr "Plugins"
msgid "workspace.toolbar.plugins"
msgstr "Plugins"
msgid "workspace.plugins.menu.plugins-manager"
msgstr "Plugins manager"

View file

@ -5361,6 +5361,9 @@ msgstr "Pulsar para cerrar la ruta"
msgid "workspace.plugins.title"
msgstr "Extensiones"
msgid "workspace.toolbar.plugins"
msgstr "Extensiones"
msgid "workspace.plugins.search-placeholder"
msgstr "Intruduzca URL de la extensión"