Overview
The WeaveCommentToolAction class that allows users to create comments on a particular position (x,y) of the stage.
The class extends the WeaveAction class.
TypeScript types
type WeaveCommentToolActionStateKeys = keyof typeof WEAVE_COMMENT_TOOL_STATE;
type WeaveCommentToolActionState =
(typeof WEAVE_COMMENT_TOOL_STATE)[WeaveCommentToolActionStateKeys];
type WeaveCommentToolStyle = {
cursor: {
add: string;
block: string;
};
};
type WeaveCommentToolModel<T> = {
getCreateModel: () => DeepPartial<T>;
};
type WeaveCommentToolActionConfig<T> = {
style: WeaveCommentToolStyle;
getUser: () => WeaveUser;
getUserBackgroundColor: (
user: WeaveUser
) => string | CanvasGradient | undefined;
getUserForegroundColor: (
user: WeaveUser
) => string | CanvasGradient | undefined;
model: WeaveCommentToolModel<T>;
};
type WeaveCommentToolActionParams<T> = {
config: Pick<
WeaveCommentToolActionConfig<T>,
"model" | "getUser" | "getUserBackgroundColor" | "getUserForegroundColor"
> &
DeepPartial<Pick<WeaveCommentToolActionConfig<T>, "style">>;
};
Constants
const WEAVE_COMMENT_TOOL_ACTION_NAME = "commentTool";
const WEAVE_COMMENT_TOOL_LAYER_NAME = "commentsLayer";
const WEAVE_COMMENT_TOOL_STATE = {
["IDLE"]: "idle",
["ADDING"]: "adding",
["SELECTED_POSITION"]: "selectedPosition",
["CREATING_COMMENT"]: "creatingComment",
["ADDED"]: "added",
} as const;
Parameters
For WeaveBrushToolActionParams:
| Property | Type | Required | Description |
|---|---|---|---|
|
|
Required |
Config parameters for the tool. |
For Pick<WeaveCommentToolActionConfig<T>, 'model' | 'getUser' | 'getUserBackgroundColor' | 'getUserForegroundColor'> & DeepPartial<Pick<WeaveCommentToolActionConfig<T>, 'style'>>:
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
|
|
|
Defines the tool style properties. |
|
|
|
Required |
Setup the Entity model |
|
|
|
Required |
A function that return the actual user model |
|
|
|
Required |
A function that is called to define a user background color base on its model. |
|
|
|
Required |
A function that is called to define a user foreground color base on its model. |