Add plugins and mcp event data (#9228)

*  Add plugins and mcp event data

* ♻️ Changed data-event ::ev/event to ev/event
This commit is contained in:
Alonso Torres 2026-05-11 08:36:53 +02:00 committed by GitHub
parent c9b81284d2
commit 9f05ba2fdf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
61 changed files with 542 additions and 448 deletions

View File

@ -96,12 +96,13 @@
(update-in [:comments id] assoc (:id comment) comment)))) (update-in [:comments id] assoc (:id comment) comment))))
ptk/WatchEvent ptk/WatchEvent
(watch [_ _ _] (watch [it _ _]
(rx/of (ptk/data-event ::ev/event (rx/of (ev/event
{::ev/name "create-comment-thread" (merge {::ev/name "create-comment-thread"
::ev/origin "workspace" ::ev/origin "workspace"
:id id :id id
:content-size (count (:content comment))})))))) :content-size (count (:content comment))}
(meta it))))))))
(def ^:private (def ^:private
schema:create-thread-on-workspace schema:create-thread-on-workspace
@ -119,7 +120,7 @@
(ptk/reify ::create-thread-on-workspace (ptk/reify ::create-thread-on-workspace
ptk/WatchEvent ptk/WatchEvent
(watch [_ state _] (watch [it state _]
(let [page-id (:current-page-id state) (let [page-id (:current-page-id state)
objects (dsh/lookup-page-objects state page-id) objects (dsh/lookup-page-objects state page-id)
frame-id (ctst/get-frame-id-by-position objects (:position params)) frame-id (ctst/get-frame-id-by-position objects (:position params))
@ -129,7 +130,10 @@
(->> (rp/cmd! :create-comment-thread params) (->> (rp/cmd! :create-comment-thread params)
(rx/mapcat #(rp/cmd! :get-comment-thread {:file-id (:file-id %) :id (:id %)})) (rx/mapcat #(rp/cmd! :get-comment-thread {:file-id (:file-id %) :id (:id %)}))
(rx/tap on-thread-created) (rx/tap on-thread-created)
(rx/map #(created-thread-on-workspace % open?)) (rx/map
(fn [data]
(-> (created-thread-on-workspace data open?)
(with-meta (meta it)))))
(rx/catch (fn [{:keys [type code] :as cause}] (rx/catch (fn [{:keys [type code] :as cause}]
(if (and (= type :restriction) (if (and (= type :restriction)
(= code :max-quote-reached)) (= code :max-quote-reached))
@ -152,11 +156,11 @@
ptk/WatchEvent ptk/WatchEvent
(watch [_ _ _] (watch [_ _ _]
(rx/of (ptk/data-event ::ev/event (rx/of (ev/event
{::ev/name "create-comment-thread" {::ev/name "create-comment-thread"
::ev/origin "viewer" ::ev/origin "viewer"
:id id :id id
:content-size (count (:content comment))}))))) :content-size (count (:content comment))})))))
(def ^:private (def ^:private
schema:create-thread-on-viewer schema:create-thread-on-viewer
@ -216,11 +220,13 @@
(d/update-in-when state [:comment-threads id] assoc :is-resolved is-resolved)) (d/update-in-when state [:comment-threads id] assoc :is-resolved is-resolved))
ptk/WatchEvent ptk/WatchEvent
(watch [_ state _] (watch [it state _]
(let [share-id (-> state :viewer-local :share-id)] (let [share-id (-> state :viewer-local :share-id)]
(rx/concat (rx/concat
(when is-resolved (rx/of (when is-resolved
(ptk/event ::ev/event {::ev/name "resolve-comment-thread" :thread-id id}))) (rx/of (ev/event
(-> {::ev/name "resolve-comment-thread" :thread-id id}
(merge (meta it))))))
(->> (rp/cmd! :update-comment-thread {:id id :is-resolved is-resolved :share-id share-id}) (->> (rp/cmd! :update-comment-thread {:id id :is-resolved is-resolved :share-id share-id})
(rx/catch (fn [{:keys [type code] :as cause}] (rx/catch (fn [{:keys [type code] :as cause}]
(if (and (= type :restriction) (if (and (= type :restriction)
@ -309,16 +315,18 @@
(update :comment-threads dissoc id))) (update :comment-threads dissoc id)))
ptk/WatchEvent ptk/WatchEvent
(watch [_ _ _] (watch [it _ _]
(rx/concat (rx/concat
(->> (rp/cmd! :delete-comment-thread {:id id}) (->> (rp/cmd! :delete-comment-thread {:id id})
(rx/catch #(rx/throw {:type :comment-error})) (rx/catch #(rx/throw {:type :comment-error}))
(rx/tap on-delete) (rx/tap on-delete)
(rx/ignore)) (rx/ignore))
(rx/of (ptk/data-event ::ev/event (rx/of (ev/event
{::ev/name "delete-comment-thread" (merge
::ev/origin "workspace" {::ev/name "delete-comment-thread"
:id id}))))))) ::ev/origin "workspace"
:id id}
(meta it)))))))))
(defn delete-comment-thread-on-viewer (defn delete-comment-thread-on-viewer
[{:keys [id] :as thread}] [{:keys [id] :as thread}]
@ -341,10 +349,10 @@
(->> (rp/cmd! :delete-comment-thread {:id id :share-id share-id}) (->> (rp/cmd! :delete-comment-thread {:id id :share-id share-id})
(rx/catch #(rx/throw {:type :comment-error})) (rx/catch #(rx/throw {:type :comment-error}))
(rx/ignore)) (rx/ignore))
(rx/of (ptk/data-event ::ev/event (rx/of (ev/event
{::ev/name "delete-comment-thread" {::ev/name "delete-comment-thread"
::ev/origin "viewer" ::ev/origin "viewer"
:id id}))))))) :id id})))))))
(defn delete-comment (defn delete-comment
[{:keys [id thread-id] :as comment}] [{:keys [id thread-id] :as comment}]
(dm/assert! (dm/assert!

View File

@ -479,7 +479,7 @@
(->> (rp/cmd! :get-file-summary {:id id}) (->> (rp/cmd! :get-file-summary {:id id})
(rx/map (fn [summary] (rx/map (fn [summary]
(when (-> summary :variants :count pos?) (when (-> summary :variants :count pos?)
(ptk/event ::ev/event {::ev/name "set-file-variants-shared" ::ev/origin "dashboard"}))))))))))) (ev/event {::ev/name "set-file-variants-shared" ::ev/origin "dashboard"})))))))))))
(defn set-file-thumbnail (defn set-file-thumbnail
[file-id thumbnail-id] [file-id thumbnail-id]

View File

@ -267,8 +267,7 @@
counts)) counts))
{:png 0, :jpeg 0, :webp 0, :pdf 0, :svg 0} {:png 0, :jpeg 0, :webp 0, :pdf 0, :svg 0}
exports)] exports)]
(ptk/event (ev/event (merge types
::ev/event (merge types {::ev/name "export-shapes"
{::ev/name "export-shapes" ::ev/origin origin
::ev/origin origin :num-shapes (count exports)}))))
:num-shapes (count exports)}))))

View File

@ -261,12 +261,12 @@
ptk/WatchEvent ptk/WatchEvent
(watch [_ state _] (watch [_ state _]
(let [team-id (:current-team-id state)] (let [team-id (:current-team-id state)]
(rx/of (ptk/data-event ::ev/event {::ev/name "add-font" (rx/of (ev/event {::ev/name "add-font"
:team-id team-id :team-id team-id
:font-id (:id font) :font-id (:id font)
:font-family (:font-family font) :font-family (:font-family font)
:font-style (:font-style font) :font-style (:font-style font)
:font-weight (:font-weight font)})))))) :font-weight (:font-weight font)}))))))
(defn update-font (defn update-font
[{:keys [id name] :as params}] [{:keys [id name] :as params}]
@ -310,9 +310,9 @@
(rx/concat (rx/concat
(->> (rp/cmd! :delete-font {:id font-id :team-id team-id}) (->> (rp/cmd! :delete-font {:id font-id :team-id team-id})
(rx/ignore)) (rx/ignore))
(rx/of (ptk/data-event ::ev/event {::ev/name "delete-font" (rx/of (ev/event {::ev/name "delete-font"
:team-id team-id :team-id team-id
:font-id font-id}))))))) :font-id font-id})))))))
(defn delete-font-variant (defn delete-font-variant
[id] [id]
@ -331,9 +331,9 @@
(rx/concat (rx/concat
(->> (rp/cmd! :delete-font-variant {:id id :team-id team-id}) (->> (rp/cmd! :delete-font-variant {:id id :team-id team-id})
(rx/ignore)) (rx/ignore))
(rx/of (ptk/data-event ::ev/event {::ev/name "delete-font-variant" (rx/of (ev/event {::ev/name "delete-font-variant"
:id id :id id
:team-id team-id}))))))) :team-id team-id})))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

View File

@ -152,10 +152,10 @@
(when (not= (:theme profile) (when (not= (:theme profile)
(:theme profile')) (:theme profile'))
(rx/of (ptk/data-event ::ev/event (rx/of (ev/event
{::ev/name "activate-theme" {::ev/name "activate-theme"
::ev/origin "settings" ::ev/origin "settings"
:theme (:theme profile)}))))))))) :theme (:theme profile)})))))))))
;; --- Toggle Theme ;; --- Toggle Theme
@ -186,9 +186,9 @@
(watch [it state _] (watch [it state _]
(let [profile (get state :profile) (let [profile (get state :profile)
origin (::ev/origin (meta it))] origin (::ev/origin (meta it))]
(rx/of (ptk/data-event ::ev/event {:theme (:theme profile) (rx/of (ev/event {:theme (:theme profile)
::ev/name "activate-theme" ::ev/name "activate-theme"
::ev/origin origin}) ::ev/origin origin})
(persist-profile)))))) (persist-profile))))))
;; --- Request Email Change ;; --- Request Email Change

View File

@ -176,10 +176,10 @@
(rx/of (dp/refresh-profile) (rx/of (dp/refresh-profile)
(fetch-members team-id) (fetch-members team-id)
(fetch-teams) (fetch-teams)
(ptk/data-event ::ev/event (ev/event
{::ev/name "delete-team-member" {::ev/name "delete-team-member"
:team-id team-id :team-id team-id
:member-id member-id}))))))))) :member-id member-id})))))))))
(defn- stats-fetched (defn- stats-fetched
@ -240,9 +240,9 @@
(rx/tap on-success) (rx/tap on-success)
(rx/mapcat (fn [_] (rx/mapcat (fn [_]
(rx/of (fetch-teams) (rx/of (fetch-teams)
(ptk/data-event ::ev/event (ev/event
{::ev/name "update-team-photo" {::ev/name "update-team-photo"
:team-id team-id})))) :team-id team-id}))))
(rx/catch on-error)))))) (rx/catch on-error))))))
@ -345,10 +345,10 @@
(rx/merge (rx/merge
(rx/of (team-leaved params) (rx/of (team-leaved params)
(fetch-teams) (fetch-teams)
(ptk/data-event ::ev/event (ev/event
{::ev/name "leave-team" {::ev/name "leave-team"
:reassign-to reassign-to :reassign-to reassign-to
:team-id team-id})) :team-id team-id}))
(on-success)))) (on-success))))
(rx/catch on-error)))))) (rx/catch on-error))))))

View File

