penpot/frontend/src/app/plugins/system_events.cljs
alonso.torres 1a9c7f9486 Plugin events
2026-04-23 11:24:26 +02:00

33 lines
1.0 KiB
Clojure

;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) KALEIDOS INC
(ns app.plugins.system-events
(:require
[app.main.data.event :as ev]
[app.main.store :as st]))
;; Formats an event from the plugin system
(defn event
[plugin-id name & {:as props}]
(let [plugin-data (get-in @st/state [:profile :props :plugins :data 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 (get-in @st/state [:profile :props :plugins :data plugin-id])]
(with-meta
event
{::ev/origin "plugin"
::ev/context {:plugin-name (:name plugin-data)
:plugin-url (:url plugin-data)}})))