WeaveExportNodeToolAction
Export the selected node as an image
Overview
The WeaveExportNodeToolAction class that allows users to export a specific node or group of nodes from the canvas as a standalone image file (e.g., PNG or JPEG). This action is especially useful when users want to extract visual components from the canvas for sharing, documentation, thumbnails, or reuse outside the app.
It works by rendering the selected node(s) to an off-screen canvas, preserving their current visual appearance, and triggering a downloadable export.
The class extends the WeaveAction class.
Name
This action name
property value is exportNodeTool
.
Import
import { WeaveExportNodeToolAction } from "@inditextech/weave-sdk";
Instantiation
new WeaveExportNodeToolAction();
TypeScript types
const WEAVE_EXPORT_FORMATS: {
readonly PNG: "image/png";
readonly JPEG: "image/jpeg";
};
type WeaveExportNodeOptions = {
format?: typeof WEAVE_EXPORT_FORMATS.PNG;
padding?: number;
pixelRatio?: number;
backgroundColor?: string;
quality?: number;
};
type WeaveExportNodeActionParams = {
node: WeaveElementInstance;
options?: WeaveExportNodeOptions;
};
Trigger function params
trigger(cancelAction: () => void, params?: WeaveExportNodeActionParams): Promise<void>;
For WeaveExportNodeActionParams
:
Prop | Type | Default |
---|---|---|
options? | WeaveExportNodeOptions | - |
node | WeaveElementInstance | - |
For WeaveExportNodeOptions
:
Prop | Type | Default |
---|---|---|
quality? | number | 1 |
backgroundColor? | string | #FFFFFF |
pixelRatio? | number | 1 |
padding? | number | 0 |
format | WeaveExportFormat | WEAVE_EXPORT_FORMATS.PNG |