@ -82,7 +82,7 @@
(when (some? (:profile state)) (when (some? (:profile state))
(fetch-comment-threads params)) (fetch-comment-threads params))
(when (:share-id params) (when (:share-id params)
(rx/of (ptk/event ::ev/event {::ev/name "shared-prototipe-visited"}))))) (rx/of (ev/event {::ev/name "shared-prototipe-visited"})))))
ptk/EffectEvent ptk/EffectEvent
(effect [_ _ _] (effect [_ _ _]
;; Set the window name, the window name is used on inter-tab ;; Set the window name, the window name is used on inter-tab

View File

@ -1343,7 +1343,7 @@
(rx/concat (rx/concat
(rx/of (dch/commit-changes changes)) (rx/of (dch/commit-changes changes))
(when (nil? annotation) (when (nil? annotation)
(rx/of (ptk/data-event ::ev/event {::ev/name "delete-component-annotation"})))))))) (rx/of (ev/event {::ev/name "delete-component-annotation"}))))))))
(defn set-annotations-expanded (defn set-annotations-expanded
[expanded] [expanded]
@ -1365,7 +1365,7 @@
ptk/WatchEvent ptk/WatchEvent
(watch [_ _ _] (watch [_ _ _]
(when (some? id) (when (some? id)
(rx/of (ptk/data-event ::ev/event {::ev/name "create-component-annotation"})))))) (rx/of (ev/event {::ev/name "create-component-annotation"}))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Preview blend modes ;; Preview blend modes

View File

@ -960,7 +960,7 @@
(ptk/data-event :layout/update {:ids [frame-id]}) (ptk/data-event :layout/update {:ids [frame-id]})
(dwu/commit-undo-transaction undo-id) (dwu/commit-undo-transaction undo-id)
(when add-component-to-variant? (when add-component-to-variant?
(ptk/event ::ev/event {::ev/name "add-component-to-variant"}))))))))) (ev/event {::ev/name "add-component-to-variant"})))))))))
(defn- as-content [text] (defn- as-content [text]
(let [paragraphs (->> (str/lines text) (let [paragraphs (->> (str/lines text)

View File

@ -390,7 +390,7 @@
([id-ref ids] ([id-ref ids]
(ptk/reify ::add-component (ptk/reify ::add-component
ptk/WatchEvent ptk/WatchEvent
(watch [_ state _] (watch [it state _]
(let [objects (dsh/lookup-page-objects state) (let [objects (dsh/lookup-page-objects state)
selected (->> (d/nilv ids (dsh/lookup-selected state)) selected (->> (d/nilv ids (dsh/lookup-selected state))
(cfh/clean-loops objects)) (cfh/clean-loops objects))
@ -399,7 +399,8 @@
can-make-component (every? true? (map #(ctn/valid-shape-for-component? objects %) selected-objects))] can-make-component (every? true? (map #(ctn/valid-shape-for-component? objects %) selected-objects))]
(when can-make-component (when can-make-component
(rx/of (add-component2 id-ref selected)))))))) (rx/of (-> (add-component2 id-ref selected)
(with-meta (meta it))))))))))
(defn add-multiple-components (defn add-multiple-components
"Add several new components to current file library, from the currently selected shapes." "Add several new components to current file library, from the currently selected shapes."
@ -601,11 +602,12 @@
(when id-ref (when id-ref
(reset! id-ref (:id new-shape))) (reset! id-ref (:id new-shape)))
(rx/of (ptk/event ::ev/event (rx/of (ev/event
{::ev/name "use-library-component" (-> {::ev/name "use-library-component"
::ev/origin origin ::ev/origin origin
:external-library (not= file-id current-file-id) :external-library (not= file-id current-file-id)
:is-variant (ctk/is-variant? component)}) :is-variant (ctk/is-variant? component)}
(merge (meta it))))
(dwu/start-undo-transaction undo-id) (dwu/start-undo-transaction undo-id)
(dch/commit-changes changes) (dch/commit-changes changes)
(ptk/data-event :layout/update {:ids [(:id new-shape)]}) (ptk/data-event :layout/update {:ids [(:id new-shape)]})
@ -1399,7 +1401,7 @@
vals vals
(some ctk/is-variant?))] (some ctk/is-variant?))]
(if has-variants? (if has-variants?
(rx/of (ptk/event ::ev/event {::ev/name "set-file-variants-shared" ::ev/origin "workspace"})) (rx/of (ev/event {::ev/name "set-file-variants-shared" ::ev/origin "workspace"}))
(rx/empty))))))))) (rx/empty)))))))))
;; --- Link and unlink Files ;; --- Link and unlink Files
@ -1463,11 +1465,11 @@
(when (pos? variants-count) (when (pos? variants-count)
(->> (rp/cmd! :get-library-usage {:file-id library-id}) (->> (rp/cmd! :get-library-usage {:file-id library-id})
(rx/map (fn [library-usage] (rx/map (fn [library-usage]
(ptk/event ::ev/event {::ev/name "attach-library-variants" (ev/event {::ev/name "attach-library-variants"
:file-id file-id :file-id file-id
:library-id library-id :library-id library-id
:variants-count variants-count :variants-count variants-count
:library-used-in (:used-in library-usage)})))))))))) :library-used-in (:used-in library-usage)}))))))))))
(defn unlink-file-from-library (defn unlink-file-from-library
[file-id library-id] [file-id library-id]

View File

@ -305,11 +305,11 @@
(ptk/data-event :layout/update {:ids ids}) (ptk/data-event :layout/update {:ids ids})
(dwu/commit-undo-transaction undo-id) (dwu/commit-undo-transaction undo-id)
(when (or (:layout-align-content changes) (:layout-justify-content changes)) (when (or (:layout-align-content changes) (:layout-justify-content changes))
(ptk/event ::ev/event (ev/event
{::ev/name "layout-change-alignment"})) {::ev/name "layout-change-alignment"}))
(when (or (:layout-padding changes) (:layout-gap changes)) (when (or (:layout-padding changes) (:layout-gap changes))
(ptk/event ::ev/event (ev/event
{::ev/name "layout-change-margin"})))))))) {::ev/name "layout-change-margin"}))))))))
(defn add-layout-track (defn add-layout-track
([ids type value] ([ids type value]

View File

@ -602,7 +602,7 @@
:subsections [:basics] :subsections [:basics]
:fn #(when (features/active-feature? @st/state "plugins/runtime") :fn #(when (features/active-feature? @st/state "plugins/runtime")
(st/emit! (st/emit!
(ptk/event ::ev/event {::ev/name "open-plugins-manager" ::ev/origin "workspace:shortcuts"}) (ev/event {::ev/name "open-plugins-manager" ::ev/origin "workspace:shortcuts"})
(modal/show :plugin-management {})))}}) (modal/show :plugin-management {})))}})
(def debug-shortcuts (def debug-shortcuts

View File

@ -897,8 +897,8 @@
(rx/concat (rx/concat
(rx/of (dwl/add-typography typ) (rx/of (dwl/add-typography typ)
(ptk/event ::ev/event {::ev/name "add-asset-to-library" (ev/event {::ev/name "add-asset-to-library"
:asset-type "typography"})) :asset-type "typography"}))
(when (not multiple?) (when (not multiple?)
(rx/of (update-attrs (:id shape) (rx/of (update-attrs (:id shape)

View File

@ -658,7 +658,7 @@
[{:keys [attributes attributes-to-remove token shape-ids on-update-shape]}] [{:keys [attributes attributes-to-remove token shape-ids on-update-shape]}]
(ptk/reify ::apply-token (ptk/reify ::apply-token
ptk/WatchEvent ptk/WatchEvent
(watch [_ state _] (watch [it state _]
;; We do not allow to apply tokens while text editor is open. ;; We do not allow to apply tokens while text editor is open.
;; The classic text editor sets :workspace-editor-state; the WASM text editor ;; The classic text editor sets :workspace-editor-state; the WASM text editor
;; does not, so we also check :workspace-local :edition for text shapes. ;; does not, so we also check :workspace-local :edition for text shapes.
@ -704,10 +704,12 @@
type (:type token)] type (:type token)]
(rx/concat (rx/concat
(rx/of (rx/of
(st/emit! (ev/event {::ev/name "apply-tokens" (st/emit! (ev/event
:type type (-> {::ev/name "apply-tokens"
:applied-to attributes :type type
:applied-to-variant any-variant?})) :applied-to attributes
:applied-to-variant any-variant?}
(merge (meta it)))))
(dwu/start-undo-transaction undo-id) (dwu/start-undo-transaction undo-id)
(dwsh/update-shapes shape-ids (fn [shape] (dwsh/update-shapes shape-ids (fn [shape]
(cond-> shape (cond-> shape
@ -736,7 +738,7 @@
[{:keys [token shapes attr]}] [{:keys [token shapes attr]}]
(ptk/reify ::apply-spacing-token-separated (ptk/reify ::apply-spacing-token-separated
ptk/WatchEvent ptk/WatchEvent
(watch [_ state _] (watch [it state _]
(let [objects (dsh/lookup-page-objects state) (let [objects (dsh/lookup-page-objects state)
{:keys [attributes on-update-shape]} {:keys [attributes on-update-shape]}
@ -746,14 +748,17 @@
(group-by #(if (ctsl/any-layout-immediate-child? objects %) :frame-children :other) shapes)] (group-by #(if (ctsl/any-layout-immediate-child? objects %) :frame-children :other) shapes)]
(rx/of (rx/of
(apply-token {:attributes (or attr attributes) (-> (apply-token {:attributes (or attr attributes)
:token token :token token
:shape-ids (map :id other) :shape-ids (map :id other)
:on-update-shape on-update-shape}) :on-update-shape on-update-shape})
(apply-token {:attributes ctt/spacing-margin-keys (with-meta (meta it)))
:token token
:shape-ids (map :id frame-children) (-> (apply-token {:attributes ctt/spacing-margin-keys
:on-update-shape update-layout-item-margin})))))) :token token
:shape-ids (map :id frame-children)
:on-update-shape update-layout-item-margin})
(with-meta (meta it))))))))
(defn unapply-token (defn unapply-token
"Removes `attributes` that match `token` for `shape-ids`. "Removes `attributes` that match `token` for `shape-ids`.
@ -775,7 +780,7 @@
[{:keys [token attrs shape-ids expand-with-children]}] [{:keys [token attrs shape-ids expand-with-children]}]
(ptk/reify ::on-toggle-token (ptk/reify ::on-toggle-token
ptk/WatchEvent ptk/WatchEvent
(watch [_ state _] (watch [it state _]
(let [objects (dsh/lookup-page-objects state) (let [objects (dsh/lookup-page-objects state)
shapes (into [] (keep (d/getf objects)) shape-ids) shapes (into [] (keep (d/getf objects)) shape-ids)
@ -812,15 +817,17 @@
(cond (cond
(and (= (:type token) :spacing) (and (= (:type token) :spacing)
(nil? attrs)) (nil? attrs))
(apply-spacing-token-separated {:token token (-> (apply-spacing-token-separated {:token token
:attr attrs :attr attrs
:shapes shapes}) :shapes shapes})
(with-meta (meta it)))
:else :else
(apply-token {:attributes (if (empty? attrs) attributes attrs) (-> (apply-token {:attributes (if (empty? attrs) attributes attrs)
:token token :token token
:shape-ids shape-ids :shape-ids shape-ids
:on-update-shape on-update-shape})))))))) :on-update-shape on-update-shape})
(with-meta (meta it))))))))))
(defn apply-token-on-selected (defn apply-token-on-selected
[color-operations token] [color-operations token]

View File

@ -426,7 +426,8 @@
token))] token))]
(rx/of (dch/commit-changes changes) (rx/of (dch/commit-changes changes)
(ptk/data-event ::ev/event {::ev/name "create-token" :type token-type}))) (ev/event (-> {::ev/name "create-token" :type token-type}
(merge (meta it))))))
(rx/of (create-token-with-set token))))))) (rx/of (create-token-with-set token)))))))
@ -454,7 +455,8 @@
id id
token'))] token'))]
(rx/of (dch/commit-changes changes) (rx/of (dch/commit-changes changes)
(ptk/data-event ::ev/event {::ev/name "edit-token" :type token-type}))))))) (ev/event (-> {::ev/name "edit-token" :type token-type}
(merge (meta it))))))))))
(defn delete-token (defn delete-token
[set-id token-id] [set-id token-id]
@ -475,7 +477,8 @@
(pcb/with-library-data data) (pcb/with-library-data data)
(pcb/set-token set-id token-id nil))] (pcb/set-token set-id token-id nil))]
(rx/of (dch/commit-changes changes) (rx/of (dch/commit-changes changes)
(ptk/data-event ::ev/event {::ev/name "delete-token" :type token-type})))))) (ev/event (-> {::ev/name "delete-token" :type token-type}
(merge (meta it)))))))))
(defn bulk-delete-tokens (defn bulk-delete-tokens
[set-id token-ids] [set-id token-ids]
@ -491,7 +494,7 @@
(pcb/with-library-data data)) (pcb/with-library-data data))
token-ids)] token-ids)]
(rx/of (dch/commit-changes changes) (rx/of (dch/commit-changes changes)
(ptk/data-event ::ev/event {::ev/name "delete-token-node"})))))) (ev/event {::ev/name "delete-token-node"}))))))
(defn duplicate-token (defn duplicate-token
[token-id] [token-id]

View File

@ -616,7 +616,7 @@
[ids {:keys [page-id trigger variant-id]}] [ids {:keys [page-id trigger variant-id]}]
(ptk/reify ::combine-as-variants (ptk/reify ::combine-as-variants
ptk/WatchEvent ptk/WatchEvent
(watch [_ state stream] (watch [it state stream]
(let [current-page (:current-page-id state) (let [current-page (:current-page-id state)
combine combine
@ -665,7 +665,8 @@
(dwsh/relocate-shapes #{variant-id} common-parent index) (dwsh/relocate-shapes #{variant-id} common-parent index)
(dwt/update-dimensions [variant-id] :width (+ (:width rect) 60)) (dwt/update-dimensions [variant-id] :width (+ (:width rect) 60))
(dwt/update-dimensions [variant-id] :height (+ (:height rect) 60)) (dwt/update-dimensions [variant-id] :height (+ (:height rect) 60))
(ev/event {::ev/name "combine-as-variants" ::ev/origin trigger :number-of-combined (count ids)})) (ev/event (-> {::ev/name "combine-as-variants" ::ev/origin trigger :number-of-combined (count ids)}
(merge (meta it)))))
;; NOTE: we need to schedule a commit into a ;; NOTE: we need to schedule a commit into a
;; microtask for ensure that all the scheduled ;; microtask for ensure that all the scheduled
@ -701,7 +702,7 @@
[shape {:keys [pos val] :as params}] [shape {:keys [pos val] :as params}]
(ptk/reify ::variant-switch (ptk/reify ::variant-switch
ptk/WatchEvent ptk/WatchEvent
(watch [_ state _] (watch [it state _]
(let [libraries (dsh/lookup-libraries state) (let [libraries (dsh/lookup-libraries state)
component-id (:component-id shape) component-id (:component-id shape)
component (ctf/get-component libraries (:component-file shape) component-id :include-deleted? false)] component (ctf/get-component libraries (:component-file shape) component-id :include-deleted? false)]
@ -735,20 +736,23 @@
(rx/empty)) (rx/empty))
(rx/of (rx/of
(dwl/component-swap shape (:component-file shape) (:id nearest-comp) true) (dwl/component-swap shape (:component-file shape) (:id nearest-comp) true)
(ev/event {::ev/name "variant-switch" ::ev/origin "workspace:design-tab"})))))))))) (ev/event (-> {::ev/name "variant-switch" ::ev/origin "workspace:design-tab"}
(merge (meta it)))))))))))))
(defn variants-switch (defn variants-switch
"Switch each shape (that must be a variant copy head) for the closest one with the property value passed as parameter" "Switch each shape (that must be a variant copy head) for the closest one with the property value passed as parameter"
[{:keys [shapes] :as params}] [{:keys [shapes] :as params}]
(ptk/reify ::variants-switch (ptk/reify ::variants-switch
ptk/WatchEvent ptk/WatchEvent
(watch [_ _ _] (watch [it _ _]
(let [ids (into (d/ordered-set) d/xf:map-id shapes) (let [ids (into (d/ordered-set) d/xf:map-id shapes)
undo-id (js/Symbol)] undo-id (js/Symbol)]
(rx/concat (rx/concat
(rx/of (dwu/start-undo-transaction undo-id)) (rx/of (dwu/start-undo-transaction undo-id))
(->> (rx/from shapes) (->> (rx/from shapes)
(rx/map #(variant-switch % params))) (rx/map (fn [data]
(-> (variant-switch data params)
(with-meta (meta it))))))
(rx/of (dwu/commit-undo-transaction undo-id) (rx/of (dwu/commit-undo-transaction undo-id)
(dws/select-shapes ids))))))) (dws/select-shapes ids)))))))

View File

