API for rete-comment-plugin package - Rete.js

API for rete-comment-plugin package

Produces

index.ts

A union of all possible signals that can be emitted by the comment plugin

ts
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" };

CommentPlugin

index.ts

A plugin that provides comments for nodes

ts
class CommentPlugin<Schemes extends ExpectedSchemes, K extends unknown>
ParameterExtendsDescription
SchemesExpectedSchemes
Kunknown

Extends Scope<Produces, BaseArea | K>

constructor

index.ts

ts
constructor(props: Props): CommentPlugin<Schemes, K>
ParameterTypeDescription
propsPropsOptional comment plugin properties

Returns CommentPlugin<Schemes, K>

addFrame

index.ts

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.

ts
addFrame(text: string, links: string[]): void
ParameterTypeDescription
textstringComment text
linksstring[]List of node IDs the comment is linked with

Returns void

addInline

index.ts

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.

ts
addInline(text: string, position: [number, number], link: string): void
ParameterTypeDescription
textstringComment text
position[number, number]Comment position
linkstringNode ID the comment is linked with

Returns void

clear

index.ts

Removes all comments

ts
clear(): void

Returns void

delete

index.ts

Removes a comment

ts
delete(id: string): void
ParameterTypeDescription
idstringComment id

Returns void

editComment

index.ts

Trigger edit form for a comment

ts
editComment(id: string): Promise<void>
ParameterTypeDescription
idstringComment id

Returns Promise<void>

select

index.ts

Selects a comment

ts
select(id: string): void
ParameterTypeDescription
idstringComment id

Returns void

translate

index.ts

Translates a comment

ts
translate(id: string, dx: number, dy: number): void
ParameterTypeDescription
idstringComment id
dxnumberDelta x
dynumberDelta y

Returns void

unselect

index.ts

Unselects a comment

ts
unselect(id: string): void
ParameterTypeDescription
idstringComment id

Returns void

CommentExtensions

extensions/index.ts

Comment plugin extensions

selectable

extensions/selectable.ts

Enables synchronization between comments and the selector

ts
selectable(plugin: CommentPlugin<S, K>, selector: Selector<SelectorEntity>, accumulating: { active: unknown }): void
ParameterTypeDescription
pluginCommentPlugin<S, K>Comment plugin instance
selectorSelector<SelectorEntity>Selector instance
accumulating{ active: unknown }Accumulating state

Returns void

Props

index.ts

Comment plugin properties

ts
type Props = { edit: Function };