Weave.js

WeaveExportStageToolAction

Tool to export the stage as an image

Overview

The WeaveExportStageToolAction class that enables users to export the entire canvas (Stage) as an image file—typically in PNG format. This action captures everything visible on the canvas, including all nodes, layers, and plugin-rendered visuals, and converts it into a high-fidelity static image.

It’s particularly useful for sharing snapshots, archiving work, or generating thumbnails from collaborative visual tools.

The class extends the WeaveAction class.

Name

This action name property value is exportStageTool.

Import

import { WeaveExportStageToolAction } from "@inditextech/weave-sdk";

Instantiation

new WeaveExportStageToolAction();

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 WeaveExportStageActionParams = {
  boundingNodes?: (nodes: Konva.Node[]) => Konva.Node[];
  options?: WeaveExportNodesOptions;
};

Trigger function params

trigger(cancelAction: () => void, params?: WeaveExportStageActionParams): Promise<void>;

For WeaveExportStageActionParams:

Property Type Required Description

boundingNodes

(nodes: Konva.Node[]) ⇒ Konva.Node[]

A function that defines the bounding node

options

WeaveExportNodeOptions

The exported image options.

For WeaveExportNodeOptions:

Property Type Required Default Description

format

WeaveExportFormat

Required

WEAVE_EXPORT_FORMATS.PNG

The format of the image to export.

padding

number

0

The padding to add to the image to export. In pixels.

pixelRatio

number

1

The pixel ratio to use on the image to export. For example 2 on a image of 400x400 generates a image of 800x800 pixels.

backgroundColor

string

#FFFFFF

The background color to use on the image to export. Is a CCS color value.

quality

number

1

The quality of the image to export. From 0 to 1.