@ -66,7 +66,7 @@
;; Force persist before creating snapshot, otherwise we could loss changes ;; Force persist before creating snapshot, otherwise we could loss changes
(rx/concat (rx/concat
(rx/of ::dwp/force-persist (rx/of ::dwp/force-persist
(ptk/event ::ev/event {::ev/name "create-version"})) (ev/event {::ev/name "create-version"}))
(->> (rx/from-atom refs/persistence-state {:emit-current-value? true}) (->> (rx/from-atom refs/persistence-state {:emit-current-value? true})
(rx/filter #(or (nil? %) (= :saved %))) (rx/filter #(or (nil? %) (= :saved %)))
@ -88,8 +88,8 @@
(let [file-id (:current-file-id state)] (let [file-id (:current-file-id state)]
(rx/merge (rx/merge
(rx/of (update-versions-state {:editing nil}) (rx/of (update-versions-state {:editing nil})
(ptk/event ::ev/event {::ev/name "rename-version" (ev/event {::ev/name "rename-version"
:file-id file-id})) :file-id file-id}))
(->> (rp/cmd! :update-file-snapshot {:id id :label label}) (->> (rp/cmd! :update-file-snapshot {:id id :label label})
(rx/map fetch-versions))))))) (rx/map fetch-versions)))))))
@ -173,7 +173,7 @@
(rx/mapcat (fn [_] (rx/mapcat (fn [_]
(rx/of (update-versions-state {:editing id}) (rx/of (update-versions-state {:editing id})
(fetch-versions) (fetch-versions)
(ptk/event ::ev/event {::ev/name "pin-version"})))))))))) (ev/event {::ev/name "pin-version"}))))))))))
(defn lock-version (defn lock-version
[id] [id]
@ -215,9 +215,6 @@
(let [current-file-id (:current-file-id state)] (let [current-file-id (:current-file-id state)]
;; Force persist before creating snapshot, otherwise we could loss changes ;; Force persist before creating snapshot, otherwise we could loss changes
(->> (rx/concat (->> (rx/concat
(rx/of (ptk/event ::ev/event {::ev/origin "plugins"
::ev/name "create-version"}))
(when (= file-id current-file-id) (when (= file-id current-file-id)
(rx/of ::dwp/force-persist)) (rx/of ::dwp/force-persist))
@ -246,20 +243,15 @@
(ptk/reify ::restore-version-from-plugins (ptk/reify ::restore-version-from-plugins
ptk/WatchEvent ptk/WatchEvent
(watch [_ state _] (watch [_ _ _]
(let [team-id (:current-team-id state)] (rx/concat
(rx/concat (rx/of ::dwp/force-persist)
(rx/of (ev/event {::ev/name "restore-version-plugin" (->> (wait-for-persistence file-id id)
:file-id file-id (rx/map #(initialize-version)))
:team-id team-id})
::dwp/force-persist)
(->> (wait-for-persistence file-id id) (->> (rx/of 1)
(rx/map #(initialize-version))) (rx/tap resolve)
(rx/ignore))))))
(->> (rx/of 1)
(rx/tap resolve)
(rx/ignore)))))))

View File

@ -76,8 +76,7 @@
(when send-event-info? (when send-event-info?
(let [route (dm/get-in match [:data :name]) (let [route (dm/get-in match [:data :name])
params (get match :query-params)] params (get match :query-params)]
(rx/of (ptk/event (rx/of (ev/event
::ev/event
(assoc params (assoc params
::ev/name "navigate" ::ev/name "navigate"
:route (name route))))))) :route (name route)))))))

View File

@ -44,7 +44,6 @@
[cuerdas.core :as str] [cuerdas.core :as str]
[goog.events :as events] [goog.events :as events]
[okulary.core :as l] [okulary.core :as l]
[potok.v2.core :as ptk]
[rumext.v2 :as mf])) [rumext.v2 :as mf]))
(mf/defc dashboard-content* (mf/defc dashboard-content*
@ -216,7 +215,7 @@
(fn [plugin] (fn [plugin]
(if plugin (if plugin
(do (do
(st/emit! (ptk/event ::ev/event {::ev/name "install-plugin" :name (:name plugin) :url plugin-url})) (st/emit! (ev/event {::ev/name "install-plugin" :name (:name plugin) :url plugin-url}))
(open-permissions-dialog plugin)) (open-permissions-dialog plugin))
(st/emit! (notif/error (tr "dashboard.plugins.parse-error"))))) (st/emit! (notif/error (tr "dashboard.plugins.parse-error")))))
(fn [_] (fn [_]
@ -245,12 +244,12 @@
(dd/fetch-recent-files team-id) (dd/fetch-recent-files team-id)
(dd/fetch-projects team-id) (dd/fetch-projects team-id)
(dd/clear-selected-files) (dd/clear-selected-files)
(ptk/event ::ev/event {::ev/name "install-template-from-link-finished" (ev/event {::ev/name "install-template-from-link-finished"
:name template-name :name template-name
:url template-url}))] :url template-url}))]
(if valid-url? (if valid-url?
(st/emit! (st/emit!
(ptk/event ::ev/event {::ev/name "install-template-from-link" :name template-name :url template-url}) (ev/event {::ev/name "install-template-from-link" :name template-name :url template-url})
(modal/show (modal/show
{:type :import {:type :import
:project-id project-id :project-id project-id

View File

@ -18,7 +18,6 @@
[app.main.ui.ds.foundations.assets.icon :as i] [app.main.ui.ds.foundations.assets.icon :as i]
[app.main.ui.icons :as deprecated-icon] [app.main.ui.icons :as deprecated-icon]
[app.util.i18n :as i18n :refer [tr]] [app.util.i18n :as i18n :refer [tr]]
[potok.v2.core :as ptk]
[rumext.v2 :as mf])) [rumext.v2 :as mf]))
(def ^:private comments-icon-svg (def ^:private comments-icon-svg
@ -81,8 +80,8 @@
(mf/deps show?) (mf/deps show?)
(fn [] (fn []
(when show? (when show?
(st/emit! (ptk/event ::ev/event {::ev/name "open-comment-notifications" (st/emit! (ev/event {::ev/name "open-comment-notifications"
::ev/origin "dashboard"}))))) ::ev/origin "dashboard"})))))
[:div {:class (stl/css :dashboard-comments-section)} [:div {:class (stl/css :dashboard-comments-section)}
[:& dropdown {:show show? :on-close on-hide-comments :dropdown-id "dashboard-comments"} [:& dropdown {:show show? :on-close on-hide-comments :dropdown-id "dashboard-comments"}

View File

@ -27,7 +27,6 @@
[app.util.webapi :as wapi] [app.util.webapi :as wapi]
[beicon.v2.core :as rx] [beicon.v2.core :as rx]
[cuerdas.core :as str] [cuerdas.core :as str]
[potok.v2.core :as ptk]
[rumext.v2 :as mf])) [rumext.v2 :as mf]))
(log/set-level! :debug) (log/set-level! :debug)
@ -171,14 +170,14 @@
(rx/subs! (rx/subs!
(fn [message] (fn [message]
(when (some? (:error message)) (when (some? (:error message))
(st/emit! (ptk/data-event ::ev/event {::ev/name "import-files-error" (st/emit! (ev/event {::ev/name "import-files-error"
:error (:error message)}))) :error (:error message)})))
(swap! state update-with-analyze-result message)))))) (swap! state update-with-analyze-result message))))))
(defn- import-files (defn- import-files
[state project-id entries] [state project-id entries]
(st/emit! (ptk/data-event ::ev/event {::ev/name "import-files" (st/emit! (ev/event {::ev/name "import-files"
:num-files (count entries)})) :num-files (count entries)}))
(let [features (get @st/state :features)] (let [features (get @st/state :features)]
(->> (mw/ask-many! (->> (mw/ask-many!

View File

@ -16,7 +16,6 @@
[app.util.dom :as dom] [app.util.dom :as dom]
[app.util.i18n :as i18n :refer [tr]] [app.util.i18n :as i18n :refer [tr]]
[okulary.core :as l] [okulary.core :as l]
[potok.v2.core :as ptk]
[rumext.v2 :as mf])) [rumext.v2 :as mf]))
(mf/defc empty-project-placeholder* (mf/defc empty-project-placeholder*
@ -27,9 +26,9 @@
on-add-library on-add-library
(mf/use-fn (mf/use-fn
(fn [_] (fn [_]
(st/emit! (ptk/event ::ev/event {::ev/name "explore-libraries-click" (st/emit! (ev/event {::ev/name "explore-libraries-click"
::ev/origin "dashboard" ::ev/origin "dashboard"
:section "empty-placeholder-projects"})) :section "empty-placeholder-projects"}))
(dom/open-new-window "https://penpot.app/penpothub/libraries-templates"))) (dom/open-new-window "https://penpot.app/penpothub/libraries-templates")))
on-import on-import

View File

@ -31,7 +31,6 @@
[app.util.storage :as storage] [app.util.storage :as storage]
[cuerdas.core :as str] [cuerdas.core :as str]
[okulary.core :as l] [okulary.core :as l]
[potok.v2.core :as ptk]
[rumext.v2 :as mf])) [rumext.v2 :as mf]))
(def ^:private show-more-icon (def ^:private show-more-icon
@ -344,8 +343,8 @@
(mf/use-fn (mf/use-fn
(fn [] (fn []
(reset! show-team-hero* false) (reset! show-team-hero* false)
(st/emit! (ptk/data-event ::ev/event {::ev/name "dont-show-team-up-hero" (st/emit! (ev/event {::ev/name "dont-show-team-up-hero"
::ev/origin "dashboard"}))))] ::ev/origin "dashboard"}))))]
(mf/with-effect [show-team-hero?] (mf/with-effect [show-team-hero?]
(swap! storage/global assoc ::show-team-hero show-team-hero?)) (swap! storage/global assoc ::show-team-hero show-team-hero?))

View File

@ -44,7 +44,6 @@
[beicon.v2.core :as rx] [beicon.v2.core :as rx]
[cuerdas.core :as str] [cuerdas.core :as str]
[goog.functions :as f] [goog.functions :as f]
[potok.v2.core :as ptk]
[rumext.v2 :as mf])) [rumext.v2 :as mf]))
(def ^:private clear-search-icon (def ^:private clear-search-icon
@ -869,8 +868,8 @@
(dom/get-data "url")) (dom/get-data "url"))
eventname (-> (dom/get-current-target event) eventname (-> (dom/get-current-target event)
(dom/get-data "eventname"))] (dom/get-data "eventname"))]
(st/emit! (ptk/event ::ev/event {::ev/name eventname (st/emit! (ev/event {::ev/name eventname
::ev/origin "menu:in-app"})) ::ev/origin "menu:in-app"}))
(dom/open-new-window url)))) (dom/open-new-window url))))
handle-feedback-click handle-feedback-click
@ -914,8 +913,8 @@
(dom/get-data "url")) (dom/get-data "url"))
eventname (-> (dom/get-current-target event) eventname (-> (dom/get-current-target event)
(dom/get-data "eventname"))] (dom/get-data "eventname"))]
(st/emit! (ptk/event ::ev/event {::ev/name eventname (st/emit! (ev/event {::ev/name eventname
::ev/origin "menu:in-app"})) ::ev/origin "menu:in-app"}))
(dom/open-new-window url))))] (dom/open-new-window url))))]
[:> dropdown-menu* {:show true [:> dropdown-menu* {:show true
@ -942,7 +941,7 @@
show-release-notes show-release-notes
(mf/use-fn (mf/use-fn
(fn [event] (fn [event]
(st/emit! (ptk/event ::ev/event {::ev/name "show-release-notes" :version (:main version)})) (st/emit! (ev/event {::ev/name "show-release-notes" :version (:main version)}))
(if (and (kbd/alt? event) (kbd/mod? event)) (if (and (kbd/alt? event) (kbd/mod? event))
(st/emit! (modal/show {:type :onboarding})) (st/emit! (modal/show {:type :onboarding}))
(st/emit! (modal/show {:type :release-notes :version (:main version)}))))) (st/emit! (modal/show {:type :release-notes :version (:main version)})))))
@ -954,8 +953,8 @@
(dom/get-data "url")) (dom/get-data "url"))
eventname (-> (dom/get-current-target event) eventname (-> (dom/get-current-target event)
(dom/get-data "eventname"))] (dom/get-data "eventname"))]
(st/emit! (ptk/event ::ev/event {::ev/name eventname (st/emit! (ev/event {::ev/name eventname
::ev/origin "menu:in-app"})) ::ev/origin "menu:in-app"}))
(dom/open-new-window url))))] (dom/open-new-window url))))]
[:> dropdown-menu* {:show true [:> dropdown-menu* {:show true
@ -1052,7 +1051,7 @@
on-power-up-click on-power-up-click
(mf/use-fn (mf/use-fn
(fn [] (fn []
(st/emit! (ptk/event ::ev/event {::ev/name "explore-pricing-click" ::ev/origin "dashboard" :section "sidebar"})) (st/emit! (ev/event {::ev/name "explore-pricing-click" ::ev/origin "dashboard" :section "sidebar"}))
(dom/open-new-window "https://penpot.app/pricing")))] (dom/open-new-window "https://penpot.app/pricing")))]
[:* [:*

View File

@ -16,7 +16,6 @@
[app.util.i18n :as i18n :refer [tr]] [app.util.i18n :as i18n :refer [tr]]
[app.util.keyboard :as kbd] [app.util.keyboard :as kbd]
[lambdaisland.uri :as u] [lambdaisland.uri :as u]
[potok.v2.core :as ptk]
[rumext.v2 :as mf])) [rumext.v2 :as mf]))
(defn get-subscription-type (defn get-subscription-type
@ -124,9 +123,9 @@
go-to-manage-subscription go-to-manage-subscription
(mf/use-fn (mf/use-fn
(fn [] (fn []
(st/emit! (ptk/event ::ev/event {::ev/name "open-subscription-management" (st/emit! (ev/event {::ev/name "open-subscription-management"
::ev/origin "dashboard" ::ev/origin "dashboard"
:section "team-settings"})) :section "team-settings"}))
(let [href (-> (rt/get-current-href) (let [href (-> (rt/get-current-href)
(rt/encode-url)) (rt/encode-url))
href (str "payments/subscriptions/show?returnUrl=" href)] href (str "payments/subscriptions/show?returnUrl=" href)]

View File

@ -23,7 +23,6 @@
[app.util.keyboard :as kbd] [app.util.keyboard :as kbd]
[app.util.storage :as storage] [app.util.storage :as storage]
[okulary.core :as l] [okulary.core :as l]
[potok.v2.core :as ptk]
[rumext.v2 :as mf])) [rumext.v2 :as mf]))
(def ^:private arrow-icon (def ^:private arrow-icon
@ -40,10 +39,10 @@
(letfn [(on-finish [] (letfn [(on-finish []
(st/emit! (st/emit!
(dd/fetch-recent-files team-id) (dd/fetch-recent-files team-id)
(ptk/event ::ev/event {::ev/name "import-template-finish" (ev/event {::ev/name "import-template-finish"
::ev/origin "dashboard" ::ev/origin "dashboard"
:template (:name template) :template (:name template)
:section section}) :section section})
(when-not (some? project-id) (when-not (some? project-id)
(dcm/go-to-dashboard-recent (dcm/go-to-dashboard-recent
@ -51,10 +50,10 @@
:project-id default-project-id))))] :project-id default-project-id))))]
(st/emit! (st/emit!
(ptk/event ::ev/event {::ev/name "import-template-launch" (ev/event {::ev/name "import-template-launch"
::ev/origin "dashboard" ::ev/origin "dashboard"
:template (:name template) :template (:name template)
:section section}) :section section})
(modal/show (modal/show
{:type :import {:type :import
@ -145,9 +144,9 @@
(mf/use-fn (mf/use-fn
(mf/deps section) (mf/deps section)
(fn [] (fn []
(st/emit! (ptk/event ::ev/event {::ev/name "explore-libraries-click" (st/emit! (ev/event {::ev/name "explore-libraries-click"
::ev/origin "dashboard" ::ev/origin "dashboard"
:section section})))) :section section}))))
on-key-down on-key-down
(mf/use-fn (mf/use-fn

View File

@ -31,7 +31,6 @@
[beicon.v2.core :as rx] [beicon.v2.core :as rx]
[cuerdas.core :as str] [cuerdas.core :as str]
[okulary.core :as l] [okulary.core :as l]
[potok.v2.core :as ptk]
[rumext.v2 :as mf])) [rumext.v2 :as mf]))
(def embed-images? true) (def embed-images? true)
@ -158,10 +157,10 @@
(let [origin (if (= :workspace from) (let [origin (if (= :workspace from)
"workspace" "workspace"
"viewer")] "viewer")]
(st/emit! (ptk/event ::ev/event (st/emit! (ev/event
{::ev/name "copy-inspect-code" {::ev/name "copy-inspect-code"
::ev/origin origin ::ev/origin origin
:type markup-type}))))) :type markup-type})))))
on-style-copied on-style-copied
(mf/use-fn (mf/use-fn
@ -170,10 +169,10 @@
(let [origin (if (= :workspace from) (let [origin (if (= :workspace from)
"workspace" "workspace"
"viewer")] "viewer")]
(st/emit! (ptk/event ::ev/event (st/emit! (ev/event
{::ev/name "copy-inspect-style" {::ev/name "copy-inspect-style"
::ev/origin origin ::ev/origin origin
:type style-type}))))) :type style-type})))))
{on-markup-pointer-down :on-pointer-down {on-markup-pointer-down :on-pointer-down
on-markup-lost-pointer-capture :on-lost-pointer-capture on-markup-lost-pointer-capture :on-lost-pointer-capture
@ -206,10 +205,10 @@
(let [origin (if (= :workspace from) (let [origin (if (= :workspace from)
"workspace" "workspace"
"viewer")] "viewer")]
(st/emit! (ptk/event ::ev/event (st/emit! (ev/event
{::ev/name "copy-inspect-code" {::ev/name "copy-inspect-code"
::ev/origin origin ::ev/origin origin
:type "all"}))))) :type "all"})))))
;;handle-open-review ;;handle-open-review
;;(mf/use-fn ;;(mf/use-fn

View File

@ -24,7 +24,6 @@
[app.util.dom :as dom] [app.util.dom :as dom]
[app.util.i18n :refer [tr]] [app.util.i18n :refer [tr]]
[app.util.shape-icon :as usi] [app.util.shape-icon :as usi]
[potok.v2.core :as ptk]
[rumext.v2 :as mf])) [rumext.v2 :as mf]))
(defn- get-libraries (defn- get-libraries
@ -75,7 +74,7 @@
(when on-change-section (when on-change-section
(on-change-section (keyword new-section)) (on-change-section (keyword new-section))
(st/emit! (st/emit!
(ptk/event ::ev/event {::ev/name "change-inspect-tab" :tab new-section}))))) (ev/event {::ev/name "change-inspect-tab" :tab new-section})))))
handle-expand handle-expand
(mf/use-fn (mf/use-fn
@ -122,7 +121,7 @@
(mf/deps shapes handle-change-tab) (mf/deps shapes handle-change-tab)
(fn [] (fn []
(if (seq shapes) (if (seq shapes)
(st/emit! (ptk/event ::ev/event {::ev/name "inspect-mode-click-element"})) (st/emit! (ev/event {::ev/name "inspect-mode-click-element"}))
(handle-change-tab (if (contains? cf/flags :inspect-styles) :styles :info))))) (handle-change-tab (if (contains? cf/flags :inspect-styles) :styles :info)))))
[:aside {:class (stl/css-case :settings-bar-right true [:aside {:class (stl/css-case :settings-bar-right true

View File

@ -11,14 +11,13 @@
[app.common.data :as d] [app.common.data :as d]
[app.common.data.macros :as dm] [app.common.data.macros :as dm]
[app.common.schema :as sm] [app.common.schema :as sm]
[app.main.data.event :as-alias ev] [app.main.data.event :as ev]
[app.main.data.profile :as du] [app.main.data.profile :as du]
[app.main.store :as st] [app.main.store :as st]
[app.main.ui.components.forms :as fm] [app.main.ui.components.forms :as fm]
[app.main.ui.icons :as deprecated-icon] [app.main.ui.icons :as deprecated-icon]
[app.util.i18n :as i18n :refer [tr]] [app.util.i18n :as i18n :refer [tr]]
[cuerdas.core :as str] [cuerdas.core :as str]
[potok.v2.core :as ptk]
[rumext.v2 :as mf])) [rumext.v2 :as mf]))
(mf/defc step-container (mf/defc step-container
@ -33,7 +32,7 @@
(assoc :label label) (assoc :label label)
(assoc :step step) (assoc :step step)
(assoc ::ev/name "onboarding-step"))] (assoc ::ev/name "onboarding-step"))]
(st/emit! (ptk/data-event ::ev/event params)) (st/emit! (ev/event params))
(on-next form event))))] (on-next form event))))]
[:& fm/form {:form form [:& fm/form {:form form

View File

@ -18,7 +18,6 @@
[app.main.ui.icons :as deprecated-icon] [app.main.ui.icons :as deprecated-icon]
[app.main.ui.notifications.context-notification :refer [context-notification]] [app.main.ui.notifications.context-notification :refer [context-notification]]
[app.util.i18n :as i18n :refer [tr]] [app.util.i18n :as i18n :refer [tr]]
[potok.v2.core :as ptk]
[rumext.v2 :as mf])) [rumext.v2 :as mf]))
(mf/defc left-sidebar (mf/defc left-sidebar
@ -121,13 +120,13 @@
params {:name name}] params {:name name}]
(st/emit! (-> (dtm/create-team (with-meta params mdata)) (st/emit! (-> (dtm/create-team (with-meta params mdata))
(with-meta {::ev/origin :onboarding-without-invitations})) (with-meta {::ev/origin :onboarding-without-invitations}))
(ptk/data-event ::ev/event (ev/event
{::ev/name "onboarding-step" {::ev/name "onboarding-step"
:label "team:create-team-and-invite-later" :label "team:create-team-and-invite-later"
:team-name name :team-name name
:step 8}) :step 8})
(ptk/data-event ::ev/event (ev/event
{::ev/name "onboarding-finish"}))))) {::ev/name "onboarding-finish"})))))
on-invite-now on-invite-now
(mf/use-fn (mf/use-fn
@ -137,15 +136,15 @@
(st/emit! (-> (dtm/create-team-with-invitations (with-meta params mdata)) (st/emit! (-> (dtm/create-team-with-invitations (with-meta params mdata))
(with-meta {::ev/origin :onboarding-with-invitations})) (with-meta {::ev/origin :onboarding-with-invitations}))
(ptk/data-event ::ev/event (ev/event
{::ev/name "onboarding-step" {::ev/name "onboarding-step"
:label "team:create-team-and-invite" :label "team:create-team-and-invite"
:invites (count emails) :invites (count emails)
:team-name name :team-name name
:role (:role params) :role (:role params)
:step 8}) :step 8})
(ptk/data-event ::ev/event (ev/event
{::ev/name "onboarding-finish"}))))) {::ev/name "onboarding-finish"})))))
on-submit* on-submit*
(mf/use-fn (mf/use-fn
@ -160,12 +159,12 @@
(mf/use-fn (mf/use-fn
(fn [] (fn []
(st/emit! (du/update-profile-props {:onboarding-viewed true}) (st/emit! (du/update-profile-props {:onboarding-viewed true})
(ptk/data-event ::ev/event (ev/event
{::ev/name "onboarding-step" {::ev/name "onboarding-step"
:label "team:skip-team-creation" :label "team:skip-team-creation"
:step 7}) :step 7})
(ptk/data-event ::ev/event (ev/event
{::ev/name "onboarding-finish"}))))] {::ev/name "onboarding-finish"}))))]
[:* [:*
[:div {:class (stl/css :modal-right)} [:div {:class (stl/css :modal-right)}
[:div {:class (stl/css :first-block)} [:div {:class (stl/css :first-block)}

View File

@ -18,7 +18,6 @@
[app.main.ui.icons :as deprecated-icon] [app.main.ui.icons :as deprecated-icon]
[app.util.i18n :as i18n :refer [tr]] [app.util.i18n :as i18n :refer [tr]]
[app.util.keyboard :as kbd] [app.util.keyboard :as kbd]
[potok.v2.core :as ptk]
[rumext.v2 :as mf])) [rumext.v2 :as mf]))
(def ^:private arrow-icon (def ^:private arrow-icon
@ -52,7 +51,7 @@
(defn- show-release-notes (defn- show-release-notes
[event] [event]
(let [version (:main cf/version)] (let [version (:main cf/version)]
(st/emit! (ptk/event ::ev/event {::ev/name "show-release-notes" :version version})) (st/emit! (ev/event {::ev/name "show-release-notes" :version version}))
(if (and (kbd/alt? event) (kbd/mod? event)) (if (and (kbd/alt? event) (kbd/mod? event))
(st/emit! (modal/show {:type :onboarding})) (st/emit! (modal/show {:type :onboarding}))

View File

@ -18,7 +18,6 @@
[app.main.ui.notifications.badge :refer [badge-notification]] [app.main.ui.notifications.badge :refer [badge-notification]]
[app.util.dom :as dom] [app.util.dom :as dom]
[app.util.i18n :as i18n :refer [tr c]] [app.util.i18n :as i18n :refer [tr c]]
[potok.v2.core :as ptk]
[rumext.v2 :as mf])) [rumext.v2 :as mf]))
(mf/defc plan-card* (mf/defc plan-card*
@ -132,16 +131,16 @@
add-payment-details? "&quantity=" add-payment-details? "&quantity="
min-members "&returnUrl=" return-url)] min-members "&returnUrl=" return-url)]
(reset! form nil) (reset! form nil)
(st/emit! (ptk/event ::ev/event {::ev/name "create-trial-subscription" (st/emit! (ev/event {::ev/name "create-trial-subscription"
:type "unlimited" :type "unlimited"
:quantity min-members}) :quantity min-members})
(rt/nav-raw :href href)))))) (rt/nav-raw :href href))))))
subscribe-to-enterprise subscribe-to-enterprise
(mf/use-fn (mf/use-fn
(fn [] (fn []
(st/emit! (ptk/event ::ev/event {::ev/name "create-trial-subscription" (st/emit! (ev/event {::ev/name "create-trial-subscription"
:type "enterprise"})) :type "enterprise"}))
(let [return-url (-> (rt/get-current-href) (rt/encode-url)) (let [return-url (-> (rt/get-current-href) (rt/encode-url))
href (dm/str "payments/subscriptions/create?type=enterprise&returnUrl=" return-url)] href (dm/str "payments/subscriptions/create?type=enterprise&returnUrl=" return-url)]
(st/emit! (rt/nav-raw :href href))))) (st/emit! (rt/nav-raw :href href)))))
@ -161,7 +160,7 @@
handle-close-dialog handle-close-dialog
(mf/use-fn (mf/use-fn
(fn [] (fn []
(st/emit! (ptk/event ::ev/event {::ev/name "close-subscription-modal"})) (st/emit! (ev/event {::ev/name "close-subscription-modal"}))
(modal/hide!))) (modal/hide!)))
show-editors-list* show-editors-list*
@ -323,7 +322,7 @@
(let [profile (mf/deref refs/profile) (let [profile (mf/deref refs/profile)
handle-close-dialog (mf/use-fn handle-close-dialog (mf/use-fn
(fn [] (fn []
(st/emit! (ptk/event ::ev/event {::ev/name "subscription-success"})) (st/emit! (ev/event {::ev/name "subscription-success"}))
(modal/hide!)))] (modal/hide!)))]
[:div {:class (stl/css :modal-overlay)} [:div {:class (stl/css :modal-overlay)}
@ -434,8 +433,8 @@
^boolean show-trial-subscription-modal? ^boolean show-trial-subscription-modal?
(st/emit! (st/emit!
(ptk/event ::ev/event {::ev/name "open-subscription-modal" (ev/event {::ev/name "open-subscription-modal"
::ev/origin "settings:from-pricing-page"}) ::ev/origin "settings:from-pricing-page"})
(modal/show :management-dialog (modal/show :management-dialog
{:subscription-type (if (= params-subscription "subscription-to-penpot-unlimited") {:subscription-type (if (= params-subscription "subscription-to-penpot-unlimited")
"unlimited" "unlimited"

View File

@ -24,7 +24,6 @@
[app.util.clipboard :as clipboard] [app.util.clipboard :as clipboard]
[app.util.dom :as dom] [app.util.dom :as dom]
[app.util.i18n :as i18n :refer [tr]] [app.util.i18n :as i18n :refer [tr]]
[potok.v2.core :as ptk]
[rumext.v2 :as mf])) [rumext.v2 :as mf]))
(log/set-level! :warn) (log/set-level! :warn)
@ -126,10 +125,10 @@
(let [params (prepare-params options) (let [params (prepare-params options)
params (assoc params :file-id (:id file))] params (assoc params :file-id (:id file))]
(st/emit! (dc/create-share-link params) (st/emit! (dc/create-share-link params)
(ptk/event ::ev/event {::ev/name "create-share-link" (ev/event {::ev/name "create-share-link"
::ev/origin "viewer" ::ev/origin "viewer"
:can-comment (:who-comment params) :can-comment (:who-comment params)
:can-inspect-code (:who-inspect params)})))) :can-inspect-code (:who-inspect params)}))))
copy-link copy-link
(fn [_] (fn [_]
@ -138,8 +137,8 @@
:type :toast :type :toast
:content (tr "common.share-link.link-copied-success") :content (tr "common.share-link.link-copied-success")
:timeout 1000}) :timeout 1000})
(ptk/event ::ev/event {::ev/name "copy-share-link" (ev/event {::ev/name "copy-share-link"
::ev/origin "viewer"}))) ::ev/origin "viewer"})))
try-delete-link try-delete-link
(fn [_] (fn [_]

View File

@ -24,7 +24,6 @@
[app.util.keyboard :as kbd] [app.util.keyboard :as kbd]
[app.util.object :as obj] [app.util.object :as obj]
[okulary.core :as l] [okulary.core :as l]
[potok.v2.core :as ptk]
[rumext.v2 :as mf])) [rumext.v2 :as mf]))
(mf/defc palette-item* (mf/defc palette-item*
@ -37,10 +36,10 @@
(st/emit! (mdc/add-recent-color color) (st/emit! (mdc/add-recent-color color)
(mdc/apply-color-from-palette color (kbd/alt? event)) (mdc/apply-color-from-palette color (kbd/alt? event))
(when (not= selected :recent) (when (not= selected :recent)
(ptk/data-event ::ev/event (ev/event
{::ev/name "use-library-color" {::ev/name "use-library-color"
::ev/origin "color-palette" ::ev/origin "color-palette"
:external-library (not= selected :file)}))))) :external-library (not= selected :file)})))))
title title
(uc/get-color-name color)] (uc/get-color-name color)]

