Add version property to plugins API (#8676)

This commit is contained in:
Alonso Torres
2026-03-18 16:03:17 +01:00
committed by GitHub
parent 1b91bbe64d
commit a4ad940177
4 changed files with 19 additions and 0 deletions

View File

@@ -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 %)}

View File

@@ -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)

View File

@@ -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.
*

View File

@@ -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;