mirror of
https://github.com/penpot/penpot.git
synced 2026-02-24 10:47:49 -05:00
Compare commits
1 Commits
staging
...
niwinz-sta
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
931afe912a |
@@ -14,6 +14,7 @@
|
||||
[app.main.data.modal :as modal]
|
||||
[app.main.data.notifications :as ntf]
|
||||
[app.main.store :as st]
|
||||
[app.plugins.flags :as pflag]
|
||||
[app.plugins.register :as preg]
|
||||
[app.util.globals :as ug]
|
||||
[app.util.http :as http]
|
||||
@@ -44,20 +45,6 @@
|
||||
(update [_ state]
|
||||
(update-in state [:workspace-local :open-plugins] (fnil conj #{}) id))))
|
||||
|
||||
(defn reset-plugin-flags
|
||||
[id]
|
||||
(ptk/reify ::reset-plugin-flags
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(update-in state [:workspace-local :plugin-flags] assoc id {}))))
|
||||
|
||||
(defn set-plugin-flag
|
||||
[id key value]
|
||||
(ptk/reify ::set-plugin-flag
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(update-in state [:workspace-local :plugin-flags id] assoc key value))))
|
||||
|
||||
(defn remove-current-plugin
|
||||
[id]
|
||||
(ptk/reify ::remove-current-plugin
|
||||
@@ -68,8 +55,8 @@
|
||||
(defn- load-plugin!
|
||||
[{:keys [plugin-id name description host code icon permissions]}]
|
||||
(try
|
||||
(st/emit! (save-current-plugin plugin-id)
|
||||
(reset-plugin-flags plugin-id))
|
||||
(st/emit! (pflag/clear plugin-id)
|
||||
(save-current-plugin plugin-id))
|
||||
|
||||
(.ɵloadPlugin
|
||||
^js ug/global
|
||||
|
||||
@@ -1173,7 +1173,8 @@
|
||||
(when add-component-to-variant?
|
||||
(rx/of (ev/event {::ev/name "add-component-to-variant"})))
|
||||
(when add-new-variant?
|
||||
(rx/of (ev/event {::ev/name "add-new-variant" ::ev/origin "workspace:move-shapes-to-frame"}))))))))
|
||||
(rx/of (ev/event {::ev/name "add-new-variant"
|
||||
::ev/origin "workspace:move-shapes-to-frame"}))))))))
|
||||
|
||||
(defn- get-displacement
|
||||
"Retrieve the correct displacement delta point for the
|
||||
|
||||
@@ -6,10 +6,30 @@
|
||||
|
||||
(ns app.plugins.flags
|
||||
(:require
|
||||
[app.main.data.plugins :as dp]
|
||||
[app.common.data.macros :as dm]
|
||||
[app.main.store :as st]
|
||||
[app.plugins.utils :as u]
|
||||
[app.util.object :as obj]))
|
||||
[app.util.object :as obj]
|
||||
[potok.v2.core :as ptk]))
|
||||
|
||||
(defn natural-child-ordering?
|
||||
[plugin-id]
|
||||
(boolean
|
||||
(dm/get-in @st/state [:plugins :flags plugin-id :natural-child-ordering])))
|
||||
|
||||
(defn clear
|
||||
[id]
|
||||
(ptk/reify ::reset
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(update-in state [:plugins :flags] assoc id {}))))
|
||||
|
||||
(defn- set-flag
|
||||
[id key value]
|
||||
(ptk/reify ::set-flag
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(update-in state [:plugins :flags id] assoc key value))))
|
||||
|
||||
(defn flags-proxy
|
||||
[plugin-id]
|
||||
@@ -17,11 +37,7 @@
|
||||
:naturalChildOrdering
|
||||
{:this false
|
||||
:get
|
||||
(fn []
|
||||
(boolean
|
||||
(get-in
|
||||
@st/state
|
||||
[:workspace-local :plugin-flags plugin-id :natural-child-ordering])))
|
||||
(fn [] (natural-child-ordering? plugin-id))
|
||||
|
||||
:set
|
||||
(fn [value]
|
||||
@@ -30,4 +46,4 @@
|
||||
(u/display-not-valid :naturalChildOrdering value)
|
||||
|
||||
:else
|
||||
(st/emit! (dp/set-plugin-flag plugin-id :natural-child-ordering value))))}))
|
||||
(st/emit! (set-flag plugin-id :natural-child-ordering value))))}))
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
[app.main.data.workspace.shape-layout :as dwsl]
|
||||
[app.main.data.workspace.transforms :as dwt]
|
||||
[app.main.store :as st]
|
||||
[app.plugins.flags :refer [natural-child-ordering?]]
|
||||
[app.plugins.register :as r]
|
||||
[app.plugins.utils :as u]
|
||||
[app.util.object :as obj]
|
||||
@@ -259,11 +260,10 @@
|
||||
(u/display-not-valid :appendChild child)
|
||||
|
||||
:else
|
||||
(let [child-id (obj/get child "$id")]
|
||||
(let [child-id (obj/get child "$id")]
|
||||
(st/emit! (dwt/move-shapes-to-frame #{child-id} id nil nil)
|
||||
(ptk/data-event :layout/update {:ids [id]})))))))
|
||||
|
||||
|
||||
(defn layout-child-proxy? [p]
|
||||
(obj/type-of? p "LayoutChildProxy"))
|
||||
|
||||
|
||||
@@ -47,13 +47,13 @@
|
||||
[app.main.data.workspace.variants :as dwv]
|
||||
[app.main.repo :as rp]
|
||||
[app.main.store :as st]
|
||||
[app.plugins.flags :refer [natural-child-ordering?]]
|
||||
[app.plugins.flex :as flex]
|
||||
[app.plugins.format :as format]
|
||||
[app.plugins.grid :as grid]
|
||||
[app.plugins.parser :as parser]
|
||||
[app.plugins.register :as r]
|
||||
[app.plugins.ruler-guides :as rg]
|
||||
[app.plugins.state :refer [natural-child-ordering?]]
|
||||
[app.plugins.text :as text]
|
||||
[app.plugins.utils :as u]
|
||||
[app.util.http :as http]
|
||||
@@ -960,9 +960,11 @@
|
||||
(u/display-not-valid :appendChild "Plugin doesn't have 'content:write' permission")
|
||||
|
||||
:else
|
||||
(let [child-id (obj/get child "$id")
|
||||
(let [child-id (obj/get child "$id")
|
||||
is-reversed? (ctl/flex-layout? shape)
|
||||
index (if (and (natural-child-ordering? plugin-id) is-reversed?) 0 (count (:shapes shape)))]
|
||||
index (if (and (natural-child-ordering? plugin-id) is-reversed?)
|
||||
0
|
||||
(count (:shapes shape)))]
|
||||
(st/emit! (dwsh/relocate-shapes #{child-id} id index))))))
|
||||
|
||||
:insertChild
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; Copyright (c) KALEIDOS INC
|
||||
|
||||
(ns app.plugins.state
|
||||
(:require
|
||||
[app.main.store :as st]))
|
||||
|
||||
(defn natural-child-ordering?
|
||||
[plugin-id]
|
||||
(boolean
|
||||
(get-in
|
||||
@st/state
|
||||
[:workspace-local :plugin-flags plugin-id :natural-child-ordering])))
|
||||
Reference in New Issue
Block a user