View File

@ -15,7 +15,7 @@
[app.common.types.fills :as types.fills] [app.common.types.fills :as types.fills]
[app.common.types.tokens-lib :as ctob] [app.common.types.tokens-lib :as ctob]
[app.config :as cfg] [app.config :as cfg]
[app.main.data.event :as-alias ev] [app.main.data.event :as ev]
[app.main.data.modal :as modal] [app.main.data.modal :as modal]
[app.main.data.shortcuts :as dsc] [app.main.data.shortcuts :as dsc]
[app.main.data.workspace.colors :as dc] [app.main.data.workspace.colors :as dc]
@ -46,7 +46,6 @@
[app.util.timers :as ts] [app.util.timers :as ts]
[cuerdas.core :as str] [cuerdas.core :as str]
[okulary.core :as l] [okulary.core :as l]
[potok.v2.core :as ptk]
[rumext.v2 :as mf] [rumext.v2 :as mf]
[rumext.v2.util :as mfu])) [rumext.v2.util :as mfu]))
@ -174,9 +173,9 @@
(st/emit! (st/emit!
(dc/update-colorpicker-color {:image image} true) (dc/update-colorpicker-color {:image image} true)
(ptk/data-event ::ev/event {::ev/name "toggle-image-aspect-ratio" (ev/event {::ev/name "toggle-image-aspect-ratio"
::ev/origin "workspace:colorpicker" ::ev/origin "workspace:colorpicker"
:checked keep-aspect-ratio?}))))) :checked keep-aspect-ratio?})))))
on-change-tab on-change-tab
(mf/use-fn #(reset! active-color-tab* %)) (mf/use-fn #(reset! active-color-tab* %))

View File

@ -24,7 +24,6 @@
[app.main.ui.icons :as deprecated-icon] [app.main.ui.icons :as deprecated-icon]
[app.util.dom :as dom] [app.util.dom :as dom]
[app.util.i18n :as i18n :refer [tr]] [app.util.i18n :as i18n :refer [tr]]
[potok.v2.core :as ptk]
[rumext.v2 :as mf])) [rumext.v2 :as mf]))
(mf/defc libraries (mf/defc libraries
@ -87,8 +86,7 @@
(mf/deps state selected on-select-color) (mf/deps state selected on-select-color)
(fn [event] (fn [event]
(when-not (= :recent selected) (when-not (= :recent selected)
(st/emit! (ptk/event (st/emit! (ev/event
::ev/event
{::ev/name "use-library-color" {::ev/name "use-library-color"
::ev/origin "colorpicker" ::ev/origin "colorpicker"
:external-library (not= :file selected)}))) :external-library (not= :file selected)})))

View File

@ -41,7 +41,6 @@
[app.util.timers :as timers] [app.util.timers :as timers]
[beicon.v2.core :as rx] [beicon.v2.core :as rx]
[okulary.core :as l] [okulary.core :as l]
[potok.v2.core :as ptk]
[rumext.v2 :as mf])) [rumext.v2 :as mf]))
(def menu-ref (def menu-ref
@ -676,7 +675,7 @@
:on-accept delete-fn})) :on-accept delete-fn}))
do-duplicate #(st/emit! do-duplicate #(st/emit!
(dw/duplicate-page id) (dw/duplicate-page id)
(ptk/event ::ev/event {::ev/name "duplicate-page"})) (ev/event {::ev/name "duplicate-page"}))
do-rename #(st/emit! (dw/start-rename-page-item id))] do-rename #(st/emit! (dw/start-rename-page-item id))]
[:* [:*

View File

@ -43,7 +43,6 @@
[app.util.i18n :as i18n :refer [tr]] [app.util.i18n :as i18n :refer [tr]]
[app.util.keyboard :as kbd] [app.util.keyboard :as kbd]
[beicon.v2.core :as rx] [beicon.v2.core :as rx]
[potok.v2.core :as ptk]
[rumext.v2 :as mf])) [rumext.v2 :as mf]))
(mf/defc shortcuts* (mf/defc shortcuts*
@ -62,43 +61,43 @@
(let [nav-to-helpc-center (let [nav-to-helpc-center
(mf/use-fn (mf/use-fn
(fn [] (fn []
(st/emit! (ptk/event ::ev/event {::ev/name "explore-help-center-click" (st/emit! (ev/event {::ev/name "explore-help-center-click"
::ev/origin "workspace-menu:in-app"})) ::ev/origin "workspace-menu:in-app"}))
(dom/open-new-window "https://help.penpot.app"))) (dom/open-new-window "https://help.penpot.app")))
nav-to-community nav-to-community
(mf/use-fn (mf/use-fn
(fn [] (fn []
(st/emit! (ptk/event ::ev/event {::ev/name "explore-community-click" (st/emit! (ev/event {::ev/name "explore-community-click"
::ev/origin "workspace-menu:in-app"})) ::ev/origin "workspace-menu:in-app"}))
(dom/open-new-window "https://community.penpot.app"))) (dom/open-new-window "https://community.penpot.app")))
nav-to-youtube nav-to-youtube
(mf/use-fn (mf/use-fn
(fn [] (fn []
(st/emit! (ptk/event ::ev/event {::ev/name "explore-tutorials-click" (st/emit! (ev/event {::ev/name "explore-tutorials-click"
::ev/origin "workspace-menu:in-app"})) ::ev/origin "workspace-menu:in-app"}))
(dom/open-new-window "https://www.youtube.com/c/Penpot"))) (dom/open-new-window "https://www.youtube.com/c/Penpot")))
nav-to-templates nav-to-templates
(mf/use-fn (mf/use-fn
(fn [] (fn []
(st/emit! (ptk/event ::ev/event {::ev/name "explore-libraries-click" (st/emit! (ev/event {::ev/name "explore-libraries-click"
::ev/origin "workspace"})) ::ev/origin "workspace"}))
(dom/open-new-window "https://penpot.app/libraries-templates"))) (dom/open-new-window "https://penpot.app/libraries-templates")))
nav-to-github nav-to-github
(mf/use-fn (mf/use-fn
(fn [] (fn []
(st/emit! (ptk/event ::ev/event {::ev/name "explore-github-repository-click" (st/emit! (ev/event {::ev/name "explore-github-repository-click"
::ev/origin "workspace-menu:in-app"})) ::ev/origin "workspace-menu:in-app"}))
(dom/open-new-window "https://github.com/penpot/penpot"))) (dom/open-new-window "https://github.com/penpot/penpot")))
nav-to-terms nav-to-terms
(mf/use-fn (mf/use-fn
(fn [] (fn []
(st/emit! (ptk/event ::ev/event {::ev/name "explore-terms-service-click" (st/emit! (ev/event {::ev/name "explore-terms-service-click"
::ev/origin "workspace-menu:in-app"})) ::ev/origin "workspace-menu:in-app"}))
(dom/open-new-window "https://penpot.app/terms"))) (dom/open-new-window "https://penpot.app/terms")))
nav-to-feedback nav-to-feedback
@ -125,8 +124,8 @@
(mf/use-fn (mf/use-fn
(fn [event] (fn [event]
(let [version (:main cf/version)] (let [version (:main cf/version)]
(st/emit! (ptk/event ::ev/event {::ev/name "show-release-notes" (st/emit! (ev/event {::ev/name "show-release-notes"
:version version})) :version version}))
(println version) (println version)
(if (and (kbd/alt? event) (kbd/mod? event)) (if (and (kbd/alt? event) (kbd/mod? event))
(st/emit! (modal/show {:type :onboarding})) (st/emit! (modal/show {:type :onboarding}))
@ -712,10 +711,10 @@
(fn [event] (fn [event]
(if can-open? (if can-open?
(do (do
(st/emit! (ptk/event ::ev/event {::ev/name "start-plugin" (st/emit! (ev/event {::ev/name "start-plugin"
::ev/origin "workspace:menu" ::ev/origin "workspace:menu"
:name name :name name
:host host})) :host host}))
(dp/open-plugin! manifest user-can-edit?)) (dp/open-plugin! manifest user-can-edit?))
(dom/stop-propagation event)))) (dom/stop-propagation event))))
on-key-down on-key-down
@ -724,10 +723,10 @@
(fn [event] (fn [event]
(when can-open? (when can-open?
(when (kbd/enter? event) (when (kbd/enter? event)
(st/emit! (ptk/event ::ev/event {::ev/name "start-plugin" (st/emit! (ev/event {::ev/name "start-plugin"
::ev/origin "workspace:menu" ::ev/origin "workspace:menu"
:name name :name name
:host host})) :host host}))
(dp/open-plugin! manifest user-can-edit?)))))] (dp/open-plugin! manifest user-can-edit?)))))]
[:> dropdown-menu-item* {:key (dm/str "plugins-menu-" idx) [:> dropdown-menu-item* {:key (dm/str "plugins-menu-" idx)
@ -765,8 +764,8 @@
on-nav-to-integrations on-nav-to-integrations
(mf/use-fn (mf/use-fn
(fn [] (fn []
(st/emit! (ptk/event ::ev/event {::ev/name "manage-mpc-option" (st/emit! (ev/event {::ev/name "manage-mpc-option"
::ev/origin "workspace-menu"})) ::ev/origin "workspace-menu"}))
(dom/open-new-window "/#/settings/integrations"))) (dom/open-new-window "/#/settings/integrations")))
on-nav-to-integrations-key-down on-nav-to-integrations-key-down
@ -780,11 +779,11 @@
(fn [] (fn []
(if mcp-connected? (if mcp-connected?
(st/emit! (mcp/user-disconnect-mcp) (st/emit! (mcp/user-disconnect-mcp)
(ptk/event ::ev/event {::ev/name "disconnect-mcp-plugin" (ev/event {::ev/name "disconnect-mcp-plugin"
::ev/origin "workspace-menu"})) ::ev/origin "workspace-menu"}))
(st/emit! (mcp/connect-mcp) (st/emit! (mcp/connect-mcp)
(ptk/event ::ev/event {::ev/name "connect-mcp-plugin" (ev/event {::ev/name "connect-mcp-plugin"
::ev/origin "workspace-menu"}))))) ::ev/origin "workspace-menu"})))))
on-toggle-mcp-plugin-key-down on-toggle-mcp-plugin-key-down
(mf/use-fn (mf/use-fn
@ -866,8 +865,8 @@
on-power-up-click on-power-up-click
(mf/use-fn (mf/use-fn
(fn [] (fn []
(st/emit! (ptk/event ::ev/event {::ev/name "explore-pricing-click" (st/emit! (ev/event {::ev/name "explore-pricing-click"
::ev/origin "workspace-menu"})) ::ev/origin "workspace-menu"}))
(dom/open-new-window "https://penpot.app/pricing"))) (dom/open-new-window "https://penpot.app/pricing")))
toggle-flag toggle-flag
@ -896,8 +895,8 @@
(reset! show-menu* false) (reset! show-menu* false)
(reset! selected-sub-menu* nil) (reset! selected-sub-menu* nil)
(st/emit! (st/emit!
(ptk/event ::ev/event {::ev/name "open-plugins-manager" (ev/event {::ev/name "open-plugins-manager"
::ev/origin "workspace:menu"}) ::ev/origin "workspace:menu"})
(modal/show :plugin-management {})))) (modal/show :plugin-management {}))))
subscription (:subscription (:props profile)) subscription (:subscription (:props profile))

View File

@ -27,7 +27,6 @@
[app.util.i18n :as i18n :refer [tr]] [app.util.i18n :as i18n :refer [tr]]
[beicon.v2.core :as rx] [beicon.v2.core :as rx]
[cuerdas.core :as str] [cuerdas.core :as str]
[potok.v2.core :as ptk]
[rumext.v2 :as mf])) [rumext.v2 :as mf]))
(def ^:private close-icon (def ^:private close-icon
@ -128,7 +127,7 @@
(reset! fetching-manifest? false) (reset! fetching-manifest? false)
(if plugin (if plugin
(do (do
(st/emit! (ptk/event ::ev/event {::ev/name "install-plugin" :name (:name plugin) :url plugin-url})) (st/emit! (ev/event {::ev/name "install-plugin" :name (:name plugin) :url plugin-url}))
(modal/show! (modal/show!
:plugin-permissions :plugin-permissions
{:plugin plugin {:plugin plugin
@ -148,10 +147,10 @@
handle-open-plugin handle-open-plugin
(mf/use-fn (mf/use-fn
(fn [manifest] (fn [manifest]
(st/emit! (ptk/event ::ev/event {::ev/name "start-plugin" (st/emit! (ev/event {::ev/name "start-plugin"
::ev/origin "workspace:plugins" ::ev/origin "workspace:plugins"
:name (:name manifest) :name (:name manifest)
:host (:host manifest)})) :host (:host manifest)}))
(dp/open-plugin! manifest user-can-edit?) (dp/open-plugin! manifest user-can-edit?)
(modal/hide!))) (modal/hide!)))
@ -161,9 +160,9 @@
(fn [plugin-index] (fn [plugin-index]
(let [plugins-list (preg/plugins-list) (let [plugins-list (preg/plugins-list)
plugin (nth plugins-list plugin-index)] plugin (nth plugins-list plugin-index)]
(st/emit! (ptk/event ::ev/event {::ev/name "remove-plugin" (st/emit! (ev/event {::ev/name "remove-plugin"
:name (:name plugin) :name (:name plugin)
:host (:host plugin)})) :host (:host plugin)}))
(dp/close-plugin! plugin) (dp/close-plugin! plugin)
(preg/remove-plugin! plugin) (preg/remove-plugin! plugin)
(reset! plugins-state* (preg/plugins-list)))))] (reset! plugins-state* (preg/plugins-list)))))]
@ -195,7 +194,7 @@
(when-not (empty? plugins-state) (when-not (empty? plugins-state)
[:> i18n/tr-html* [:> i18n/tr-html*
{:class (stl/css :discover) {:class (stl/css :discover)
:on-click #(st/emit! (ptk/event ::ev/event {::ev/name "open-plugins-list"})) :on-click #(st/emit! (ev/event {::ev/name "open-plugins-list"}))
:content (tr "workspace.plugins.discover" cfg/plugins-list-uri)}]) :content (tr "workspace.plugins.discover" cfg/plugins-list-uri)}])
[:hr] [:hr]
@ -207,7 +206,7 @@
[:a {:class (stl/css :plugins-link) [:a {:class (stl/css :plugins-link)
:href cfg/plugins-list-uri :href cfg/plugins-list-uri
:target "_blank" :target "_blank"
:on-click #(st/emit! (ptk/event ::ev/event {::ev/name "open-plugins-list"}))} :on-click #(st/emit! (ev/event {::ev/name "open-plugins-list"}))}
(tr "workspace.plugins.plugin-list-link") deprecated-icon/external-link]] (tr "workspace.plugins.plugin-list-link") deprecated-icon/external-link]]
[:* [:*
@ -298,9 +297,9 @@
(mf/use-fn (mf/use-fn
(fn [event] (fn [event]
(dom/prevent-default event) (dom/prevent-default event)
(st/emit! (ptk/event ::ev/event {::ev/name "allow-plugin-permissions" (st/emit! (ev/event {::ev/name "allow-plugin-permissions"
:host host :host host
:permissions (->> permissions (str/join ", "))}) :permissions (->> permissions (str/join ", "))})
(modal/hide)) (modal/hide))
(when on-accept (on-accept)))) (when on-accept (on-accept))))
@ -308,9 +307,9 @@
(mf/use-fn (mf/use-fn
(fn [event] (fn [event]
(dom/prevent-default event) (dom/prevent-default event)
(st/emit! (ptk/event ::ev/event {::ev/name "reject-plugin-permissions" (st/emit! (ev/event {::ev/name "reject-plugin-permissions"
:host host :host host
:permissions (->> permissions (str/join ", "))}) :permissions (->> permissions (str/join ", "))})
(modal/hide)) (modal/hide))
(when on-close (on-close))))] (when on-close (on-close))))]
@ -353,9 +352,9 @@
(mf/use-fn (mf/use-fn
(fn [event] (fn [event]
(dom/prevent-default event) (dom/prevent-default event)
(st/emit! (ptk/event ::ev/event {::ev/name "allow-plugin-permissions" (st/emit! (ev/event {::ev/name "allow-plugin-permissions"
:host host :host host
:permissions (->> permissions (str/join ", "))}) :permissions (->> permissions (str/join ", "))})
(modal/hide)) (modal/hide))
(when on-accept (on-accept)))) (when on-accept (on-accept))))
@ -363,9 +362,9 @@
(mf/use-fn (mf/use-fn
(fn [event] (fn [event]
(dom/prevent-default event) (dom/prevent-default event)
(st/emit! (ptk/event ::ev/event {::ev/name "reject-plugin-permissions" (st/emit! (ev/event {::ev/name "reject-plugin-permissions"
:host host :host host
:permissions (->> permissions (str/join ", "))}) :permissions (->> permissions (str/join ", "))})
(modal/hide)) (modal/hide))
(when on-close (on-close))))] (when on-close (on-close))))]
@ -406,7 +405,7 @@
(mf/use-fn (mf/use-fn
(fn [event] (fn [event]
(dom/prevent-default event) (dom/prevent-default event)
(st/emit! (ptk/event ::ev/event {::ev/name "try-out-accept"}) (st/emit! (ev/event {::ev/name "try-out-accept"})
(modal/hide)) (modal/hide))
(when on-accept (on-accept)))) (when on-accept (on-accept))))
@ -414,7 +413,7 @@
(mf/use-fn (mf/use-fn
(fn [event] (fn [event]
(dom/prevent-default event) (dom/prevent-default event)
(st/emit! (ptk/event ::ev/event {::ev/name "try-out-cancel"}) (st/emit! (ev/event {::ev/name "try-out-cancel"})
(modal/hide)) (modal/hide))
(when on-close (on-close))))] (when on-close (on-close))))]

View File

@ -43,7 +43,6 @@
[app.main.ui.workspace.tokens.sidebar :refer [tokens-sidebar-tab*]] [app.main.ui.workspace.tokens.sidebar :refer [tokens-sidebar-tab*]]
[app.util.debug :as dbg] [app.util.debug :as dbg]
[app.util.i18n :refer [tr]] [app.util.i18n :refer [tr]]
[potok.v2.core :as ptk]
[rumext.v2 :as mf])) [rumext.v2 :as mf]))
;; --- Left Sidebar (Component) ;; --- Left Sidebar (Component)
@ -146,7 +145,7 @@
(fn [id] (fn [id]
(st/emit! (dcm/go-to-workspace :layout (keyword id))) (st/emit! (dcm/go-to-workspace :layout (keyword id)))
(when (= id "tokens") (when (= id "tokens")
(st/emit! (ptk/event ::ev/event {::ev/name "open-tokens-tab"}))))) (st/emit! (ev/event {::ev/name "open-tokens-tab"})))))
tabs tabs
(mf/with-memo [mode-inspect? design-tokens?] (mf/with-memo [mode-inspect? design-tokens?]

View File

@ -31,7 +31,6 @@
[app.util.keyboard :as kbd] [app.util.keyboard :as kbd]
[cuerdas.core :as str] [cuerdas.core :as str]
[okulary.core :as l] [okulary.core :as l]
[potok.v2.core :as ptk]
[rumext.v2 :as mf])) [rumext.v2 :as mf]))
(mf/defc color-item (mf/defc color-item
@ -180,10 +179,10 @@
(mf/deps color on-asset-click read-only? file-id) (mf/deps color on-asset-click read-only? file-id)
(fn [event] (fn [event]
(when-not read-only? (when-not read-only?
(st/emit! (ptk/data-event ::ev/event (st/emit! (ev/event
{::ev/name "use-library-color" {::ev/name "use-library-color"
::ev/origin "sidebar" ::ev/origin "sidebar"
:external-library (not local?)})) :external-library (not local?)}))
(when-not (on-asset-click event (:id color)) (when-not (on-asset-click event (:id color))
(st/emit! (dc/apply-color-from-assets file-id color (kbd/alt? event)))))))] (st/emit! (dc/apply-color-from-assets file-id color (kbd/alt? event)))))))]
@ -403,8 +402,8 @@
y-position (:top bounds)] y-position (:top bounds)]
(st/emit! (dw/set-assets-section-open file-id :colors true) (st/emit! (dw/set-assets-section-open file-id :colors true)
(ptk/event ::ev/event {::ev/name "add-asset-to-library" (ev/event {::ev/name "add-asset-to-library"
:asset-type "color"}) :asset-type "color"})
(modal/show :colorpicker (modal/show :colorpicker
{:x x-position {:x x-position
:y y-position :y y-position

View File

@ -35,7 +35,6 @@
[app.util.i18n :as i18n :refer [tr]] [app.util.i18n :as i18n :refer [tr]]
[cuerdas.core :as str] [cuerdas.core :as str]
[okulary.core :as l] [okulary.core :as l]
[potok.v2.core :as ptk]
[rumext.v2 :as mf])) [rumext.v2 :as mf]))
(def drag-data* (atom {:is-local false})) (def drag-data* (atom {:is-local false}))
@ -373,8 +372,8 @@
(let [params {:file-id file-id (let [params {:file-id file-id
:blobs (seq blobs)}] :blobs (seq blobs)}]
(st/emit! (dwm/upload-media-components params) (st/emit! (dwm/upload-media-components params)
(ptk/event ::ev/event {::ev/name "add-asset-to-library" (ev/event {::ev/name "add-asset-to-library"
:asset-type "components"}))))) :asset-type "components"})))))
on-duplicate on-duplicate
(mf/use-fn (mf/use-fn

View File

@ -32,7 +32,6 @@
[app.util.keyboard :as kbd] [app.util.keyboard :as kbd]
[cuerdas.core :as str] [cuerdas.core :as str]
[okulary.core :as l] [okulary.core :as l]
[potok.v2.core :as ptk]
[rumext.v2 :as mf])) [rumext.v2 :as mf]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -94,7 +93,7 @@
(mf/use-fn (mf/use-fn
(fn [ev] (fn [ev]
(dom/stop-propagation ev) (dom/stop-propagation ev)
(st/emit! (ptk/data-event ::ev/event {::ev/name "navigate-to-library-file"}))))] (st/emit! (ev/event {::ev/name "navigate-to-library-file"}))))]
[:div {:class (stl/css-case [:div {:class (stl/css-case
:library-title true :library-title true

View File

@ -28,7 +28,6 @@
[app.util.i18n :as i18n :refer [tr]] [app.util.i18n :as i18n :refer [tr]]
[cuerdas.core :as str] [cuerdas.core :as str]
[okulary.core :as l] [okulary.core :as l]
[potok.v2.core :as ptk]
[rumext.v2 :as mf])) [rumext.v2 :as mf]))
(def lens:typography-section-state (def lens:typography-section-state
@ -97,10 +96,10 @@
(mf/deps typography on-asset-click read-only? local?) (mf/deps typography on-asset-click read-only? local?)
(fn [event] (fn [event]
(when-not read-only? (when-not read-only?
(st/emit! (ptk/data-event ::ev/event (st/emit! (ev/event
{::ev/name "use-library-typography" {::ev/name "use-library-typography"
::ev/origin "sidebar" ::ev/origin "sidebar"
:external-library (not local?)})) :external-library (not local?)}))
(when-not (on-asset-click event (:id typography)) (when-not (on-asset-click event (:id typography))
(st/emit! (dwt/apply-typography typography file-id))))))] (st/emit! (dwt/apply-typography typography file-id))))))]

