Skip to content

Commit

Permalink
Merge pull request #43 from samerickson/main
Browse files Browse the repository at this point in the history
feat: return created comment in add functions
  • Loading branch information
Ni55aN authored Nov 3, 2024
2 parents 0b64f6d + ca99180 commit d04936b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ export class CommentPlugin<Schemes extends ExpectedSchemes, K = BaseArea<Schemes
* @param text Comment text
* @param position Comment position
* @param link Node ID the comment is linked with
* @returns comment that was created
*/
public addInline(text: string, [x, y]: [number, number], link?: string) {
const comment = new InlineComment(text, this.area, {
Expand All @@ -195,6 +196,7 @@ export class CommentPlugin<Schemes extends ExpectedSchemes, K = BaseArea<Schemes
if (link) comment.linkTo([link])

this.add(comment)
return comment
}

/**
Expand All @@ -203,6 +205,7 @@ export class CommentPlugin<Schemes extends ExpectedSchemes, K = BaseArea<Schemes
* When user drops a node on a comment, the node will be linked to the comment.
* @param text Comment text
* @param links List of node IDs the comment is linked with
* @returns comment that was created
*/
public addFrame(text: string, links: string[] = []) {
const comment = new FrameComment(text, this.area, this.editor, {
Expand All @@ -218,6 +221,7 @@ export class CommentPlugin<Schemes extends ExpectedSchemes, K = BaseArea<Schemes

this.add(comment)
this.area.area.content.reorder(comment.element, this.area.area.content.holder.firstChild)
return comment
}

public add(comment: Comment) {
Expand Down

0 comments on commit d04936b

Please sign in to comment.