Skip to content

814887: Added Get content as plain text/rich text and corrected the naming for the content in Core and MVC #3804

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
// To select the current paragraph in document
container.documentEditor.selection.selectParagraph();

// To get the selected content as sfdt
var selectedContent = container.documentEditor.selection.sfdt;
// To get the selected content as text
var selectedContentText = container.documentEditor.selection.text;
// To get the selected content as SFDT (rich text)
var selectedContentSFDT = container.documentEditor.selection.sfdt;
}
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
// To select the current paragraph in document
container.documentEditor.selection.selectParagraph();

// To get the selected content as sfdt
var selectedContent = container.documentEditor.selection.sfdt;
// To get the selected content as text
var selectedContentText = container.documentEditor.selection.text;
// To get the selected content as SFDT (rich text)
var selectedContentSFDT = container.documentEditor.selection.sfdt;
}
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
container.documentEditor.selection.selectCurrentWord();

// To get the selected content as text
var selectedContent = container.documentEditor.selection.text;
var selectedContentText = container.documentEditor.selection.text;
// To get the selected content as SFDT (rich text)
var selectedContentSFDT = container.documentEditor.selection.sfdt;
}
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
container.documentEditor.selection.selectCurrentWord();

// To get the selected content as text
var selectedContent = container.documentEditor.selection.text;
var selectedContentText = container.documentEditor.selection.text;
// To get the selected content as SFDT (rich text)
var selectedContentSFDT = container.documentEditor.selection.sfdt;
}
</script>
20 changes: 13 additions & 7 deletions ej2-asp-core-mvc/document-editor/how-to/get-current-word.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
layout: post
title: Select and retrieve current word and Paragraph in ##Platform_Name## Document Editor Component
title: Get current Word/Para in ##Platform_Name## Document editor control | Syncfusion
description: Learn how to select and retrieve current word and Paragraph from the Syncfusion ##Platform_Name## Document Editor Component
platform: ej2-asp-core-mvc
control: Get The Current Word And Paragrapgh
Expand All @@ -25,7 +25,9 @@ The following example code illustrates how to select and get the current word as
{% include code-snippet/document-editor-container/get-word/tagHelper %}
{% endhighlight %}
{% highlight c# tabtitle="Get-word.cs" %}
{% endhighlight %}{% endtabs %}
{% endhighlight %}
{% code-snippet/document-editor-container/get-word/document-editor.cs %}
{% endtabs %}

{% elsif page.publishingplatform == "aspnet-mvc" %}

Expand All @@ -34,12 +36,12 @@ The following example code illustrates how to select and get the current word as
{% include code-snippet/document-editor-container/get-word/razor %}
{% endhighlight %}
{% highlight c# tabtitle="Get-word.cs" %}
{% endhighlight %}{% endtabs %}
{% code-snippet/document-editor-container/get-word/document-editor.cs %}
{% endhighlight %}
{% endtabs %}
{% endif %}


To get the bookmark content as SFDT (rich text), check this [`link`](../../document-editor/how-to/get-the-selected-content/#get-the-selected-content-as-sfdt-rich-text)

## Select and get the paragraph in current cursor position

You can use [`selectParagraph`] API in selection module to select the current paragraph at cursor position and use [`text`] API or [`sfdt`] API to get the selected content as plain text or SFDT from Document Editor component.
Expand All @@ -53,7 +55,9 @@ The following example code illustrates how to select and get the current paragra
{% include code-snippet/document-editor-container/get-paragraph/tagHelper %}
{% endhighlight %}
{% highlight c# tabtitle="Get-paragraph.cs" %}
{% endhighlight %}{% endtabs %}
{% code-snippet/document-editor-container/get-paragraph/document-editor.cs %}
{% endhighlight %}
{% endtabs %}

{% elsif page.publishingplatform == "aspnet-mvc" %}

Expand All @@ -62,5 +66,7 @@ The following example code illustrates how to select and get the current paragra
{% include code-snippet/document-editor-container/get-paragraph/razor %}
{% endhighlight %}
{% highlight c# tabtitle="Get-paragraph.cs" %}
{% endhighlight %}{% endtabs %}
{% code-snippet/document-editor-container/get-paragraph/document-editor.cs %}
{% endhighlight %}
{% endtabs %}
{% endif %}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
layout: post
title: Get The Selected Content in ##Platform_Name## Document Editor Component
title: Get Selected Content in ##Platform_Name## Document Editor Component | Syncfusion
description: Learn here all about get the selected content in Syncfusion ##Platform_Name## Document Editor component of Syncfusion Essential JS 2 and more.
platform: ej2-asp-core-mvc
control: Get The Selected Content
Expand All @@ -24,7 +24,9 @@ You can use `text` API to get the selected content as plain text from React Docu
{% include code-snippet/document-editor-container/get-text/tagHelper %}
{% endhighlight %}
{% highlight c# tabtitle="Get-text.cs" %}
{% endhighlight %}{% endtabs %}
{% code-snippet/document-editor-container/get-text/document-editor.cs %}
{% endhighlight %}
{% endtabs %}

{% elsif page.publishingplatform == "aspnet-mvc" %}

Expand All @@ -33,7 +35,9 @@ You can use `text` API to get the selected content as plain text from React Docu
{% include code-snippet/document-editor-container/get-text/razor %}
{% endhighlight %}
{% highlight c# tabtitle="Get-text.cs" %}
{% endhighlight %}{% endtabs %}
{% code-snippet/document-editor-container/get-text/document-editor.cs %}
{% endhighlight %}
{% endtabs %}
{% endif %}


Expand All @@ -46,7 +50,7 @@ You can add the following custom options using this API,

## Get the selected content as SFDT (rich text)

You can use `sfdt` API to get the selected content as plain text from React Document Editor component.
You can use `sfdt` API to get the selected content as rich text from React Document Editor component.

{% if page.publishingplatform == "aspnet-core" %}

Expand All @@ -55,7 +59,9 @@ You can use `sfdt` API to get the selected content as plain text from React Docu
{% include code-snippet/document-editor-container/get-sfdt/tagHelper %}
{% endhighlight %}
{% highlight c# tabtitle="Get-sfdt.cs" %}
{% endhighlight %}{% endtabs %}
{% code-snippet/document-editor-container/get-sfdt/document-editor.cs %}
{% endhighlight %}
{% endtabs %}

{% elsif page.publishingplatform == "aspnet-mvc" %}

Expand All @@ -64,13 +70,15 @@ You can use `sfdt` API to get the selected content as plain text from React Docu
{% include code-snippet/document-editor-container/get-sfdt/razor %}
{% endhighlight %}
{% highlight c# tabtitle="Get-sfdt.cs" %}
{% endhighlight %}{% endtabs %}
{% code-snippet/document-editor-container/get-sfdt/document-editor.cs %}
{% endhighlight %}
{% endtabs %}
{% endif %}



You can add the following custom options using this API,

* Save or export the selected content as SFDT file.
* Get the content of a bookmark in Word document as SFDT by selecting a bookmark using `selectbookmark` API.
* Get the content of a bookmark in Word document as SFDT by selecting a bookmark using `select bookmark` API.
* Create template content that can be inserted to multiple documents in cursor position using `paste` API.