View File

@ -19,7 +19,6 @@
[app.util.i18n :refer [tr]] [app.util.i18n :refer [tr]]
[app.util.object :as obj] [app.util.object :as obj]
[cuerdas.core :as str] [cuerdas.core :as str]
[potok.v2.core :as ptk]
[rumext.v2 :as mf])) [rumext.v2 :as mf]))
(mf/defc typography-item (mf/defc typography-item
@ -38,8 +37,7 @@
:typography-ref-id (:id typography)} :typography-ref-id (:id typography)}
(dissoc typography :id :name))] (dissoc typography :id :name))]
(st/emit! (ptk/event (st/emit! (ev/event
::ev/event
{::ev/name "use-library-typography" {::ev/name "use-library-typography"
::ev/origin "text-palette" ::ev/origin "text-palette"
:external-library (not= file-id current-file-id)})) :external-library (not= file-id current-file-id)}))

View File

@ -23,7 +23,6 @@
[app.util.i18n :refer [tr]] [app.util.i18n :refer [tr]]
[app.util.webapi :as wapi] [app.util.webapi :as wapi]
[app.util.zip :as zip] [app.util.zip :as zip]
[potok.v2.core :as ptk]
[rumext.v2 :as mf])) [rumext.v2 :as mf]))
(mf/defc export-tab* (mf/defc export-tab*
@ -61,7 +60,7 @@
(mf/deps tokens-json) (mf/deps tokens-json)
(fn [] (fn []
(when tokens-json (when tokens-json
(st/emit! (ptk/data-event ::ev/event {::ev/name "export-tokens" :type "single"})) (st/emit! (ev/event {::ev/name "export-tokens" :type "single"}))
(->> (wapi/create-blob (or tokens-json "{}") "application/json") (->> (wapi/create-blob (or tokens-json "{}") "application/json")
(dom/trigger-download "tokens.json")))))] (dom/trigger-download "tokens.json")))))]
[:> export-tab* {:is-disabled is-disabled [:> export-tab* {:is-disabled is-disabled
@ -88,7 +87,7 @@
(mf/use-fn (mf/use-fn
(mf/deps files) (mf/deps files)
(fn [] (fn []
(st/emit! (ptk/data-event ::ev/event {::ev/name "export-tokens" :type "multiple"})) (st/emit! (ev/event {::ev/name "export-tokens" :type "multiple"}))
(download-tokens-zip! files)))] (download-tokens-zip! files)))]
[:> export-tab* {:on-export on-export [:> export-tab* {:on-export on-export
:is-disabled is-disabled} :is-disabled is-disabled}

View File

@ -27,7 +27,6 @@
[app.util.zip :as uz] [app.util.zip :as uz]
[beicon.v2.core :as rx] [beicon.v2.core :as rx]
[cuerdas.core :as str] [cuerdas.core :as str]
[potok.v2.core :as ptk]
[rumext.v2 :as mf])) [rumext.v2 :as mf]))
(defn- on-stream-imported (defn- on-stream-imported
@ -35,7 +34,7 @@
(rx/sub! (rx/sub!
tokens-lib-stream tokens-lib-stream
(fn [lib] (fn [lib]
(st/emit! (ptk/data-event ::ev/event {::ev/name "import-tokens" :type type}) (st/emit! (ev/event {::ev/name "import-tokens" :type type})
(dwtl/import-tokens-lib lib)) (dwtl/import-tokens-lib lib))
(modal/hide!)) (modal/hide!))
(fn [err] (fn [err]

View File

@ -7,8 +7,7 @@
[app.main.data.notifications :as ntf] [app.main.data.notifications :as ntf]
[app.main.data.workspace.tokens.library-edit :as dwtl] [app.main.data.workspace.tokens.library-edit :as dwtl]
[app.main.store :as st] [app.main.store :as st]
[app.util.i18n :refer [tr]] [app.util.i18n :refer [tr]]))
[potok.v2.core :as ptk]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; HELPERS - Shared functions for token sets management ;; HELPERS - Shared functions for token sets management
@ -37,7 +36,7 @@
[tokens-lib parent-set name] [tokens-lib parent-set name]
(let [name (ctob/make-child-name parent-set name) (let [name (ctob/make-child-name parent-set name)
errors (sm/validation-errors name (cfo/make-token-set-name-schema tokens-lib nil))] errors (sm/validation-errors name (cfo/make-token-set-name-schema tokens-lib nil))]
(st/emit! (ptk/data-event ::ev/event {::ev/name "create-token-set" :name name}) (st/emit! (ev/event {::ev/name "create-token-set" :name name})
(dwtl/clear-token-set-creation)) (dwtl/clear-token-set-creation))
(if (empty? errors) (if (empty? errors)
(let [token-set (ctob/make-token-set :name name)] (let [token-set (ctob/make-token-set :name name)]

View File

@ -33,7 +33,6 @@
[app.util.i18n :refer [tr]] [app.util.i18n :refer [tr]]
[app.util.keyboard :as k] [app.util.keyboard :as k]
[cuerdas.core :as str] [cuerdas.core :as str]
[potok.v2.core :as ptk]
[rumext.v2 :as mf])) [rumext.v2 :as mf]))
;; Form Component -------------------------------------------------------------- ;; Form Component --------------------------------------------------------------
@ -412,7 +411,7 @@
on-save on-save
(mf/use-fn (mf/use-fn
(fn [theme] (fn [theme]
(st/emit! (ptk/event ::ev/event {::ev/name "create-tokens-theme"}) (st/emit! (ev/event {::ev/name "create-tokens-theme"})
(dwtl/create-token-theme theme)))) (dwtl/create-token-theme theme))))
has-prev-view (has-prev-view (:prev-type state))] has-prev-view (has-prev-view (:prev-type state))]

View File

@ -24,7 +24,6 @@
[app.util.i18n :as i18n :refer [tr]] [app.util.i18n :as i18n :refer [tr]]
[app.util.timers :as ts] [app.util.timers :as ts]
[okulary.core :as l] [okulary.core :as l]
[potok.v2.core :as ptk]
[rumext.v2 :as mf])) [rumext.v2 :as mf]))
(mf/defc image-upload (mf/defc image-upload
@ -209,8 +208,8 @@
:aria-label (tr "workspace.toolbar.plugins" (sc/get-tooltip :plugins)) :aria-label (tr "workspace.toolbar.plugins" (sc/get-tooltip :plugins))
:class (stl/css :main-toolbar-options-button) :class (stl/css :main-toolbar-options-button)
:on-click #(st/emit! :on-click #(st/emit!
(ptk/data-event ::ev/event {::ev/name "open-plugins-manager" (ev/event {::ev/name "open-plugins-manager"
::ev/origin "workspace:toolbar"}) ::ev/origin "workspace:toolbar"})
(modal/show :plugin-management {})) (modal/show :plugin-management {}))
:data-tool "plugins" :data-tool "plugins"
:data-testid "plugins-btn"} :data-testid "plugins-btn"}

