Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(plugins-runtime): add upload svg with images #190

Merged
merged 1 commit into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions libs/plugin-types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions libs/plugins-runtime/src/lib/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down