Weave.js

WeaveImageToolAction

Add an image to the canvas

Overview

The WeaveImageToolAction class that enables users to insert image nodes into the canvas. It provides an intuitive way to add visual content—either by selecting an image file, dragging and dropping, or integrating with an image picker—allowing users to enhance their collaborative workspace with rich media.

Each interaction results in the creation of a WeaveImageNode, which can be resized, moved, and synchronized across all connected users.

The class extends the WeaveAction class.

Name

This action name property value is imageTool.

Import

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

Instantiation

new WeaveImageToolAction();

TypeScript types

type WeaveImageToolActionOnStartLoadImageEvent = undefined;
type WeaveImageToolActionOnEndLoadImageEvent = Error | undefined;

type WeaveImageToolActionTriggerParams = {
  imageURL?: string;
};

type WeaveImageToolActionTriggerReturn =
  | {
      finishUploadCallback: (imageURL: string) => void;
    }
  | undefined;

Trigger function params

trigger(cancelAction: () => void, params?: WeaveImageToolActionTriggerParams): void;

For WeaveImageToolActionTriggerParams:

PropTypeDefault
imageURL?
string
-

Events

onImageLoadStart

onImageLoadStart: WeaveNodesSelectionPluginOnNodesChangeEvent;

The onImageLoadStart event is called when the image is stated to load onto the canvas.

onImageLoadEnd

onImageLoadEnd: WeaveNodesSelectionPluginOnNodesChangeEvent;

The onImageLoadEnd event is called when the image ended loading into the canvas.