Skip to content

Commit 1e9434e

Browse files
authored
Merge pull request #6885 from syncfusion-content/985781-paste-d
985781: Paste cleanup documentation improvement for blazor
2 parents f2db679 + 2ef43c2 commit 1e9434e

File tree

1 file changed

+38
-13
lines changed

1 file changed

+38
-13
lines changed

blazor/rich-text-editor/paste-cleanup.md

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,24 @@ When pasting content into the editor, you can control the formatting and styles
1717

1818
| API | Description | Default Value | Type |
1919
|:----------------:|:---------:|:-----------------------------:|:---------:|
20-
| [Prompt](#prompt-dialog) | To invoke prompt dialog with paste options on pasting the content in editor. | false | boolean |
21-
| [PlainText](#paste-as-plain-text) | To paste the content as plain text. | false | boolean |
22-
| [KeepFormat](#keep-format) | To keep the same format with copied content. | true | boolean |
23-
| [DeniedTags](#denied-tags) | To ignore the tags when pasting HTML content. | null | string[] |
24-
| [DeniedAttributes](#denied-attributes) | To paste the content by filtering out these attributes from the content. | null | string[] |
25-
| [AllowedStyleProperties](#allowed-style-properties) | To paste the content by accepting these style attributes and removing other style attributes. | [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[] |
20+
| [Prompt](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.RichTextEditor.RichTextEditorPasteCleanupSettings.html#Syncfusion_Blazor_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 |
21+
| [PlainText](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.RichTextEditor.RichTextEditorPasteCleanupSettings.html#Syncfusion_Blazor_RichTextEditor_RichTextEditorPasteCleanupSettings_PlainText) | To paste the content as plain text. | false | boolean |
22+
| [KeepFormat](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.RichTextEditor.RichTextEditorPasteCleanupSettings.html#Syncfusion_Blazor_RichTextEditor_RichTextEditorPasteCleanupSettings_KeepFormat) | To keep the same format with copied content. | true | boolean |
23+
| [DeniedTags](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.RichTextEditor.RichTextEditorPasteCleanupSettings.html#Syncfusion_Blazor_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[] |
24+
| [DeniedAttributes](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.RichTextEditor.RichTextEditorPasteCleanupSettings.html#Syncfusion_Blazor_RichTextEditor_RichTextEditorPasteCleanupSettings_DeniedAttributes) | Filters out specified attributes from the pasted content | null | string[] |
25+
| [AllowedStyleProperties](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.RichTextEditor.RichTextEditorPasteCleanupSettings.html#Syncfusion_Blazor_RichTextEditor_RichTextEditorPasteCleanupSettings_AllowedStyleProperties) | To paste the content by accepting these style attributes and removing other style attributes. | [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[] |
2626

2727
## Prompt dialog options
2828

2929
When [Prompt](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.RichTextEditor.RichTextEditorPasteCleanupSettings.html#Syncfusion_Blazor_RichTextEditor_RichTextEditorPasteCleanupSettings_Prompt) is set to true, pasting the content in the editor opens a dialog box with three options as radio buttons: keep, clean, and plain text.
3030

31+
![Blazor RichTextEditor with prompt](./images/blazor-richtexteditor-paste-prompt.png)
32+
3133
1. `Keep`: To keep the same format with copied content.
3234
2. `Clean`: To clear all the style formats with copied content.
3335
3. `Plain Text`: To paste the copied content as plain text without any formatting or style (including the removal of all tags).
3436

35-
N> When the `Prompt` value is set to true, the API properties [PlainText](#paste-as-plain-text) and [KeepFormat](#keep-format) will not be considered for processing when pasting the content.
37+
N> When the `Prompt` value is set to true, the API properties [PlainText](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.RichTextEditor.RichTextEditorPasteCleanupSettings.html#Syncfusion_Blazor_RichTextEditor_RichTextEditorPasteCleanupSettings_PlainText) and [KeepFormat](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.RichTextEditor.RichTextEditorPasteCleanupSettings.html#Syncfusion_Blazor_RichTextEditor_RichTextEditorPasteCleanupSettings_KeepFormat) will not be considered for processing when pasting the content.
3638

3739
{% tabs %}
3840
{% highlight razor %}
@@ -42,13 +44,11 @@ N> When the `Prompt` value is set to true, the API properties [PlainText](#paste
4244
{% endhighlight %}
4345
{% endtabs %}
4446

45-
![Blazor RichTextEditor with prompt](./images/blazor-richtexteditor-paste-prompt.png)
46-
4747
## Paste as plain text
4848

4949
When [PlainText](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.RichTextEditor.RichTextEditorPasteCleanupSettings.html#Syncfusion_Blazor_RichTextEditor_RichTextEditorPasteCleanupSettings_PlainText) is set to true, the copied content will be converted to plain text by removing all the HTML tags and styles applied to it, and only the plain text is pasted in the editor.
5050

51-
N> When `PlainText` value is set true, the API property [Prompt](#prompt-dialog) should be set to false, and [KeepFormat](#keep-format) will not be considered for processing when pasting the content.
51+
N> When `PlainText` value is set true, the API property [Prompt](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.RichTextEditor.RichTextEditorPasteCleanupSettings.html#Syncfusion_Blazor_RichTextEditor_RichTextEditorPasteCleanupSettings_Prompt) should be set to false, and [KeepFormat](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.RichTextEditor.RichTextEditorPasteCleanupSettings.html#Syncfusion_Blazor_RichTextEditor_RichTextEditorPasteCleanupSettings_KeepFormat) will not be considered for processing when pasting the content.
5252

5353
{% tabs %}
5454
{% highlight razor %}
@@ -62,11 +62,13 @@ N> When `PlainText` value is set true, the API property [Prompt](#prompt-dialog)
6262

6363
## Keep format
6464

65-
When [KeepFormat](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.RichTextEditor.RichTextEditorPasteCleanupSettings.html#Syncfusion_Blazor_RichTextEditor_RichTextEditorPasteCleanupSettings_KeepFormat) is set to true, the copied content will maintain all the style formatting allowed in the [AllowedStyleProperties](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.RichTextEditor.RichTextEditorPasteCleanupSettings.html#Syncfusion_Blazor_RichTextEditor_RichTextEditorPasteCleanupSettings_AllowedStyleProperties) when pasting the content in the editor.
65+
When [KeepFormat](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.RichTextEditor.RichTextEditorPasteCleanupSettings.html#Syncfusion_Blazor_RichTextEditor_RichTextEditorPasteCleanupSettings_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 `AllowedStyleProperties`, `DeniedTags`, and `DeniedAttrs` settings:
6666

67-
When `KeepFormat` is set to false, the style in the copied content will be removed without considering the allowed styles in the `AllowedStyleProperties` when pasting the content in the editor.
67+
* Only the style properties listed in `AllowedStyleProperties` will be preserved.
68+
* Any HTML tags listed in `DeniedTags` will be removed.
69+
* Any attributes listed in `DeniedAttrs` will be stripped from the pasted content.
6870

69-
N> When the `KeepFormat` value is set to true, the API properties [Prompt](#prompt-dialog) and [PlainText](#paste-as-plain-text) should be set to false.
71+
This ensures that while the formatting is retained, it remains clean, safe, and consistent with your application's styling rules.
7072

7173
{% tabs %}
7274
{% highlight razor %}
@@ -78,6 +80,19 @@ N> When the `KeepFormat` value is set to true, the API properties [Prompt](#prom
7880

7981
![Blazor RichTextEditor with keep format](./images/blazor-richtexteditor-paste-keep-format.gif)
8082

83+
>When `KeepFormat` is set to true, set both `Prompt` and `PlainText` to false.
84+
85+
## Clean formating
86+
87+
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.
88+
89+
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:
90+
91+
- **`DeniedTags`**: Tags listed here will still be removed from the pasted content.
92+
- **`DeniedAttrs`**: Attributes listed here will also be stripped from the pasted content.
93+
94+
> The `AllowedStyleProps` setting only applies if `KeepFormat` is enabled.
95+
8196
## Denied tags
8297

8398
The [DeniedTags](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.RichTextEditor.RichTextEditorPasteCleanupSettings.html#Syncfusion_Blazor_RichTextEditor_RichTextEditorPasteCleanupSettings_DeniedTags) specify the tags to restrict when pasting the content into the Rich Text Editor.
@@ -96,6 +111,9 @@ The [DeniedTags](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.RichTe
96111

97112
![Blazor RichTextEditor with denied tags](./images/blazor-richtexteditor-paste-denied-tag.gif)
98113

114+
> This setting is ignored when `PlainText` is set to `true`. <br>
115+
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.
116+
99117
## Denied attributes
100118

101119
The [DeniedAttributes](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.RichTextEditor.RichTextEditorPasteCleanupSettings.html#Syncfusion_Blazor_RichTextEditor_RichTextEditorPasteCleanupSettings_DeniedAttributes) property specifies the attributes to restrict when pasting the content into the Rich Text Editor.
@@ -110,8 +128,13 @@ The [DeniedAttributes](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.R
110128

111129
![Blazor RichTextEditor with denied attribute](./images/blazor-richtexteditor-paste-denied-attribute.png)
112130

131+
> This setting is ignored when `PlainText` is set to `true`. <br>
132+
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.
133+
113134
## Allowed style properties
114135

136+
By default, a predefined set of basic style properties are allowed when content is pasted into the Rich Text Editor.
137+
115138
When you configure `AllowedStyleProperties`, only the styles that match the allowed style properties list are allowed. All other style properties will be removed on pasting the content into the editor.
116139

117140
For Example, **public string[] AllowedStyles = new string[] { "color", "margin" };** This will allow only the style properties 'color' and 'margin' in each pasted element.
@@ -126,6 +149,8 @@ For Example, **public string[] AllowedStyles = new string[] { "color", "margin"
126149

127150
![Blazor RichTextEditor with allowed styles](./images/blazor-richtexteditor-paste-allowed-style.png)
128151

152+
> This setting works only when `KeepFormat` is set to true. If `KeepFormat` is `false` or `PlainText` is `true`, style filtering via `AllowedStyleProperties` will not be applied.
153+
129154
## Pasting large text content
130155

131156
When pasting a large text into the editor it displays `Attempting to reconnect` and then the text gets inserted. To achieve this, you can increase the SignalR size at the application level by adding the `signalR` method with a larger buffer size(1024000000).

0 commit comments

Comments
 (0)