From 9a9b33a8fe5bf6daeaab2108dab476cfa7991e91 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 23 Jul 2024 13:31:41 +0200 Subject: [PATCH] feat(plugins-runtime): add method for pages --- libs/plugin-types/index.d.ts | 2 +- libs/plugins-runtime/src/lib/api/index.ts | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/libs/plugin-types/index.d.ts b/libs/plugin-types/index.d.ts index f0dce08..72975cd 100644 --- a/libs/plugin-types/index.d.ts +++ b/libs/plugin-types/index.d.ts @@ -207,7 +207,7 @@ export interface PenpotFile extends PenpotPluginData { * - `'penpot'` will create a *.penpot file with a binary representation of the file * - `'zip'` will create a *.zip with the file exported in several SVG files with some JSON metadata */ - export(exportType: 'penpot' | 'zip'): Uint8Array; + export(exportType: 'penpot' | 'zip'): Promise; } /** diff --git a/libs/plugins-runtime/src/lib/api/index.ts b/libs/plugins-runtime/src/lib/api/index.ts index dbb9c6c..847d7da 100644 --- a/libs/plugins-runtime/src/lib/api/index.ts +++ b/libs/plugins-runtime/src/lib/api/index.ts @@ -368,6 +368,21 @@ export function createApi(context: PenpotContext, manifest: Manifest): Penpot { checkPermission('content:read'); return context.generateStyle(shapes, options); }, + + openViewer(): void { + checkPermission('content:read'); + context.openViewer(); + }, + + createPage(): PenpotPage { + checkPermission('content:write'); + return context.createPage(); + }, + + openPage(page: PenpotPage): void { + checkPermission('content:read'); + context.openPage(page); + }, }; return penpot;