diff --git a/ej2-asp-core-mvc/code-snippet/document-editor-container/context-type-selection/document-editor.cs b/ej2-asp-core-mvc/code-snippet/document-editor-container/context-type-selection/document-editor.cs new file mode 100644 index 0000000000..048a3eb88c --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/document-editor-container/context-type-selection/document-editor.cs @@ -0,0 +1,5 @@ +public ActionResult Default() +{ + return View(); +} + diff --git a/ej2-asp-core-mvc/code-snippet/document-editor-container/context-type-selection/razor b/ej2-asp-core-mvc/code-snippet/document-editor-container/context-type-selection/razor new file mode 100644 index 0000000000..76b5944b84 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/document-editor-container/context-type-selection/razor @@ -0,0 +1,19 @@ + +@Html.EJS().Button("element").Content("Context Type").Click("contextType").Render() +@Html.EJS().DocumentEditorContainer("container").Created("onCreated").EnableToolbar(true).Render() + + diff --git a/ej2-asp-core-mvc/code-snippet/document-editor-container/context-type-selection/tagHelper b/ej2-asp-core-mvc/code-snippet/document-editor-container/context-type-selection/tagHelper new file mode 100644 index 0000000000..26e98e13cc --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/document-editor-container/context-type-selection/tagHelper @@ -0,0 +1,20 @@ +
+ + + +
+ diff --git a/ej2-asp-core-mvc/document-editor/how-to/contextType-based-on-selection.md b/ej2-asp-core-mvc/document-editor/how-to/contextType-based-on-selection.md new file mode 100644 index 0000000000..cc054e57c4 --- /dev/null +++ b/ej2-asp-core-mvc/document-editor/how-to/contextType-based-on-selection.md @@ -0,0 +1,45 @@ +--- +layout: post +title: ContextType Based on selection in ##Platform_Name## Document Editor Component +description: Learn how to ContextType Based on selection in Document from the ##Platform_Name## Document Editor Component +platform: ej2-asp-core-mvc +control: ContextType Based on selection +publishingplatform: ##Platform_Name## +documentation: ug +--- + +# Determine the context type of the current cursor position based on the selection in the Document in ##Platform_Name## Document editor control + +You can utilize the contextType API within the selection module to determine whether the current cursor is positioned in the table,text and so on. + +## Get the ContextType based on selected content + +You can use [`contextType`]API to get the contextType based on the selected content in the Document Editor component. + +The following example code illustrates how to determine the context type of the current cursor position based on the selection in the Document. + +* Click the Button while selecting the specific context type. +* This will get the context type and result to show the contextType based on the selected content in the Document. + +{% if page.publishingplatform == "aspnet-core" %} + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/document-editor-container/context-type-selection/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="context-type-selection.cs" %} +{% include code-snippet/document-editor-container/context-type-selection/document-editor.cs %} +{% endhighlight %} +{% endtabs %} + +{% elsif page.publishingplatform == "aspnet-mvc" %} + +{% tabs %} +{% highlight razor tabtitle="CSHTML" %} +{% include code-snippet/document-editor-container/context-type-selection/razor %} +{% endhighlight %} +{% highlight c# tabtitle="Context-type-selection.cs" %} +{% include code-snippet/document-editor-container/context-type-selection/document-editor.cs %} +{% endhighlight %} +{% endtabs %} +{% endif %} \ No newline at end of file diff --git a/ej2-asp-core-toc.html b/ej2-asp-core-toc.html index 9b22766f49..8823a47a3a 100644 --- a/ej2-asp-core-toc.html +++ b/ej2-asp-core-toc.html @@ -1000,6 +1000,7 @@
  • Select and Get the Current Word and Paragraph
  • Insert page number and navigate to specific page
  • Move the selection to specific position in Document
  • +
  • Determine the context type of the current cursor position based on the selection in the Document
  • Disable Header and Footer edit in Document
  • Insert the text and rich-text content in Document editor
  • Change the cursor color in document editor using CSS
  • diff --git a/ej2-asp-mvc-toc.html b/ej2-asp-mvc-toc.html index 6daa8c4bba..4f2abd72bb 100644 --- a/ej2-asp-mvc-toc.html +++ b/ej2-asp-mvc-toc.html @@ -948,6 +948,7 @@
  • Select and Get the Current Word and Paragraph
  • Insert page number and navigate to specific page
  • Move the selection to specific position in Document
  • +
  • Determine the context type of the current cursor position based on the selection in the Document
  • Disable Header and Footer edit in Document
  • Insert the text and rich-text content in Document editor
  • Change the cursor color in document editor using CSS