Skip to content

Commit c0c070f

Browse files
Merge pull request #3238 from syncfusion-content/899281-comments
899281: Added insert reply comment, get comment and delete comments api.
2 parents d9ceff8 + ef54e5d commit c0c070f

File tree

1 file changed

+73
-3
lines changed

1 file changed

+73
-3
lines changed

ej2-asp-core-mvc/document-editor/comments.md

Lines changed: 73 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,66 @@ Comments can be inserted to the selected text.
2121
documentEditor.editor.insertComment("Test comment");
2222
```
2323

24+
## Add a New Comment with Date, Author, and Status
25+
26+
Comments can be inserted into the selected text with a specified date, author, and status `insertComment`.
27+
28+
```typescript
29+
// In this example, a comment with the text "Hello world"
30+
// is added by the author Nancy Davolio on July 23, 2024, at 2:30 PM.
31+
// The isResolved status is set to false.
32+
33+
// Create a specific date: July 23, 2024, at 2:30:00 PM.
34+
// Note: July is represented by 6 (0-based index).
35+
var specificDate = new Date(2024, 6, 23, 14, 30, 0);
36+
37+
38+
// Define the properties of the comment including author, date, and resolution status.
39+
var commentProperties = {
40+
author: 'Nancy Davolio', // The author of the comment.
41+
dateTime: specificDate, // The date and time when the comment is created.
42+
isResolved: false // The status of the comment; false indicates it is unresolved.
43+
};
44+
45+
// Insert the comment with the specified properties into the document editor.
46+
documentEditor.editor.insertComment('Hello world', commentProperties);
47+
```
48+
49+
## Add a Reply Comment with Date, Author, and Status
50+
51+
Reply comments can be inserted into the parent comment with a specified date, author using `insertReplyComment`.
52+
53+
```typescript
54+
// In this example, a comment with the text "Hello world"
55+
// is added by the author Nancy Davolio on July 23, 2024, at 2:30 PM.
56+
// The isResolved status is set to false.
57+
58+
// Create a specific date: July 23, 2024, at 2:30:00 PM.
59+
// Note: July is represented by 6 (0-based index).
60+
var specificDate = new Date(2024, 6, 23, 14, 30, 0);
61+
62+
// Define the properties of the comment including author, date, and resolution status.
63+
var commentProperties = {
64+
author: 'Nancy Davolio', // The author of the comment.
65+
dateTime: specificDate, // The date and time when the comment is created.
66+
isResolved: false // The status of the comment; false indicates it is unresolved.
67+
};
68+
69+
// Insert the comment with the specified properties into the Document Editor.
70+
var comment = documentEditor.editor.insertComment('Hello world', commentProperties);
71+
// Insert a reply comment with specified properties into the Document Editor
72+
documentEditor.editor.insertReplyComment(comment.id, 'Hello world', commentProperties);
73+
```
74+
75+
## Get Comments
76+
77+
Document Editor allows to get the comments along with its reply and comment properties using `getComments`.
78+
79+
```typescript
80+
//Get Comments in the document along with the properties author, date, status.
81+
var commentinfo = container.documentEditor.getComments();
82+
```
83+
2484
## Comment navigation
2585

2686
Next and previous comments can be navigated using the below code snippet.
@@ -35,10 +95,20 @@ documentEditor.selection.navigatePreviousComment();
3595

3696
## Delete comment
3797

38-
Current comment can be deleted using the below code snippet.
98+
Current comment can be deleted using `deleteComment`.
3999

40100
```typescript
41-
documentEditor.editor.deleteComment();
101+
//Delete the current selected comment.
102+
container.documentEditor.editor.deleteComment();
103+
104+
//Get Comments in the document along with the properties author, date, status.
105+
let commentinfo = container.documentEditor.getComments();
106+
107+
//Delete the particular parent comments and all of its reply comments
108+
container.documentEditor.editor.deleteComment(commentinfo[0].id);
109+
110+
//Delete the particular reply comment.
111+
container.documentEditor.editor.deleteComment(commentinfo[0].replies[0].id);
42112
```
43113

44114
## Delete all comment
@@ -104,4 +174,4 @@ The following example illustrates how to enable mention support in Document Edit
104174
{% endhighlight %}
105175
{% highlight c# tabtitle="comments-mention.cs" %}
106176
{% endhighlight %}{% endtabs %}
107-
{% endif %}
177+
{% endif %}

0 commit comments

Comments
 (0)