rete-comment-plugin packageA union of all possible signals that can be emitted by the comment plugin
type Produces =
| { data: Comment; type: "commentcreated" }
| { data: Comment; type: "commentremoved" }
| { data: Comment; type: "editcomment" }
| { data: Comment; type: "commentselected" }
| { data: Comment; type: "commentunselected" }
| { data: Object; type: "commenttranslated" }
| { data: Object; type: "commentlinktranslate" };
A plugin that provides comments for nodes
class CommentPlugin<Schemes extends ExpectedSchemes, K extends unknown>
| Parameter | Extends | Description |
|---|---|---|
| Schemes | ExpectedSchemes | |
| K | unknown |
Extends Scope<Produces, BaseArea
constructor(props: Props): CommentPlugin<Schemes, K>
| Parameter | Type | Description |
|---|---|---|
| props | Props | Optional comment plugin properties |
Returns CommentPlugin<Schemes, K>
Adds a frame comment. Represents a rectangle with a text and nodes linked to it. When user translates a comment, all linked nodes will be translated as well. When user drops a node on a comment, the node will be linked to the comment.
addFrame(text: string, links: string[]): void
| Parameter | Type | Description |
|---|---|---|
| text | string | Comment text |
| links | string[] | List of node IDs the comment is linked with |
Returns void
Adds an inline comment which is represented by a block with text at certain position, which is attached to the node. When user translates a node, the comment will be translated as well. When user drops a comment on a node, the comment will be linked to the node.
addInline(text: string, position: [number, number], link: string): void
| Parameter | Type | Description |
|---|---|---|
| text | string | Comment text |
| position | [number, number] | Comment position |
| link | string | Node ID the comment is linked with |
Returns void
Removes all comments
clear(): void
Returns void
Removes a comment
delete(id: string): void
| Parameter | Type | Description |
|---|---|---|
| id | string | Comment id |
Returns void
Trigger edit form for a comment
editComment(id: string): Promise<void>
| Parameter | Type | Description |
|---|---|---|
| id | string | Comment id |
Returns Promise<void>
Selects a comment
select(id: string): void
| Parameter | Type | Description |
|---|---|---|
| id | string | Comment id |
Returns void
Translates a comment
translate(id: string, dx: number, dy: number): void
| Parameter | Type | Description |
|---|---|---|
| id | string | Comment id |
| dx | number | Delta x |
| dy | number | Delta y |
Returns void
Unselects a comment
unselect(id: string): void
| Parameter | Type | Description |
|---|---|---|
| id | string | Comment id |
Returns void
Comment plugin extensions
Enables synchronization between comments and the selector
selectable(plugin: CommentPlugin<S, K>, selector: Selector<SelectorEntity>, accumulating: { active: unknown }): void
| Parameter | Type | Description |
|---|---|---|
| plugin | CommentPlugin<S, K> | Comment plugin instance |
| selector | Selector<SelectorEntity> | Selector instance |
| accumulating | { active: unknown } | Accumulating state |
Returns void
Comment plugin properties
type Props = { edit: Function };