From a4ad94017736a1853e58d06527925d2c37767f62 Mon Sep 17 00:00:00 2001 From: Alonso Torres Date: Wed, 18 Mar 2026 16:03:17 +0100 Subject: [PATCH] :sparkles: Add version property to plugins API (#8676) --- frontend/src/app/plugins/api.cljs | 5 +++++ plugins/CHANGELOG.md | 5 +++++ plugins/libs/plugin-types/index.d.ts | 5 +++++ plugins/libs/plugins-runtime/src/lib/api/index.ts | 4 ++++ 4 files changed, 19 insertions(+) diff --git a/frontend/src/app/plugins/api.cljs b/frontend/src/app/plugins/api.cljs index 4c982db774..59bd81caae 100644 --- a/frontend/src/app/plugins/api.cljs +++ b/frontend/src/app/plugins/api.cljs @@ -18,6 +18,7 @@ [app.common.types.shape :as cts] [app.common.types.text :as txt] [app.common.uuid :as uuid] + [app.config :as cf] [app.main.data.changes :as ch] [app.main.data.common :as dcm] [app.main.data.helpers :as dsh] @@ -84,6 +85,10 @@ :$plugin {:enumerable false :get (fn [] plugin-id)} ;; Public properties + :version + {:this true + :get (constantly (:base cf/version))} + :root {:this true :get #(.getRoot ^js %)} diff --git a/plugins/CHANGELOG.md b/plugins/CHANGELOG.md index a5d5faff84..4ba7745a4f 100644 --- a/plugins/CHANGELOG.md +++ b/plugins/CHANGELOG.md @@ -1,6 +1,11 @@ ## 1.5.0 (Unreleased) - **plugin-types**: Added a flags subcontexts with the flag `naturalChildrenOrdering` +- **plugins-runtime**: Added `version` field that returns the current version +- **plugin-types**: Fix penpot.openPage() to navigate in same tab by default +- **plugin-types**: Added `createVariantFromComponents` +- **plugin-types**: Change return type of `combineAsVariants` +- **plugin-types**: Added `textBounds` property for text shapes ## 1.4.2 (2026-01-21) diff --git a/plugins/libs/plugin-types/index.d.ts b/plugins/libs/plugin-types/index.d.ts index 84cff58440..91dbb38b84 100644 --- a/plugins/libs/plugin-types/index.d.ts +++ b/plugins/libs/plugin-types/index.d.ts @@ -768,6 +768,11 @@ export interface CommonLayout { * Represents the context of Penpot, providing access to various Penpot functionalities and data. */ export interface Context { + /** + * Returns the current penpot version. + */ + readonly version: string; + /** * The root shape in the current Penpot context. Requires `content:read` permission. * diff --git a/plugins/libs/plugins-runtime/src/lib/api/index.ts b/plugins/libs/plugins-runtime/src/lib/api/index.ts index 2f8e9e58d9..00d64e58ed 100644 --- a/plugins/libs/plugins-runtime/src/lib/api/index.ts +++ b/plugins/libs/plugins-runtime/src/lib/api/index.ts @@ -165,6 +165,10 @@ export function createApi( // Penpot State API + get version(): string { + return plugin.context.version; + }, + get root(): Shape | null { checkPermission('content:read'); return plugin.context.root;