diff --git a/libs/plugin-types/index.d.ts b/libs/plugin-types/index.d.ts index cb1e32d..da771ae 100644 --- a/libs/plugin-types/index.d.ts +++ b/libs/plugin-types/index.d.ts @@ -2221,6 +2221,18 @@ export interface PenpotContext { */ uploadMediaUrl(name: string, url: string): Promise; + /** + * Uploads media to penpot and retrieves the image data + * @param name The name of the media. + * @param data The image content data + * Returns a promise that resolves to the image data of the uploaded media. + */ + uploadMediaData( + name: string, + data: Uint8Array, + mimeType: string + ): Promise; + // Methods for creating shapes and components group(shapes: PenpotShape[]): PenpotGroup; ungroup(group: PenpotGroup, ...other: PenpotGroup[]): void; diff --git a/libs/plugins-runtime/src/lib/api/index.ts b/libs/plugins-runtime/src/lib/api/index.ts index 895b4c9..a534a68 100644 --- a/libs/plugins-runtime/src/lib/api/index.ts +++ b/libs/plugins-runtime/src/lib/api/index.ts @@ -308,6 +308,10 @@ export function createApi(context: PenpotContext, manifest: Manifest): Penpot { uploadMediaUrl(name: string, url: string) { return context.uploadMediaUrl(name, url); }, + + uploadMediaData(name: string, data: Uint8Array, mimeType: string) { + return context.uploadMediaData(name, data, mimeType); + }, }; return penpot;