View File

@ -273,6 +273,7 @@
(->> (dwm/upload-media-url name file-id url) (->> (dwm/upload-media-url name file-id url)
(rx/take 1) (rx/take 1)
(rx/map format/format-image) (rx/map format/format-image)
(rx/tap #(st/emit! (se/event plugin-id "add-media")))
(rx/subs! resolve reject))))))) (rx/subs! resolve reject)))))))
:uploadMediaData :uploadMediaData
@ -289,6 +290,7 @@
:on-svg identity}) :on-svg identity})
(rx/take 1) (rx/take 1)
(rx/map format/format-image) (rx/map format/format-image)
(rx/tap #(st/emit! (se/event plugin-id "add-media")))
(rx/subs! resolve reject)))))) (rx/subs! resolve reject))))))
:group :group
@ -462,6 +464,7 @@
(conj acc (cg/generate-formatted-markup-code objects type resolved-shapes)))) (conj acc (cg/generate-formatted-markup-code objects type resolved-shapes))))
[]))] []))]
(st/emit! (se/event plugin-id "copy-inspect-code"))
(->> resolved-code (str/join "\n")))))) (->> resolved-code (str/join "\n"))))))
:generateStyle :generateStyle
@ -508,6 +511,7 @@
(cg/generate-style-code (cg/generate-style-code
objects type shapes resolved-shapes {:with-prelude? prelude?})))) objects type shapes resolved-shapes {:with-prelude? prelude?}))))
[]))] []))]
(st/emit! (se/event plugin-id "copy-inspect-style"))
(dm/str (dm/str
(if prelude? (cg/prelude type) "") (if prelude? (cg/prelude type) "")
(->> resolved-styles (->> resolved-styles
@ -542,7 +546,8 @@
(fn [] (fn []
(let [file-id (:current-file-id @st/state) (let [file-id (:current-file-id @st/state)
id (uuid/next)] id (uuid/next)]
(st/emit! (dw/create-page {:page-id id :file-id file-id})) (st/emit! (-> (dw/create-page {:page-id id :file-id file-id})
(se/add-event plugin-id)))
(page/page-proxy plugin-id file-id id))) (page/page-proxy plugin-id file-id id)))
:openPage :openPage
@ -648,9 +653,10 @@
ids)] ids)]
(if valid? (if valid?
(let [variant-id (uuid/next)] (let [variant-id (uuid/next)]
(st/emit! (dwv/combine-as-variants (st/emit! (-> (dwv/combine-as-variants
ids ids
{:trigger "plugin:combine-as-variants" :variant-id variant-id})) {:trigger "plugin:combine-as-variants" :variant-id variant-id})
(se/add-event plugin-id)))
(shape/shape-proxy plugin-id variant-id)) (shape/shape-proxy plugin-id variant-id))
(u/not-valid plugin-id :shapes "One of the components is not on the same page or is already a variant"))))))) (u/not-valid plugin-id :shapes "One of the components is not on the same page or is already a variant")))))))

View File

@ -17,6 +17,7 @@
[app.plugins.parser :as parser] [app.plugins.parser :as parser]
[app.plugins.register :as r] [app.plugins.register :as r]
[app.plugins.shape :as shape] [app.plugins.shape :as shape]
[app.plugins.system-events :as se]
[app.plugins.user :as user] [app.plugins.user :as user]
[app.plugins.utils :as u] [app.plugins.utils :as u]
[app.util.object :as obj] [app.util.object :as obj]
@ -71,7 +72,13 @@
:else :else
(->> (rp/cmd! :update-comment {:id (:id data) :content content}) (->> (rp/cmd! :update-comment {:id (:id data) :content content})
(rx/tap #(st/emit! (dc/retrieve-comment-threads file-id))) (rx/tap #(st/emit! (dc/retrieve-comment-threads file-id)))
(rx/subs! #(swap! data* assoc :content content))))))} (rx/subs!
(fn []
(st/emit! (se/event plugin-id "update-comment"
:thread-id thread-id
:id (:id data)
:content-size (count content)))
(swap! data* assoc :content content)))))))}
;; Public methods ;; Public methods
:remove :remove
@ -87,7 +94,11 @@
:else :else
(->> (rp/cmd! :delete-comment {:id (:id data)}) (->> (rp/cmd! :delete-comment {:id (:id data)})
(rx/tap #(st/emit! (dc/retrieve-comment-threads file-id))) (rx/tap #(st/emit! (dc/retrieve-comment-threads file-id)))
(rx/subs! #(resolve) reject))))))))) (rx/subs!
(fn []
(st/emit! (se/event plugin-id "update-comment" :thread-id thread-id))
(resolve))
reject)))))))))
(defn comment-thread-proxy? [p] (defn comment-thread-proxy? [p]
(obj/type-of? p "CommentThreadProxy")) (obj/type-of? p "CommentThreadProxy"))
@ -143,7 +154,8 @@
(u/not-valid plugin-id :resolved "Plugin doesn't have 'comment:write' permission") (u/not-valid plugin-id :resolved "Plugin doesn't have 'comment:write' permission")
:else :else
(do (st/emit! (dc/update-comment-thread (assoc @data* :is-resolved is-resolved))) (do (st/emit! (-> (dc/update-comment-thread (assoc @data* :is-resolved is-resolved))
(se/add-event plugin-id)))
(swap! data* assoc :is-resolved is-resolved))))} (swap! data* assoc :is-resolved is-resolved))))}
:findComments :findComments
@ -178,7 +190,13 @@
(js/Promise. (js/Promise.
(fn [resolve reject] (fn [resolve reject]
(->> (rp/cmd! :create-comment {:thread-id (:id data) :content content}) (->> (rp/cmd! :create-comment {:thread-id (:id data) :content content})
(rx/subs! #(resolve (comment-proxy plugin-id file-id page-id (:id data) %)) reject)))))) (rx/subs!
(fn [result]
(st/emit! (se/event plugin-id "create-comment"
:thread-id (:id data)
:file-id file-id
:content-size (count content)))
(resolve (comment-proxy plugin-id file-id page-id (:id data) result))) reject))))))
:remove :remove
(fn [] (fn []
@ -194,4 +212,5 @@
:else :else
(js/Promise. (js/Promise.
(fn [resolve] (fn [resolve]
(st/emit! (dc/delete-comment-thread-on-workspace {:id (:id data)} #(resolve))))))))))) (st/emit! (-> (dc/delete-comment-thread-on-workspace {:id (:id data)} #(resolve))
(se/add-event plugin-id)))))))))))

View File

