diff --git a/docs/plugin-usage.md b/docs/plugin-usage.md index b9f66db..dc9711c 100644 --- a/docs/plugin-usage.md +++ b/docs/plugin-usage.md @@ -63,3 +63,11 @@ penpot.on('pagechange', event); penpot.off('pagechange', event); ``` + +### Requests + +Same as the browser fetch API. + +```ts +penpot.fetch('http://example.com/movies.json'); +``` diff --git a/libs/plugins-runtime/src/lib/api/index.ts b/libs/plugins-runtime/src/lib/api/index.ts index 4823c0b..81f57e3 100644 --- a/libs/plugins-runtime/src/lib/api/index.ts +++ b/libs/plugins-runtime/src/lib/api/index.ts @@ -152,6 +152,7 @@ export function createApi(manifest: Manifest) { return selection; }, + fetch, } as const; return penpot; diff --git a/libs/plugins-runtime/src/lib/index.d.ts b/libs/plugins-runtime/src/lib/index.d.ts index ec38ba4..e2e0a3f 100644 --- a/libs/plugins-runtime/src/lib/index.d.ts +++ b/libs/plugins-runtime/src/lib/index.d.ts @@ -40,7 +40,8 @@ interface Penpot { ) => void; getFileState: () => File; getPageState: () => Page; - getSelection: () => any; + getSelection: () => string | null; + fetch: typeof fetch; } declare namespace globalThis {