mirror of
https://github.com/penpot/penpot-plugins.git
synced 2025-01-23 07:08:47 -05:00
feat(plugins-runtime): add support to upload images from data
This commit is contained in:
parent
452e60cb74
commit
7ce2cae2b9
2 changed files with 16 additions and 0 deletions
12
libs/plugin-types/index.d.ts
vendored
12
libs/plugin-types/index.d.ts
vendored
|
@ -2221,6 +2221,18 @@ export interface PenpotContext {
|
||||||
*/
|
*/
|
||||||
uploadMediaUrl(name: string, url: string): Promise<PenpotImageData>;
|
uploadMediaUrl(name: string, url: string): Promise<PenpotImageData>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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<PenpotImageData>;
|
||||||
|
|
||||||
// Methods for creating shapes and components
|
// Methods for creating shapes and components
|
||||||
group(shapes: PenpotShape[]): PenpotGroup;
|
group(shapes: PenpotShape[]): PenpotGroup;
|
||||||
ungroup(group: PenpotGroup, ...other: PenpotGroup[]): void;
|
ungroup(group: PenpotGroup, ...other: PenpotGroup[]): void;
|
||||||
|
|
|
@ -308,6 +308,10 @@ export function createApi(context: PenpotContext, manifest: Manifest): Penpot {
|
||||||
uploadMediaUrl(name: string, url: string) {
|
uploadMediaUrl(name: string, url: string) {
|
||||||
return context.uploadMediaUrl(name, url);
|
return context.uploadMediaUrl(name, url);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
uploadMediaData(name: string, data: Uint8Array, mimeType: string) {
|
||||||
|
return context.uploadMediaData(name, data, mimeType);
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
return penpot;
|
return penpot;
|
||||||
|
|
Loading…
Add table
Reference in a new issue