Skip to content

Commit 4b514d2

Browse files
Merge pull request #4673 from syncfusion-content/968277-clipboard
968277: Update UG Documentation with Clipboard Cleanup Feature
2 parents ec67edb + 5d91105 commit 4b514d2

File tree

10 files changed

+202
-0
lines changed

10 files changed

+202
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
public class HomeController : Controller
2+
{
3+
4+
public ActionResult Index()
5+
{
6+
return View();
7+
}
8+
9+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@Html.EJS().RichTextEditor("clipboardCleanup").BeforeClipboardWrite("beforeClipboardWrite").Render()
2+
3+
<script>
4+
function beforeClipboardWrite(args){
5+
if (args.operation === 'copy') {
6+
args.htmlContent = '<h1>This is customized content triggered while copy event</h1>';
7+
args.plainTextContent = 'This is customized content triggered while copy event';
8+
}
9+
}
10+
</script>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<ejs-richtexteditor id="clipboardCleanup" beforeClipboardWrite="beforeClipboardWrite"></ejs-richtexteditor>
2+
3+
<script>
4+
function beforeClipboardWrite(args){
5+
if (args.operation === 'copy') {
6+
args.htmlContent = '<h1>This is customized content triggered while copy event</h1>';
7+
args.plainTextContent = 'This is customized content triggered while copy event';
8+
}
9+
}
10+
</script>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
public class HomeController : Controller
2+
{
3+
4+
public ActionResult Index()
5+
{
6+
return View();
7+
}
8+
9+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
@Html.EJS().RichTextEditor("clipboardCleanup").Render()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<ejs-richtexteditor id="clipboardCleanup"></ejs-richtexteditor>
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
layout: post
3+
title: Clipboard Cleanup in ##Platform_Name## Syncfusion Rich Text Editor Component
4+
description: Learn here all about Clipboard Cleanup in Syncfusion ##Platform_Name## Rich Text Editor component of Syncfusion Essential JS 2 and more.
5+
platform: ej2-asp-core-mvc
6+
control: Clipboard Cleanup
7+
publishingplatform: ##Platform_Name##
8+
documentation: ug
9+
---
10+
11+
# Clipboard Cleanup in ##Platform_Name## Rich Text Editor Control
12+
13+
The Rich Text Editor supports automatic cleanup of clipboard content during copy (`Ctrl + C`) and cut (`Ctrl + X`) operations. When this feature is enabled, unwanted inline styles are automatically removed from the clipboard content while preserving important structural elements such as tables, lists, and images. You can enable this behavior using the [EnableClipboardCleanup](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.richtexteditor.richtexteditor.html#Syncfusion_EJ2_RichTextEditor_RichTextEditor_EnableClipboardCleanup) property.
14+
15+
When `EnableClipboardCleanup` is set to `true`, copy and cut operations are intercepted to remove unwanted inline styles. When set to `false` the browser’s default copy and cut behavior applies.
16+
17+
> For a cleaner editing experience, `EnableClipboardCleanup` is `true` by default.
18+
19+
{% if page.publishingplatform == "aspnet-core" %}
20+
21+
{% tabs %}
22+
{% highlight cshtml tabtitle="CSHTML" %}
23+
{% include code-snippet/rich-text-editor/clipboard-cleanup/tagHelper %}
24+
{% endhighlight %}
25+
{% highlight c# tabtitle="Controller.cs" %}
26+
{% include code-snippet/rich-text-editor/clipboard-cleanup/controller.cs %}
27+
{% endhighlight %}
28+
{% endtabs %}
29+
30+
{% elsif page.publishingplatform == "aspnet-mvc" %}
31+
32+
{% tabs %}
33+
{% highlight razor tabtitle="CSHTML" %}
34+
{% include code-snippet/rich-text-editor/clipboard-cleanup/razor %}
35+
{% endhighlight %}
36+
{% highlight c# tabtitle="Controller.cs" %}
37+
{% include code-snippet/rich-text-editor/clipboard-cleanup/controller.cs %}
38+
{% endhighlight %}
39+
{% endtabs %}
40+
{% endif %}
41+
42+
## Customizing Copied/Cut Content
43+
44+
You can use the [BeforeClipboardWrite](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.richtexteditor.richtexteditor.html#Syncfusion_EJ2_RichTextEditor_RichTextEditor_BeforeClipboardWrite) event, which fires before content is written to the clipboard during copy or cut operations. This event lets you to modify the HTML and plain-text representations of the content and also determine whether the action is a copy or a cut.
45+
46+
In this example, the `BeforeClipboardWrite` event is used to customize the selected content only during a copy operation, while the cut operation remains unaffected. To observe this behavior, try copying any text within the Rich Text Editor.
47+
48+
{% if page.publishingplatform == "aspnet-core" %}
49+
50+
{% tabs %}
51+
{% highlight cshtml tabtitle="CSHTML" %}
52+
{% include code-snippet/rich-text-editor/clipboard-cleanup-customize/tagHelper %}
53+
{% endhighlight %}
54+
{% highlight c# tabtitle="Controller.cs" %}
55+
{% include code-snippet/rich-text-editor/clipboard-cleanup-customize/controller.cs %}
56+
{% endhighlight %}
57+
{% endtabs %}
58+
59+
{% elsif page.publishingplatform == "aspnet-mvc" %}
60+
61+
{% tabs %}
62+
{% highlight razor tabtitle="CSHTML" %}
63+
{% include code-snippet/rich-text-editor/clipboard-cleanup-customize/razor %}
64+
{% endhighlight %}
65+
{% highlight c# tabtitle="Controller.cs" %}
66+
{% include code-snippet/rich-text-editor/clipboard-cleanup-customize/controller.cs %}
67+
{% endhighlight %}
68+
{% endtabs %}
69+
{% endif %}
70+
71+
## Best Practices & Troubleshooting
72+
73+
### Best Practices
74+
75+
- Use `BeforeClipboardWrite` sparingly — heavy processing can slightly delay `Ctrl+C`.
76+
77+
### Common Issues
78+
79+
- “Event not firing” → Make sure you’re using the correct event name `BeforeClipboardWrite` (PascalCase in MVC).
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
layout: post
3+
title: Clipboard Cleanup in ##Platform_Name## Syncfusion Rich Text Editor Control
4+
description: Learn here all about Clipboard Cleanup in Syncfusion ##Platform_Name## Rich Text Editor control of Syncfusion Essential JS 2 and more.
5+
platform: ej2-asp-core-mvc
6+
control: Clipboard Cleanup
7+
publishingplatform: ##Platform_Name##
8+
documentation: ug
9+
---
10+
11+
# Clipboard Cleanup in ##Platform_Name## Rich Text Editor Control
12+
13+
The Rich Text Editor supports automatic cleanup of clipboard content during copy (`Ctrl + C`) and cut (`Ctrl + X`) operations. When this feature is enabled, unwanted inline styles are automatically removed from the clipboard content while preserving important structural elements such as tables, lists, and images. You can enable this behavior using the [enableClipboardCleanup](https://help.syncfusion.com/cr/aspnetcore-js2/syncfusion.ej2.richtexteditor.richtexteditor.html#Syncfusion_EJ2_RichTextEditor_RichTextEditor_EnableClipboardCleanup) property.
14+
15+
When `enableClipboardCleanup` is set to `true`, copy and cut operations are intercepted to remove unwanted inline styles. When set to `false` the browser’s default copy and cut behavior applies.
16+
17+
> For a cleaner editing experience, `enableClipboardCleanup` is `true` by default.
18+
19+
{% if page.publishingplatform == "aspnet-core" %}
20+
21+
{% tabs %}
22+
{% highlight cshtml tabtitle="CSHTML" %}
23+
{% include code-snippet/rich-text-editor/clipboard-cleanup/tagHelper %}
24+
{% endhighlight %}
25+
{% highlight c# tabtitle="Controller.cs" %}
26+
{% include code-snippet/rich-text-editor/clipboard-cleanup/controller.cs %}
27+
{% endhighlight %}
28+
{% endtabs %}
29+
30+
{% elsif page.publishingplatform == "aspnet-mvc" %}
31+
32+
{% tabs %}
33+
{% highlight razor tabtitle="CSHTML" %}
34+
{% include code-snippet/rich-text-editor/clipboard-cleanup/razor %}
35+
{% endhighlight %}
36+
{% highlight c# tabtitle="Controller.cs" %}
37+
{% include code-snippet/rich-text-editor/clipboard-cleanup/controller.cs %}
38+
{% endhighlight %}
39+
{% endtabs %}
40+
{% endif %}
41+
42+
## Customizing Copied/Cut Content
43+
44+
You can use the [beforeClipboardWrite](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.RichTextEditor.RichTextEditor.html#Syncfusion_EJ2_RichTextEditor_RichTextEditor_BeforeClipboardWrite) event, which fires before content is written to the clipboard during copy or cut operations. This event lets you to modify the HTML and plain-text representations of the content and also determine whether the action is a copy or a cut.
45+
46+
In this example, the `beforeClipboardWrite` event is used to customize the selected content only during a copy operation, while the cut operation remains unaffected. To observe this behavior, try copying any text within the Rich Text Editor.
47+
48+
{% if page.publishingplatform == "aspnet-core" %}
49+
50+
{% tabs %}
51+
{% highlight cshtml tabtitle="CSHTML" %}
52+
{% include code-snippet/rich-text-editor/clipboard-cleanup-customize/tagHelper %}
53+
{% endhighlight %}
54+
{% highlight c# tabtitle="Controller.cs" %}
55+
{% include code-snippet/rich-text-editor/clipboard-cleanup-customize/controller.cs %}
56+
{% endhighlight %}
57+
{% endtabs %}
58+
59+
{% elsif page.publishingplatform == "aspnet-mvc" %}
60+
61+
{% tabs %}
62+
{% highlight razor tabtitle="CSHTML" %}
63+
{% include code-snippet/rich-text-editor/clipboard-cleanup-customize/razor %}
64+
{% endhighlight %}
65+
{% highlight c# tabtitle="Controller.cs" %}
66+
{% include code-snippet/rich-text-editor/clipboard-cleanup-customize/controller.cs %}
67+
{% endhighlight %}
68+
{% endtabs %}
69+
{% endif %}
70+
71+
## Best Practices & Troubleshooting
72+
73+
### Best Practices
74+
75+
- Use `beforeClipboardWrite` sparingly — heavy processing can slightly delay `Ctrl+C`.
76+
77+
### Common Issues
78+
79+
- “Event not firing” → Make sure you’re using the correct event name `beforeClipboardWrite` (camelCase in Core).
80+

ej2-asp-core-toc.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2248,6 +2248,7 @@
22482248
<li><a href="/ej2-asp-core/rich-text-editor/code-block">Code Block</a></li>
22492249
<li><a href="/ej2-asp-core/rich-text-editor/remove-formatting">Remove Formatting</a></li>
22502250
<li><a href="/ej2-asp-core/rich-text-editor/format-painter">Format Painter</a></li>
2251+
<li><a href="/ej2-asp-core/rich-text-editor/clipboard-cleanup">Clipboard Cleanup</a></li>
22512252
<li><a href="/ej2-asp-core/rich-text-editor/paste-cleanup">Paste Cleanup</a></li>
22522253
<li><a href="/ej2-asp-core/rich-text-editor/enter-key-configuration">Enter Key Configuration</a></li>
22532254
<li><a href="/ej2-asp-core/rich-text-editor/undo-redo">Undo Redo</a></li>

ej2-asp-mvc-toc.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2202,6 +2202,7 @@
22022202
<li><a href="/ej2-asp-mvc/rich-text-editor/code-block">Code Block</a></li>
22032203
<li><a href="/ej2-asp-mvc/rich-text-editor/remove-formatting">Remove Formatting</a></li>
22042204
<li><a href="/ej2-asp-mvc/rich-text-editor/format-painter">Format Painter</a></li>
2205+
<li><a href="/ej2-asp-mvc/rich-text-editor/clipboard-cleanup">Clipboard Cleanup</a></li>
22052206
<li><a href="/ej2-asp-mvc/rich-text-editor/paste-cleanup">Paste Cleanup</a></li>
22062207
<li><a href="/ej2-asp-mvc/rich-text-editor/enter-key-configuration">Enter Key Configuration</a></li>
22072208
<li><a href="/ej2-asp-mvc/rich-text-editor/undo-redo">Undo Redo</a></li>

0 commit comments

Comments
 (0)