Overview
The WeaveConnectorToolAction class allows users to add connector to the canvas by click-and-click onto pre-defined anchors on the canvas elements.
The class extends the WeaveAction class.
TypeScript types
type WeaveConnectorToolActionStateKeys = keyof typeof CONNECTOR_TOOL_STATE;
type WeaveConnectorToolActionState =
(typeof CONNECTOR_TOOL_STATE)[WeaveConnectorToolActionStateKeys];
type WeaveConnectorToolActionProperties = {
style: {
anchor: {
radius: number;
stroke: string;
strokeWidth: number;
fill: string;
selectedFill: string;
hoveredFill: string;
};
line: {
stroke: string;
strokeWidth: number;
dash: number[];
};
};
};
type WeaveConnectorToolActionParams = {
config: DeepPartial<WeaveConnectorToolActionProperties>;
};
Parameters
For WeaveConnectorToolActionParams:
| Property | Type | Required | Description |
|---|---|---|---|
|
|
Required |
Config parameters for the tool. |
For WeaveConnectorToolActionProperties:
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
|
|
|
The anchor radius |
|
|
|
|
The anchor border color |
|
|
|
|
The anchor border size (px) |
|
|
|
|
The anchor fill color |
|
|
|
|
The anchor fill color when selected |
|
|
|
|
The anchor fill color when hovered |
|
|
|
|
The temporary connecting line when selecting the end anchor, this defines the border color |
|
|
|
|
The temporary connecting line border size |
|
|
|
|
The temporary connecting line dash pattern |
Default values
const CONNECTOR_TOOL_ACTION_NAME = "connectorTool";
const CONNECTOR_TOOL_STATE = {
["IDLE"]: "idle",
["SELECTING_INITIAL"]: "selecting_initial",
["SELECTING_FINAL"]: "selecting_final",
["ADDED"]: "added",
} as const;
const CONNECTOR_TOOL_DEFAULT_CONFIG: WeaveConnectorToolActionProperties = {
style: {
anchor: {
radius: 7,
stroke: "#000000",
strokeWidth: 1,
fill: "#FFFFFF",
selectedFill: "#1a1aff",
hoveredFill: "#ff2c2c",
},
line: {
stroke: "#000000",
strokeWidth: 1,
dash: [],
},
},
};