From 5de6684e4b599bd9600b1e7a546d8b85ad10d9e8 Mon Sep 17 00:00:00 2001 From: kavitha Muralitharan Date: Fri, 3 Jan 2025 11:00:07 +0530 Subject: [PATCH 1/2] 904164: Added Comment Event in Core and MVC --- .../comments-event/razor | 22 ++++++++++++++++ .../comments-event/tagHelper | 23 +++++++++++++++++ ej2-asp-core-mvc/document-editor/comments.md | 25 +++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 ej2-asp-core-mvc/code-snippet/document-editor-container/comments-event/razor create mode 100644 ej2-asp-core-mvc/code-snippet/document-editor-container/comments-event/tagHelper diff --git a/ej2-asp-core-mvc/code-snippet/document-editor-container/comments-event/razor b/ej2-asp-core-mvc/code-snippet/document-editor-container/comments-event/razor new file mode 100644 index 0000000000..3f8e256358 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/document-editor-container/comments-event/razor @@ -0,0 +1,22 @@ +@Html.EJS().DocumentEditorContainer("container").EnableToolbar(true).Height("590px").BeforeCommentAction("beforeComment").Render() + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/document-editor-container/comments-event/tagHelper b/ej2-asp-core-mvc/code-snippet/document-editor-container/comments-event/tagHelper new file mode 100644 index 0000000000..caace701dc --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/document-editor-container/comments-event/tagHelper @@ -0,0 +1,23 @@ + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/document-editor/comments.md b/ej2-asp-core-mvc/document-editor/comments.md index aeae6d2a4d..5716008d99 100644 --- a/ej2-asp-core-mvc/document-editor/comments.md +++ b/ej2-asp-core-mvc/document-editor/comments.md @@ -196,3 +196,28 @@ The following example illustrates how to enable mention support in Document Edit {% highlight c# tabtitle="comments-mention.cs" %} {% endhighlight %}{% endtabs %} {% endif %} + +## Events + +DocumentEditor provides `beforeCommentAction` event, which is triggered on comment actions like Post, edit, reply, resolve and reopen. This event provides an opportunity to perform custom logic on comment actions like Post, edit, reply, resolve and reopen. The event handler receives the `CommentActionEventArgs` object as an argument, which allows access to information about the comment. + +To demonstrate a specific use case, let’s consider an example where we want to restrict the delete functionality based on the author’s name. The following code snippet illustrates how to allow only the author of a comment to delete: + +{% if page.publishingplatform == "aspnet-core" %} + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/document-editor-container/comments-event/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="comments-event.cs" %} +{% endhighlight %}{% endtabs %} + +{% elsif page.publishingplatform == "aspnet-mvc" %} + +{% tabs %} +{% highlight razor tabtitle="CSHTML" %} +{% include code-snippet/document-editor-container/comments-event/razor %} +{% endhighlight %} +{% highlight c# tabtitle="comments-event.cs" %} +{% endhighlight %}{% endtabs %} +{% endif %} \ No newline at end of file From 739a1f81f7d8eb5a72c6187a28a518f02a502331 Mon Sep 17 00:00:00 2001 From: kavitha Muralitharan Date: Fri, 3 Jan 2025 11:17:19 +0530 Subject: [PATCH 2/2] 904164: Resolved Tag issue --- .../comment-only-protect/document-editor.cs | 5 ++++ .../comments-event/document-editor.cs | 5 ++++ .../comments-event/razor | 1 + .../comments-event/tagHelper | 1 + .../comments-mention/document-editor.cs | 5 ++++ ej2-asp-core-mvc/document-editor/comments.md | 26 ++++++++++++++----- 6 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 ej2-asp-core-mvc/code-snippet/document-editor-container/comment-only-protect/document-editor.cs create mode 100644 ej2-asp-core-mvc/code-snippet/document-editor-container/comments-event/document-editor.cs create mode 100644 ej2-asp-core-mvc/code-snippet/document-editor-container/comments-mention/document-editor.cs diff --git a/ej2-asp-core-mvc/code-snippet/document-editor-container/comment-only-protect/document-editor.cs b/ej2-asp-core-mvc/code-snippet/document-editor-container/comment-only-protect/document-editor.cs new file mode 100644 index 0000000000..048a3eb88c --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/document-editor-container/comment-only-protect/document-editor.cs @@ -0,0 +1,5 @@ +public ActionResult Default() +{ + return View(); +} + diff --git a/ej2-asp-core-mvc/code-snippet/document-editor-container/comments-event/document-editor.cs b/ej2-asp-core-mvc/code-snippet/document-editor-container/comments-event/document-editor.cs new file mode 100644 index 0000000000..048a3eb88c --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/document-editor-container/comments-event/document-editor.cs @@ -0,0 +1,5 @@ +public ActionResult Default() +{ + return View(); +} + diff --git a/ej2-asp-core-mvc/code-snippet/document-editor-container/comments-event/razor b/ej2-asp-core-mvc/code-snippet/document-editor-container/comments-event/razor index 3f8e256358..e2e103e1a4 100644 --- a/ej2-asp-core-mvc/code-snippet/document-editor-container/comments-event/razor +++ b/ej2-asp-core-mvc/code-snippet/document-editor-container/comments-event/razor @@ -1,3 +1,4 @@ + @Html.EJS().DocumentEditorContainer("container").EnableToolbar(true).Height("590px").BeforeCommentAction("beforeComment").Render()