Define a subset of HTML

Is it possible to limit the html to a specific set of tags

<div>,<font>,<strong>,<em>,<u>,<ol>,<ul>,<li>,<blockquote>


The intention is to apply a rich text format that is compatible with MS Access Rich text fields.
Details Here:
https://support.microsoft.com/en-us/office/create-or-delete-a-rich-text-field-9f86237d-dbbc-4a85-b12c-9d8dca824630?ocmsassetid=ha010014097&correlationid=93686114-d3c0-46eb-a703-f89a1bd2ce93&ui=en-us&rs=en-us&ad=us


5 Replies

VJ Vinitha Jeyakumar Syncfusion Team July 12, 2022 02:29 PM UTC

Hi Daniel,


While pasting the contents into the Rich Text Editor, we can restrict the paste actions based on the DeniedTags property, the tags that matches the ‘denied tags’ list will be removed on pasting the copied content in the editor.

Code snippet:
<SfRichTextEditor><RichTextEditorPasteCleanupSettings DeniedTags="@DeniedTag" /></SfRichTextEditor>@code {private string[] DeniedTag = new string[] { "a", "a[!rel='nofollow' href]" };}



If you want to limit the set of HTML tags to be allowed in the Rich Text Editor, you can limit the toolbar items based on your requirement. You can also do Enter key and Shift Enter key customization with the help of the ShiftEnterKey and EnterKey property as like below,

Code snippet:
<SfRichTextEditor EnterKey="EnterKeyTag.DIV" ShiftEnterKey="ShiftEnterKeyTag.DIV">
    <RichTextEditorToolbarSettings Items="@Tools"  />
    <RichTextEditorPasteCleanupSettings DeniedTags="@DeniedTag" />
   
</SfRichTextEditor>

@code {
    private string[] DeniedTag = new string[] { "a", "a[!rel='nofollow' href]", "img" };
     private List<ToolbarItemModel> Tools = new List<ToolbarItemModel>()
    {
        new ToolbarItemModel() { Command = ToolbarCommand.Bold },
        new ToolbarItemModel() { Command = ToolbarCommand.Italic },
         new ToolbarItemModel() { Command = ToolbarCommand.Separator },
        new ToolbarItemModel() { Command = ToolbarCommand.FontColor },
        new ToolbarItemModel() { Command = ToolbarCommand.BackgroundColor },
        new ToolbarItemModel() { Command = ToolbarCommand.Separator },
        new ToolbarItemModel() { Command = ToolbarCommand.Formats },
        new ToolbarItemModel() { Command = ToolbarCommand.Alignments },        new ToolbarItemModel() { Command = ToolbarCommand.Separator },        new ToolbarItemModel() { Command = ToolbarCommand.OrderedList },        new ToolbarItemModel() { Command = ToolbarCommand.UnorderedList },
        new ToolbarItemModel() { Command = ToolbarCommand.Separator },
        new ToolbarItemModel() { Command = ToolbarCommand.Separator }           new ToolbarItemModel() { Command = ToolbarCommand.Separator },
        new ToolbarItemModel() { Command = ToolbarCommand.Undo },
        new ToolbarItemModel() { Command = ToolbarCommand.Redo }
    };
}



Regards,
Vinitha


DR Daniel Reibelt July 12, 2022 09:15 PM UTC

THanks, an option for allowed tags would be cleaner... The denied list would be huge...


 Future feature perhaps?





BS Buvana Sathasivam Syncfusion Team July 14, 2022 02:08 AM UTC

Hi Daniel,


We let you know that the SfRichTextEditor denied tags are supported only for paste actions. Could you please share more information about your requirements for your use case, such as whether you want to allow tag support only on paste actions?


Regards,

Buvana S



DR Daniel Reibelt July 14, 2022 02:20 AM UTC

I know this is not exactly the answer to your question, but the scenario exists where users enter values via MS Access database, and these values can be exposed and edited via a web interface. My goal is to make sure that when a user edits an existing value, or creates a new value, in the web interface that this data remains consistent when viewed again in MS Access. This may also include pasting data as well as updates.

If tags are entered that MS access does not support, then this displays as raw html in MS Access application which I must avoid, as these fields can be used to generate content that is exposed to customers ( invoices etc)

Hope that makes sense. 




VJ Vinitha Jeyakumar Syncfusion Team July 14, 2022 12:23 PM UTC

Hi Daniel,


We have considered your requirement "Provide support for AllowedTags property in the Rich Text Editor " as a feature from our end and it will be included in any of our upcoming releases.

Now you can track the status of the reported feature through the below feedback link,

Regards,
Vinitha

Loader.
Up arrow icon