@ -22,6 +22,7 @@
[app.plugins.page :as page] [app.plugins.page :as page]
[app.plugins.parser :as parser] [app.plugins.parser :as parser]
[app.plugins.register :as r] [app.plugins.register :as r]
[app.plugins.system-events :as se]
[app.plugins.user :as user] [app.plugins.user :as user]
[app.plugins.utils :as u] [app.plugins.utils :as u]
[app.util.http :as http] [app.util.http :as http]
@ -54,6 +55,7 @@
(do (swap! data assoc :label value :created-by "user") (do (swap! data assoc :label value :created-by "user")
(->> (rp/cmd! :update-file-snapshot {:id (:id @data) :label value}) (->> (rp/cmd! :update-file-snapshot {:id (:id @data) :label value})
(rx/take 1) (rx/take 1)
(rx/take #(st/emit! (se/event "rename-version" :file-id file-id)))
(rx/subs! identity)))))} (rx/subs! identity)))))}
:createdBy :createdBy
@ -78,7 +80,9 @@
:else :else
(let [version-id (get @data :id)] (let [version-id (get @data :id)]
(st/emit! (dwv/restore-version-from-plugin file-id version-id resolve reject))))))) (st/emit!
(dwv/restore-version-from-plugin file-id version-id resolve reject)
(se/event plugin-id "restore-version" :file-id file-id)))))))
:remove :remove
(fn [] (fn []
@ -110,10 +114,12 @@
:label (ct/format-inst (:created-at @data) :localized-date)}] :label (ct/format-inst (:created-at @data) :localized-date)}]
(->> (rx/zip (rp/cmd! :get-team-users {:file-id file-id}) (->> (rx/zip (rp/cmd! :get-team-users {:file-id file-id})
(rp/cmd! :update-file-snapshot params)) (rp/cmd! :update-file-snapshot params))
(rx/subs! (fn [[users data]] (rx/subs!
(let [users (d/index-by :id users)] (fn [[users data]]
(resolve (file-version-proxy plugin-id file-id users @data)))) (let [users (d/index-by :id users)]
reject)))))))))) (st/emit! (se/event plugin-id "pin-version" :file-id file-id))
(resolve (file-version-proxy plugin-id file-id users @data))))
reject))))))))))
(defn file-proxy? [p] (defn file-proxy? [p]
(obj/type-of? p "FileProxy")) (obj/type-of? p "FileProxy"))
@ -220,7 +226,8 @@
:else :else
(let [page-id (uuid/next)] (let [page-id (uuid/next)]
(st/emit! (dw/create-page {:page-id page-id :file-id id})) (st/emit! (-> (dw/create-page {:page-id page-id :file-id id})
(se/add-event plugin-id)))
(page/page-proxy plugin-id id page-id)))) (page/page-proxy plugin-id id page-id))))
:export :export
@ -269,6 +276,7 @@
:response-type :buffer})))) :response-type :buffer}))))
(rx/take 1) (rx/take 1)
(rx/map #(js/Uint8Array. (:body %))) (rx/map #(js/Uint8Array. (:body %)))
(rx/tap #(st/emit! (se/event plugin-id "export-binary-files" :format format :type type)))
(rx/subs! resolve reject)))))))) (rx/subs! resolve reject))))))))
:findVersions :findVersions
(fn [criteria] (fn [criteria]
@ -315,7 +323,9 @@
(u/reject-not-valid reject :findVersions "Plugin doesn't have 'content:write' permission") (u/reject-not-valid reject :findVersions "Plugin doesn't have 'content:write' permission")
:else :else
(st/emit! (dwv/create-version-from-plugins id label resolve reject)))))] (st/emit!
(dwv/create-version-from-plugins id label resolve reject)
(se/event plugin-id "create-version" :file-id id)))))]
(-> (js/Promise.all #js [users-promise create-version-promise]) (-> (js/Promise.all #js [users-promise create-version-promise])
(.then (.then
(fn [[users data]] (fn [[users data]]

View File

@ -13,6 +13,7 @@
[app.main.data.workspace.shapes :as dwsh] [app.main.data.workspace.shapes :as dwsh]
[app.main.store :as st] [app.main.store :as st]
[app.plugins.register :as r] [app.plugins.register :as r]
[app.plugins.system-events :as se]
[app.plugins.utils :as u] [app.plugins.utils :as u]
[app.util.object :as obj])) [app.util.object :as obj]))
@ -186,7 +187,6 @@
:else :else
(st/emit! (dwsl/update-layout #{id} {:layout-padding {:p2 value :p4 value}}))))} (st/emit! (dwsl/update-layout #{id} {:layout-padding {:p2 value :p4 value}}))))}
:topPadding :topPadding
{:this true {:this true
:get #(-> % u/proxy->shape :layout-padding :p1 (d/nilv 0)) :get #(-> % u/proxy->shape :layout-padding :p1 (d/nilv 0))
@ -260,11 +260,16 @@
:else :else
(let [child-id (obj/get child "$id") (let [child-id (obj/get child "$id")
shape (u/locate-shape file-id page-id id) shape (u/locate-shape file-id page-id id)
child-shape (u/locate-shape file-id page-id child-id)
index index
(if (and (u/natural-child-ordering? plugin-id) (not (ctl/reverse? shape))) (if (and (u/natural-child-ordering? plugin-id) (not (ctl/reverse? shape)))
0 0
(count (:shapes shape)))] (count (:shapes shape)))]
(st/emit! (dwsh/relocate-shapes #{child-id} id index))))) (st/emit!
(dwsh/relocate-shapes #{child-id} id index)
(se/event plugin-id "add-layout-element"
:type (:type child-shape)
:parent-type (:type shape))))))
:horizontalSizing :horizontalSizing
{:this true {:this true

View File

@ -16,7 +16,6 @@
[app.common.types.file :as ctf] [app.common.types.file :as ctf]
[app.common.types.typography :as ctt] [app.common.types.typography :as ctt]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[app.main.data.event :as ev]
[app.main.data.plugins :as dp] [app.main.data.plugins :as dp]
[app.main.data.workspace.libraries :as dwl] [app.main.data.workspace.libraries :as dwl]
[app.main.data.workspace.texts :as dwt] [app.main.data.workspace.texts :as dwt]
@ -27,6 +26,7 @@
[app.plugins.parser :as parser] [app.plugins.parser :as parser]
[app.plugins.register :as r] [app.plugins.register :as r]
[app.plugins.shape :as shape] [app.plugins.shape :as shape]
[app.plugins.system-events :as se]
[app.plugins.text :as text] [app.plugins.text :as text]
[app.plugins.tokens :as tokens] [app.plugins.tokens :as tokens]
[app.plugins.utils :as u] [app.plugins.utils :as u]
@ -164,7 +164,8 @@
(u/not-valid plugin-id :remove "Plugin doesn't have 'library:write' permission") (u/not-valid plugin-id :remove "Plugin doesn't have 'library:write' permission")
:else :else
(st/emit! (dwl/delete-color {:id id})))) (st/emit! (-> (dwl/delete-color {:id id})
(se/add-event plugin-id)))))
:clone :clone
(fn [] (fn []
@ -176,7 +177,8 @@
(let [color-id (uuid/next) (let [color-id (uuid/next)
color (-> (u/locate-library-color file-id id) color (-> (u/locate-library-color file-id id)
(assoc :id color-id))] (assoc :id color-id))]
(st/emit! (dwl/add-color color {:rename? false})) (st/emit! (-> (dwl/add-color color {:rename? false})
(se/add-event plugin-id)))
(lib-color-proxy plugin-id id color-id)))) (lib-color-proxy plugin-id id color-id))))
:asFill :asFill
@ -309,7 +311,8 @@
:else :else
(let [typo (u/proxy->library-typography self) (let [typo (u/proxy->library-typography self)
value (dm/str (d/nilv (:path typo) "") " / " value)] value (dm/str (d/nilv (:path typo) "") " / " value)]
(st/emit! (dwl/rename-typography file-id id value)))))} (st/emit! (-> (dwl/rename-typography file-id id value)
(se/add-event plugin-id))))))}
:path :path
{:this true {:this true
@ -488,7 +491,8 @@
(u/not-valid plugin-id :remove "Plugin doesn't have 'library:write' permission") (u/not-valid plugin-id :remove "Plugin doesn't have 'library:write' permission")
:else :else
(st/emit! (dwl/delete-typography {:id id})))) (st/emit! (-> (dwl/delete-typography {:id id})
(se/add-event plugin-id)))))
:clone :clone
(fn [] (fn []
@ -500,7 +504,8 @@
(let [typo-id (uuid/next) (let [typo-id (uuid/next)
typo (-> (u/locate-library-typography file-id id) typo (-> (u/locate-library-typography file-id id)
(assoc :id typo-id))] (assoc :id typo-id))]
(st/emit! (dwl/add-typography typo false)) (st/emit! (-> (dwl/add-typography typo false)
(se/add-event plugin-id)))
(lib-typography-proxy plugin-id id typo-id)))) (lib-typography-proxy plugin-id id typo-id))))
:applyToText :applyToText
@ -662,13 +667,13 @@
:addVariant :addVariant
(fn [] (fn []
(st/emit! (st/emit!
(ev/event {::ev/name "add-new-variant" ::ev/origin "plugin:add-variant"}) (se/event plugin-id "add-new-variant")
(dwv/add-new-variant id))) (dwv/add-new-variant id)))
:addProperty :addProperty
(fn [] (fn []
(st/emit! (st/emit!
(ev/event {::ev/name "add-new-property" ::ev/origin "plugin:add-property"}) (se/event plugin-id "add-new-property")
(dwv/add-new-property id {:property-value "Value 1"}))) (dwv/add-new-property id {:property-value "Value 1"})))
:removeProperty :removeProperty
@ -676,7 +681,7 @@
(if (not (nat-int? pos)) (if (not (nat-int? pos))
(u/not-valid plugin-id :pos pos) (u/not-valid plugin-id :pos pos)
(st/emit! (st/emit!
(ev/event {::ev/name "remove-property" ::ev/origin "plugin:remove-property"}) (se/event plugin-id "remove-property")
(dwv/remove-property id pos)))) (dwv/remove-property id pos))))
:renameProperty :renameProperty
@ -759,7 +764,8 @@
:else :else
(let [id-ref (atom nil)] (let [id-ref (atom nil)]
(st/emit! (dwl/instantiate-component file-id id (gpt/point 0 0) {:id-ref id-ref :origin "plugin"})) (st/emit! (-> (dwl/instantiate-component file-id id (gpt/point 0 0) {:id-ref id-ref :origin "plugin"})
(se/add-event plugin-id)))
(shape/shape-proxy plugin-id @id-ref)))) (shape/shape-proxy plugin-id @id-ref))))
:getPluginData :getPluginData
@ -885,7 +891,7 @@
(when (and component (when (and component
(not (ctk/is-variant? component))) (not (ctk/is-variant? component)))
(st/emit! (st/emit!
(ev/event {::ev/name "transform-in-variant" ::ev/origin "plugin:transform-in-variant"}) (se/event plugin-id "transform-in-variant")
(dwv/transform-in-variant (:main-instance-id component)))))) (dwv/transform-in-variant (:main-instance-id component))))))
:addVariant :addVariant
@ -894,7 +900,7 @@
(when (and component (when (and component
(ctk/is-variant? component)) (ctk/is-variant? component))
(st/emit! (st/emit!
(ev/event {::ev/name "add-new-variant" ::ev/origin "plugin:add-variant-from-component"}) (se/event plugin-id "add-new-variant")
(dwv/add-new-variant (:main-instance-id component)))))) (dwv/add-new-variant (:main-instance-id component))))))
:setVariantProperty :setVariantProperty
@ -908,7 +914,7 @@
:else :else
(st/emit! (st/emit!
(ev/event {::ev/name "variant-edit-property-value" ::ev/origin "plugin:edit-property-value"}) (se/event plugin-id "variant-edit-property-value")
(dwv/update-property-value id pos value)))))) (dwv/update-property-value id pos value))))))
(defn library-proxy? [p] (defn library-proxy? [p]
@ -974,7 +980,8 @@
:else :else
(let [color-id (uuid/next)] (let [color-id (uuid/next)]
(st/emit! (dwl/add-color {:id color-id :name "Color" :color "#000000" :opacity 1} {:rename? false})) (st/emit! (-> (dwl/add-color {:id color-id :name "Color" :color "#000000" :opacity 1} {:rename? false})
(se/add-event plugin-id)))
(lib-color-proxy plugin-id file-id color-id)))) (lib-color-proxy plugin-id file-id color-id))))
:createTypography :createTypography
@ -985,7 +992,8 @@
:else :else
(let [typography-id (uuid/next)] (let [typography-id (uuid/next)]
(st/emit! (dwl/add-typography (ctt/make-typography {:id typography-id :name "Typography"}) false)) (st/emit! (-> (dwl/add-typography (ctt/make-typography {:id typography-id :name "Typography"}) false)
(se/add-event plugin-id)))
(lib-typography-proxy plugin-id file-id typography-id)))) (lib-typography-proxy plugin-id file-id typography-id))))
:createComponent :createComponent
@ -997,7 +1005,8 @@
:else :else
(let [id-ref (atom nil) (let [id-ref (atom nil)
ids (into #{} (map #(obj/get % "$id")) shapes)] ids (into #{} (map #(obj/get % "$id")) shapes)]
(st/emit! (dwl/add-component id-ref ids)) (st/emit! (-> (dwl/add-component id-ref ids)
(se/add-event plugin-id)))
(lib-component-proxy plugin-id file-id @id-ref)))) (lib-component-proxy plugin-id file-id @id-ref))))
;; Plugin data ;; Plugin data
@ -1127,4 +1136,5 @@
(rx/filter (ptk/type? ::dwl/attach-library-finished)) (rx/filter (ptk/type? ::dwl/attach-library-finished))
(rx/take 1) (rx/take 1)
(rx/subs! #(resolve (library-proxy plugin-id library-id)) reject)) (rx/subs! #(resolve (library-proxy plugin-id library-id)) reject))
(st/emit! (dwl/link-file-to-library file-id library-id)))))))))) (st/emit! (-> (dwl/link-file-to-library file-id library-id)
(se/add-event plugin-id)))))))))))

View File

@ -28,6 +28,7 @@
[app.plugins.register :as r] [app.plugins.register :as r]
[app.plugins.ruler-guides :as rg] [app.plugins.ruler-guides :as rg]
[app.plugins.shape :as shape] [app.plugins.shape :as shape]
[app.plugins.system-events :as se]
[app.plugins.utils :as u] [app.plugins.utils :as u]
[app.util.object :as obj] [app.util.object :as obj]
[beicon.v2.core :as rx] [beicon.v2.core :as rx]
@ -283,7 +284,9 @@
:else :else
(let [flow-id (uuid/next)] (let [flow-id (uuid/next)]
(st/emit! (dwi/add-flow flow-id id name (obj/get frame "$id"))) (st/emit!
(dwi/add-flow flow-id id name (obj/get frame "$id"))
(se/event plugin-id "add-flow"))
(flow-proxy plugin-id file-id id flow-id)))) (flow-proxy plugin-id file-id id flow-id))))
:removeFlow :removeFlow
@ -293,7 +296,9 @@
(u/not-valid plugin-id :removeFlow-flow flow) (u/not-valid plugin-id :removeFlow-flow flow)
:else :else
(st/emit! (dwi/remove-flow id (obj/get flow "$id"))))) (st/emit!
(dwi/remove-flow id (obj/get flow "$id"))
(se/event plugin-id "remove-flow"))))
:addRulerGuide :addRulerGuide
(fn [orientation value board] (fn [orientation value board]
@ -316,12 +321,13 @@
:else :else
(let [ruler-id (uuid/next)] (let [ruler-id (uuid/next)]
(st/emit! (st/emit!
(dwgu/update-guides (-> (dwgu/update-guides
(d/without-nils (d/without-nils
{:id ruler-id {:id ruler-id
:axis (parser/orientation->axis orientation) :axis (parser/orientation->axis orientation)
:position value :position value
:frame-id (when board (obj/get board "$id"))}))) :frame-id (when board (obj/get board "$id"))}))
(se/add-event plugin-id)))
(rg/ruler-guide-proxy plugin-id file-id id ruler-id))))) (rg/ruler-guide-proxy plugin-id file-id id ruler-id)))))
:removeRulerGuide :removeRulerGuide
@ -335,7 +341,8 @@
:else :else
(let [guide (u/proxy->ruler-guide value)] (let [guide (u/proxy->ruler-guide value)]
(st/emit! (dwgu/remove-guide guide))))) (st/emit! (-> (dwgu/remove-guide guide)
(se/add-event plugin-id))))))
:addCommentThread :addCommentThread
(fn [content position board] (fn [content position board]
@ -364,15 +371,15 @@
(js/Promise. (js/Promise.
(fn [resolve] (fn [resolve]
(st/emit! (st/emit!
(dc/create-thread-on-workspace (-> (dc/create-thread-on-workspace
{:file-id file-id {:file-id file-id
:page-id id :page-id id
:position (gpt/point position) :position (gpt/point position)
:content content} :content content}
(fn [data]
(fn [data] (resolve (pc/comment-thread-proxy plugin-id file-id id data)))
(resolve (pc/comment-thread-proxy plugin-id file-id id data))) false)
false)))))))) (se/add-event plugin-id)))))))))
:removeCommentThread :removeCommentThread
(fn [thread] (fn [thread]

View File

@ -135,3 +135,7 @@
(= plugin-id mcp-plugin-id) (= plugin-id mcp-plugin-id)
(let [{:keys [permissions]} (dm/get-in @registry [:data plugin-id])] (let [{:keys [permissions]} (dm/get-in @registry [:data plugin-id])]
(contains? permissions permission)))) (contains? permissions permission))))
(defn get-plugin-data
[state plugin-id]
(get-in state [:profile :props :plugins :data plugin-id]))

