mirror of
https://github.com/penpot/penpot-plugins.git
synced 2025-02-08 08:09:18 -05:00
feat(plugins-runtime): add upload svg with images
This commit is contained in:
parent
9a3e6e049b
commit
df925b5a1b
2 changed files with 19 additions and 0 deletions
14
libs/plugin-types/index.d.ts
vendored
14
libs/plugin-types/index.d.ts
vendored
|
@ -1069,6 +1069,20 @@ export interface Context {
|
|||
* ```
|
||||
*/
|
||||
createShapeFromSvg(svgString: string): Group | null;
|
||||
/**
|
||||
* Creates a Group from an SVG string. The SVG can have images and the method returns
|
||||
* a Promise because the shape will be available after all images are uploaded.
|
||||
* Requires `content:write` permission.
|
||||
* @param svgString The SVG string representing the shapes to be converted into a group.
|
||||
* @return Returns a promise with the newly created Group containing the shapes from the SVG.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* const svgGroup = await context.createShapeFromSvgWithImages('<svg>...</svg>');
|
||||
* ```
|
||||
*/
|
||||
createShapeFromSvgWithImages(svgString: string): Promise<Group | null>;
|
||||
|
||||
/**
|
||||
* Creates a Text shape with the specified text content. Requires `content:write` permission.
|
||||
* @param text The text content for the Text shape.
|
||||
|
|
|
@ -240,6 +240,11 @@ export function createApi(
|
|||
return plugin.context.createShapeFromSvg(svgString);
|
||||
},
|
||||
|
||||
createShapeFromSvgWithImages(svgString: string): Promise<Group | null> {
|
||||
checkPermission('content:write');
|
||||
return plugin.context.createShapeFromSvgWithImages(svgString);
|
||||
},
|
||||
|
||||
group(shapes: Shape[]): Group | null {
|
||||
checkPermission('content:write');
|
||||
return plugin.context.group(shapes);
|
||||
|
|
Loading…
Add table
Reference in a new issue