Skip to content

Commit 67915ce

Browse files
Merge pull request #4589 from Syncfusion-Content/hotfix/hotfix-v31.1.17
DOCINFRA-2341_merged_using_automation
2 parents 3a8bbd7 + e2f0e92 commit 67915ce

File tree

3 files changed

+88
-49
lines changed

3 files changed

+88
-49
lines changed

ej2-asp-core-mvc/rich-text-editor/EJ2_ASP.MVC/paste-cleanup.md

Lines changed: 42 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,101 @@
11
---
22
layout: post
3-
title: Paste Cleanup in ##Platform_Name## Rich Text Editor Component
3+
title: Paste Cleanup in ##Platform_Name## Syncfusion Rich Text Editor Component
44
description: Learn here all about Paste Cleanup in Syncfusion ##Platform_Name## Rich Text Editor component of Syncfusion Essential JS 2 and more.
55
platform: ej2-asp-core-mvc
66
control: Paste Cleanup
77
publishingplatform: ##Platform_Name##
88
documentation: ug
99
---
1010

11-
1211
# Paste Cleanup in ##Platform_Name## Rich Text Editor Control
1312

14-
The Rich Text Editor simplifies the conversion of Microsoft Word content to HTML format, preserving formatting and styles. The `PasteCleanup` settings property allows you to control the formatting and styles when pasting content into the editor. The following settings are available to clean up the content:
13+
The Rich Text Editor simplifies the conversion of Microsoft Word content to HTML format, preserving formatting and styles. The `pasteCleanup` settings property (see [pasteCleanupSettingsModel](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.richtexteditor.richtexteditor.html#Syncfusion_EJ2_RichTextEditor_RichTextEditor_PasteCleanupSettings)) allows you to control the formatting and styles when pasting content into the editor. The following settings are available to clean up the content:
1514

1615
| API | Description | Default Value | Type |
1716
|:----------------:|:---------:|:-----------------------------:|:---------:|
18-
| [Prompt](#Prompt) | Invokes a Prompt dialog with paste options when pasting content into the editor| false | boolean |
19-
| [PlainText](#plain-text) | Paste the content as plain text| false | boolean |
20-
| [KeepFormat](#keep-format) | Maintains the same format as the copied content| true | boolean |
21-
| [DeniedTags](#denied-tags) | Ignores specified tags when pasting HTML content| null | string[] |
22-
| [DeniedAttrs](#denied-attributes) | Filters out specified attributes from the pasted content| null | string[] |
23-
| [AllowedStyleProps](#allowed-style-properties) | Accepts specified style attributes and removes others from the pasted content| ['background', 'background-color', 'border', 'border-bottom', 'border-left', 'border-radius', 'border-right', 'border-style', 'border-top', 'border-width', 'clear', 'color', 'cursor', 'direction', 'display', 'float', 'font', 'font-family', 'font-size', 'font-weight', 'font-style', 'height', 'left', 'line-height', 'margin', 'margin-top', 'margin-left', 'margin-right', 'margin-bottom', 'max-height', 'max-width', 'min-height', 'min-width', 'overflow', 'overflow-x', 'overflow-y', 'padding', 'padding-bottom', 'padding-left', 'padding-right', 'padding-top', 'position', 'right', 'table-layout', 'text-align', 'text-decoration', 'text-indent', 'top', 'vertical-align', 'visibility', 'white-space', 'width'] | string[] |
17+
| [Prompt](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.RichTextEditor.RichTextEditorPasteCleanupSettings.html#Syncfusion_EJ2_RichTextEditor_RichTextEditorPasteCleanupSettings_Prompt) | Displays a dialog box when content is pasted, allowing users to choose how the content should be inserted—either as plain text, with formatting, or cleaned HTML. | false | boolean |
18+
| [PlainText](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.RichTextEditor.RichTextEditorPasteCleanupSettings.html#Syncfusion_EJ2_RichTextEditor_RichTextEditorPasteCleanupSettings_PlainText) | Paste the content as plain text| false | boolean |
19+
| [KeepFormat](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.RichTextEditor.RichTextEditorPasteCleanupSettings.html#Syncfusion_EJ2_RichTextEditor_RichTextEditorPasteCleanupSettings_KeepFormat) | Retains the original formatting of the pasted content, including styles, fonts, and structure.| true | boolean |
20+
| [DeniedTags](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.RichTextEditor.RichTextEditorPasteCleanupSettings.html#Syncfusion_EJ2_RichTextEditor_RichTextEditorPasteCleanupSettings_DeniedTags) | Specifies a list of HTML tags to be removed from the pasted content, such as `<script>`, `<iframe>`, or `<style>`. Helps eliminate unwanted or unsafe elements. | null | string[] |
21+
| [DeniedAttrs](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.RichTextEditor.RichTextEditorPasteCleanupSettings.html#Syncfusion_EJ2_RichTextEditor_RichTextEditorPasteCleanupSettings_DeniedAttrs) | Filters out specified attributes from the pasted content| null | string[] |
22+
| [AllowedStyleProps](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.RichTextEditor.RichTextEditorPasteCleanupSettings.html#Syncfusion_EJ2_RichTextEditor_RichTextEditorPasteCleanupSettings_AllowedStyleProps) | Accepts specified style attributes and removes others from the pasted content| ['background', 'background-color', 'border', 'border-bottom', 'border-left', 'border-radius', 'border-right', 'border-style', 'border-top', 'border-width', 'clear', 'color', 'cursor', 'direction', 'display', 'float', 'font', 'font-family', 'font-size', 'font-weight', 'font-style', 'height', 'left', 'line-height', 'margin', 'margin-top', 'margin-left', 'margin-right', 'margin-bottom', 'max-height', 'max-width', 'min-height', 'min-width', 'overflow', 'overflow-x', 'overflow-y', 'padding', 'padding-bottom', 'padding-left', 'padding-right', 'padding-top', 'position', 'right', 'table-layout', 'text-align', 'text-decoration', 'text-indent', 'top', 'vertical-align', 'visibility', 'white-space', 'width'] | string[] |
2423

25-
## Understanding Paste Options in the Prompt Dialog
24+
## Paste options in the prompt dialog
2625

2726
When `Prompt` is set to true, pasting the content in the editor will open a dialog box that contains three options `Keep`, `Clean`, and `Plain Text` as radio buttons:
27+
28+
![Rich Text Editor Paste options prompt dialog ](../images/richtexteditor-paste-prompt.png)
29+
2830
1. `Keep`: Maintains the same format as the copied content.
2931
2. `Clean`: Clears all style formats from the copied content.
3032
3. `Plain Text`: Pastes the copied content as plain text without any formatting or style. (including the removal of all tags).
3133

32-
> When `Prompt` value is set true, the API properties [PlainText](#plain-text) and [KeepFormat](#keep-format) will not be considered for processing when pasting the content.
34+
> When `Prompt` value is set true, the API properties [PlainText](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.RichTextEditor.RichTextEditorPasteCleanupSettings.html#Syncfusion_EJ2_RichTextEditor_RichTextEditorPasteCleanupSettings_PlainText) and [KeepFormat](https://help.syncfusion.com/cr/aspnetmvc-js2/Syncfusion.EJ2.RichTextEditor.RichTextEditorPasteCleanupSettings.html#Syncfusion_EJ2_RichTextEditor_RichTextEditorPasteCleanupSettings_KeepFormat) will not be considered for processing when pasting the content.
3335
34-
## How to Paste as Plain Text
36+
## Plain text pasting
3537

3638
Setting `PlainText` to true converts the copied content to plain text by removing all HTML tags and styles. Only the plain text is pasted into the editor.
3739

3840
>When `PlainText` is set to true, set `Prompt` to false. The `KeepFormat` property will not be considered.
3941
40-
## Maintaining Formatting with Keep Format Option
42+
## Keep format
43+
44+
When `KeepFormat` is set to `true`, the pasted content retains its original formatting, including styles, fonts, and structure. However, the formatting is still subject to filtering based on the `AllowedStyleProps`, `DeniedTags`, and `DeniedAttrs` settings:
45+
46+
* Only the style properties listed in `AllowedStyleProps` will be preserved.
47+
* Any HTML tags listed in `DeniedTags` will be removed.
48+
* Any attributes listed in `DeniedAttrs` will be stripped from the pasted content.
4149

42-
When `KeepFormat` is set to true, the copied content maintains all style formatting allowed in the `AllowedStyleProps` when pasted into the editor.
50+
This ensures that while the formatting is retained, it remains clean, safe, and consistent with your application's styling rules.
4351

44-
If `KeepFormat` is set to false, all styles in the copied content are removed, regardless of the `AllowedStyleProps` settings.
52+
>When `keepFormat` is set to true, set both `Prompt` and `PlainText` to false.
4553
46-
>When `KeepFormat` is set to true, set both `Prompt` and `PlainText` to false.
54+
## Clean Formatting
4755

48-
## Cleaning Formatting During Paste
56+
When the `Prompt`, `PlainText`, and `keepFormat` options are all set to false, the Rich Text Editor performs clean format paste cleanup. In this mode, all inline styles from the pasted content are removed, eliminating any custom or external styling. This ensures a consistent and uniform appearance within the editor.
4957

50-
Setting `CleanFormat` to true removes all applied styles from the pasted content while retaining all other HTML tags in the editor.
58+
Despite the removal of styling, essential structural HTML tags such as `<p>`, `<ul>`, `<table>`, and others are preserved. This maintains the original layout and semantic integrity of the content, allowing it to remain well-structured and readable.However, the formatting is still subject to filtering based on the `DeniedTags`, and `DeniedAttrs` settings:
5159

52-
>When `CleanFormat` is set to true, set `Prompt`, `PlainText`, and `KeepFormat` to false.
60+
- **`DeniedTags`**: Tags listed here will still be removed from the pasted content.
61+
- **`DeniedAttrs`**: Attributes listed here will also be stripped from the pasted content.
5362

54-
## Managing Denied Tags for Paste Cleanup
63+
> The `AllowedStyleProps` setting only applies if `KeepFormat` is enabled.
64+
65+
## Denied tags
5566

5667
When `DeniedTags` values are set, the specified tags will be removed from the pasted content. For example,
5768

5869
* `'a'`: Removes all anchor tags.
5970
* `'a[!href]'`: Removes anchor tags without the 'href' attribute.
6071
* `'a[href, target]'`: Removes anchor tags with both 'href' and 'target' attributes.
6172

73+
> This setting is ignored when `PlainText` is set to `true`. <br>
74+
It only works when either `KeepFormat` is set to `true`, or when `Prompt`, `PlainText`, and `KeepFormat` are all set to `false`, which triggers clean format behavior.
75+
6276
## Configuring Denied Attributes in Paste Settings
6377

6478
When `DeniedAttrs` values are set, the specified attributes will be removed from all tags in the pasted content. For example,
6579

6680
`'id', 'title'`: Removes 'id' and 'title' attributes from all tags.
6781

82+
> This setting is ignored when `PlainText` is set to `true`. <br>
83+
It only works when either `KeepFormat` is set to `true`, or when `Prompt`, `PlainText`, and `KeepFormat` are all set to `false`, which triggers clean format behavior.
84+
6885
## Allowing Specific Style Properties for Pasted Content
6986

70-
By default, the following basic styles are allowed on pasting the content to the editor.
87+
By default, a predefined set of basic style properties are allowed when content is pasted into the Rich Text Editor.
7188

7289
['background', 'background-color', 'border', 'border-bottom', 'border-left', 'border-radius', 'border-right', 'border-style', 'border-top', 'border-width', 'clear', 'color', 'cursor', 'direction', 'display', 'float', 'font', 'font-family', 'font-size', 'font-weight', 'font-style', 'height', 'left', 'line-height', 'margin', 'margin-top', 'margin-left', 'margin-right', 'margin-bottom', 'max-height', 'max-width', 'min-height', 'min-width', 'overflow', 'overflow-x', 'overflow-y', 'padding', 'padding-bottom', 'padding-left', 'padding-right', 'padding-top', 'position', 'right', 'table-layout', 'text-align', 'text-decoration', 'text-indent', 'top', 'vertical-align', 'visibility', 'white-space', 'width']
7390

74-
When you configure allowedStyleProps, the styles, which matches the ‘allowed style properties’ list are allowed, all other style properties will be removed on pasting the content in the editor.
91+
> This setting works only when `KeepFormat` is set to true. If `KeepFormat` is `false` or `PlainText` is `true`, style filtering via `AllowedStyleProps` will not be applied.
7592
7693
For Example,
7794

7895
`AllowedStyleProps: ['color', 'margin']'`: This will allow only the style properties ‘color’ and ‘margin’ in each pasted element.
7996

97+
In the following example, the paste cleanup related settings are explained with its module configuration:
98+
8099
{% if page.publishingplatform == "aspnet-core" %}
81100

82101
{% tabs %}
@@ -127,4 +146,4 @@ In the following example, the `AfterPasteCleanUp` event is configured to remove
127146
{% include code-snippet/rich-text-editor/paste-cleanup-customize/controller.cs %}
128147
{% endhighlight %}
129148
{% endtabs %}
130-
{% endif %}
149+
{% endif %}

0 commit comments

Comments
 (0)