View File

@ -13,6 +13,7 @@
[app.main.store :as st] [app.main.store :as st]
[app.plugins.format :as format] [app.plugins.format :as format]
[app.plugins.register :as r] [app.plugins.register :as r]
[app.plugins.system-events :as se]
[app.plugins.utils :as u] [app.plugins.utils :as u]
[app.util.object :as obj])) [app.util.object :as obj]))
@ -55,7 +56,8 @@
:else :else
(let [board-id (when value (obj/get value "$id")) (let [board-id (when value (obj/get value "$id"))
guide (-> self u/proxy->ruler-guide)] guide (-> self u/proxy->ruler-guide)]
(st/emit! (dwgu/update-guides (assoc guide :frame-id board-id)))))))} (st/emit! (-> (dwgu/update-guides (assoc guide :frame-id board-id))
(se/add-event plugin-id)))))))}
:orientation :orientation
{:this true {:this true
@ -92,9 +94,11 @@
(+ board-pos value)) (+ board-pos value))
value)] value)]
(st/emit! (dwgu/update-guides (assoc guide :position position))))))} (st/emit! (-> (dwgu/update-guides (assoc guide :position position))
(se/add-event plugin-id))))))}
:remove :remove
(fn [] (fn []
(let [guide (u/locate-ruler-guide file-id page-id id)] (let [guide (u/locate-ruler-guide file-id page-id id)]
(st/emit! (dwgu/remove-guide guide)))))) (st/emit! (-> (dwgu/remove-guide guide)
(se/add-event plugin-id)))))))

View File

@ -53,6 +53,7 @@
[app.plugins.parser :as parser] [app.plugins.parser :as parser]
[app.plugins.register :as r] [app.plugins.register :as r]
[app.plugins.ruler-guides :as rg] [app.plugins.ruler-guides :as rg]
[app.plugins.system-events :as se]
[app.plugins.text :as text] [app.plugins.text :as text]
[app.plugins.tokens :refer [applied-tokens-plugin->applied-tokens token-attr-plugin->token-attr token-attr?]] [app.plugins.tokens :refer [applied-tokens-plugin->applied-tokens token-attr-plugin->token-attr token-attr?]]
[app.plugins.utils :as u] [app.plugins.utils :as u]
@ -785,10 +786,8 @@
(when (ctl/grid-layout-immediate-child-id? objects id) (when (ctl/grid-layout-immediate-child-id? objects id)
(grid/layout-cell-proxy plugin-id file-id page-id id))))} (grid/layout-cell-proxy plugin-id file-id page-id id))))}
;; Interactions ;; Interactions
:interactions :interactions
{:this true {:this true
:get :get
@ -962,12 +961,17 @@
:else :else
(let [child-id (obj/get child "$id") (let [child-id (obj/get child "$id")
child-shape (u/locate-shape file-id page-id child-id)
is-reversed? (ctl/flex-layout? shape) is-reversed? (ctl/flex-layout? shape)
index index
(if (or (not (u/natural-child-ordering? plugin-id)) is-reversed?) (if (or (not (u/natural-child-ordering? plugin-id)) is-reversed?)
0 0
(count (:shapes shape)))] (count (:shapes shape)))]
(st/emit! (dwsh/relocate-shapes #{child-id} id index)))))) (st/emit!
(dwsh/relocate-shapes #{child-id} id index)
(se/event plugin-id (if (ctl/any-layout? shape) "add-layout-element" "add-element")
:type (:type child-shape)
:parent-type (:type shape)))))))
:insertChild :insertChild
(fn [index child] (fn [index child]
@ -987,12 +991,17 @@
:else :else
(let [child-id (obj/get child "$id") (let [child-id (obj/get child "$id")
child-shape (u/locate-shape file-id page-id child-id)
is-reversed? (ctl/flex-layout? shape) is-reversed? (ctl/flex-layout? shape)
index index
(if (or (not (u/natural-child-ordering? plugin-id)) is-reversed?) (if (or (not (u/natural-child-ordering? plugin-id)) is-reversed?)
(- (count (:shapes shape)) index) (- (count (:shapes shape)) index)
index)] index)]
(st/emit! (dwsh/relocate-shapes #{child-id} id index)))))) (st/emit!
(dwsh/relocate-shapes #{child-id} id index)
(se/event plugin-id (if (ctl/any-layout? shape) "add-layout-element" "add-element")
:type (:type child-shape)
:parent-type (:type shape)))))))
;; Only for frames ;; Only for frames
:addFlexLayout :addFlexLayout
@ -1006,7 +1015,9 @@
(u/not-valid plugin-id :addFlexLayout "Plugin doesn't have 'content:write' permission") (u/not-valid plugin-id :addFlexLayout "Plugin doesn't have 'content:write' permission")
:else :else
(do (st/emit! (dwsl/create-layout-from-id id :flex :from-frame? true :calculate-params? false)) (do (st/emit!
(dwsl/create-layout-from-id id :flex :from-frame? true :calculate-params? false)
(se/event plugin-id "create-layout" :layout "flex"))
(flex/flex-layout-proxy plugin-id file-id page-id id))))) (flex/flex-layout-proxy plugin-id file-id page-id id)))))
:addGridLayout :addGridLayout
@ -1021,6 +1032,7 @@
:else :else
(do (st/emit! (dwsl/create-layout-from-id id :grid :from-frame? true :calculate-params? false)) (do (st/emit! (dwsl/create-layout-from-id id :grid :from-frame? true :calculate-params? false))
(se/event plugin-id "create-layout" :layout "grid")
(grid/grid-layout-proxy plugin-id file-id page-id id))))) (grid/grid-layout-proxy plugin-id file-id page-id id)))))
;; Make masks for groups ;; Make masks for groups
@ -1035,7 +1047,9 @@
(u/not-valid plugin-id :makeMask "Plugin doesn't have 'content:write' permission") (u/not-valid plugin-id :makeMask "Plugin doesn't have 'content:write' permission")
:else :else
(st/emit! (dwg/mask-group #{id}))))) (st/emit!
(dwg/mask-group #{id})
(se/event plugin-id "create-shape" :type "mask")))))
:removeMask :removeMask
(fn [] (fn []
@ -1224,8 +1238,10 @@
(rx/map :body)))) (rx/map :body))))
(rx/mapcat #(.arrayBuffer %)) (rx/mapcat #(.arrayBuffer %))
(rx/map #(js/Uint8Array. %)) (rx/map #(js/Uint8Array. %))
(rx/tap #(st/emit! (se/event plugin-id "export-shapes")))
(rx/subs! resolve reject)))))))) (rx/subs! resolve reject))))))))
;; Interactions ;; Interactions
:addInteraction :addInteraction
(fn [trigger action delay] (fn [trigger action delay]
@ -1238,7 +1254,9 @@
:else :else
(let [index (-> (u/locate-shape file-id page-id id) (:interactions []) count)] (let [index (-> (u/locate-shape file-id page-id id) (:interactions []) count)]
(st/emit! (dwi/add-interaction page-id id interaction)) (st/emit!
(dwi/add-interaction page-id id interaction)
(se/event plugin-id "add-interaction"))
(interaction-proxy plugin-id file-id page-id id index))))) (interaction-proxy plugin-id file-id page-id id index)))))
:removeInteraction :removeInteraction
@ -1248,7 +1266,9 @@
(u/not-valid plugin-id :removeInteraction interaction) (u/not-valid plugin-id :removeInteraction interaction)
:else :else
(st/emit! (dwi/remove-interaction {:id id} (obj/get interaction "$index"))))) (st/emit!
(dwi/remove-interaction {:id id} (obj/get interaction "$index"))
(se/event plugin-id "remove-interaction"))))
;; Ruler guides ;; Ruler guides
:addRulerGuide :addRulerGuide
@ -1275,11 +1295,12 @@
board-pos (get frame axis) board-pos (get frame axis)
position (+ board-pos value)] position (+ board-pos value)]
(st/emit! (st/emit!
(dwgu/update-guides (-> (dwgu/update-guides
{:id id {:id id
:axis axis :axis axis
:position position :position position
:frame-id id})) :frame-id id})
(se/add-event plugin-id)))
(rg/ruler-guide-proxy plugin-id file-id page-id id))))) (rg/ruler-guide-proxy plugin-id file-id page-id id)))))
:removeRulerGuide :removeRulerGuide
@ -1293,7 +1314,8 @@
:else :else
(let [guide (u/proxy->ruler-guide value)] (let [guide (u/proxy->ruler-guide value)]
(st/emit! (dwgu/remove-guide guide))))) (st/emit! (-> (dwgu/remove-guide guide)
(se/add-event plugin-id))))))
:tokens :tokens
{:this true {:this true
@ -1320,10 +1342,11 @@
(if (some #(not (token-attr? %)) kw-attrs) (if (some #(not (token-attr? %)) kw-attrs)
(u/not-valid plugin-id :applyToken attrs) (u/not-valid plugin-id :applyToken attrs)
(st/emit! (st/emit!
(dwta/toggle-token {:token token (-> (dwta/toggle-token {:token token
:attrs kw-attrs :attrs kw-attrs
:shape-ids [id] :shape-ids [id]
:expand-with-children false})))))} :expand-with-children false})
(se/add-event plugin-id))))))}
:isVariantHead :isVariantHead
(fn [] (fn []
@ -1349,7 +1372,8 @@
(let [shape (u/locate-shape file-id page-id id) (let [shape (u/locate-shape file-id page-id id)
component (u/locate-library-component file-id (:component-id shape))] component (u/locate-library-component file-id (:component-id shape))]
(when (and component (ctk/is-variant? component)) (when (and component (ctk/is-variant? component))
(st/emit! (dwv/variants-switch {:shapes [shape] :pos pos :val value})))))) (st/emit! (-> (dwv/variants-switch {:shapes [shape] :pos pos :val value})
(se/add-event plugin-id)))))))
:combineAsVariants :combineAsVariants
(fn [ids] (fn [ids]
@ -1371,9 +1395,10 @@
(if valid? (if valid?
(let [variant-id (uuid/next)] (let [variant-id (uuid/next)]
(st/emit! (dwv/combine-as-variants (st/emit! (-> (dwv/combine-as-variants
ids ids
{:trigger "plugin:combine-as-variants" :variant-id variant-id})) {:trigger "plugin:combine-as-variants" :variant-id variant-id})
(se/add-event plugin-id)))
(shape-proxy plugin-id variant-id)) (shape-proxy plugin-id variant-id))
(u/not-valid plugin-id :ids "One of the components is not on the same page or is already a variant")))))) (u/not-valid plugin-id :ids "One of the components is not on the same page or is already a variant"))))))

View File

@ -7,17 +7,34 @@
(ns app.plugins.system-events (ns app.plugins.system-events
(:require (:require
[app.main.data.event :as ev] [app.main.data.event :as ev]
[app.main.store :as st])) [app.main.store :as st]
[app.plugins.register :as r]))
;; Formats an event from the plugin system ;; Formats an event from the plugin system
(defn event (defn event
[plugin-id name & {:as props}] [plugin-id name & {:as props}]
(let [plugin-data (get-in @st/state [:profile :props :plugins :data plugin-id])] (if (= plugin-id r/mcp-plugin-id)
(-> props (-> props
(assoc ::ev/name name) (assoc ::ev/name name)
(assoc ::ev/origin "plugin") (assoc ::ev/origin "mcp")
(assoc ::ev/context (ev/event))
{:plugin-name (:name plugin-data)
:plugin-url (:url plugin-data)})
(ev/event))))
(let [plugin-data (r/get-plugin-data @st/state plugin-id)]
(-> props
(assoc ::ev/name name)
(assoc ::ev/origin "plugin")
(assoc ::ev/context
{:plugin-name (:name plugin-data)
:plugin-url (:url plugin-data)})
(ev/event)))))
(defn add-event
[event plugin-id]
(let [plugin-data (r/get-plugin-data @st/state plugin-id)]
(with-meta
event
(if (= plugin-id r/mcp-plugin-id)
{::ev/origin "mcp"}
{::ev/origin "plugin"
::ev/context {:plugin-name (:name plugin-data)
:plugin-url (:url plugin-data)}}))))

View File

@ -17,6 +17,7 @@
[app.main.data.workspace.tokens.application :as dwta] [app.main.data.workspace.tokens.application :as dwta]
[app.main.data.workspace.tokens.library-edit :as dwtl] [app.main.data.workspace.tokens.library-edit :as dwtl]
[app.main.store :as st] [app.main.store :as st]
[app.plugins.system-events :as se]
[app.plugins.utils :as u] [app.plugins.utils :as u]
[app.util.object :as obj] [app.util.object :as obj]
[clojure.datafy :refer [datafy]] [clojure.datafy :refer [datafy]]
@ -80,10 +81,11 @@
(if (some #(not (token-attr? %)) attrs) (if (some #(not (token-attr? %)) attrs)
(u/not-valid plugin-id :applyToSelected attrs) (u/not-valid plugin-id :applyToSelected attrs)
(st/emit! (st/emit!
(dwta/toggle-token {:token token (-> (dwta/toggle-token {:token token
:attrs (into #{} (map token-attr-plugin->token-attr) attrs) :attrs (into #{} (map token-attr-plugin->token-attr) attrs)
:shape-ids shape-ids :shape-ids shape-ids
:expand-with-children false}))))) :expand-with-children false})
(se/add-event plugin-id))))))
(defn- get-resolved-value (defn- get-resolved-value
[token tokens-tree] [token tokens-tree]
@ -123,7 +125,8 @@
(ctob/get-tokens set-id))) (ctob/get-tokens set-id)))
:set :set
(fn [_ value] (fn [_ value]
(st/emit! (dwtl/update-token set-id id {:name value})))} (st/emit! (-> (dwtl/update-token set-id id {:name value})
(se/add-event plugin-id))))}
:type :type
{:this true {:this true
@ -173,7 +176,8 @@
:schema cfo/schema:token-description :schema cfo/schema:token-description
:set :set
(fn [_ value] (fn [_ value]
(st/emit! (dwtl/update-token set-id id {:description value})))} (st/emit! (-> (dwtl/update-token set-id id {:description value})
(se/add-event :plugin-id))))}
:duplicate :duplicate
(fn [] (fn []
@ -186,12 +190,14 @@
token' (ctob/make-token (-> (datafy token) token' (ctob/make-token (-> (datafy token)
(dissoc :id (dissoc :id
:modified-at)))] :modified-at)))]
(st/emit! (dwtl/create-token set-id token')) (st/emit! (-> (dwtl/create-token set-id token')
(se/add-event plugin-id)))
(token-proxy plugin-id file-id set-id (:id token')))) (token-proxy plugin-id file-id set-id (:id token'))))
:remove :remove
(fn [] (fn []
(st/emit! (dwtl/delete-token set-id id))) (st/emit! (-> (dwtl/delete-token set-id id)
(se/add-event plugin-id))))
:applyToShapes :applyToShapes
{:enumerable false {:enumerable false
@ -323,7 +329,8 @@
(get resolved-tokens (:name token))] (get resolved-tokens (:name token))]
(if resolved-value (if resolved-value
(do (st/emit! (dwtl/create-token id token)) (do (st/emit! (-> (dwtl/create-token id token)
(se/add-event plugin-id)))
(token-proxy plugin-id file-id id (:id token))) (token-proxy plugin-id file-id id (:id token)))
(do (u/not-valid plugin-id :addToken (str errors)) (do (u/not-valid plugin-id :addToken (str errors))
nil))))} nil))))}