Completed
Last Updated: 07 Jun 2016 08:38 by ADMIN
ADMIN
Ianko
Created on: 01 Sep 2014 10:46
Category: UI for ASP.NET AJAX
Type: Feature Request
0
ADD: A new StripFormattingOptions option that handles MS Word content with list elements under IE11
Under IE11 the pasting from Word is handled natively by the browser. When pasting content with list element, the list items are pasted with paragraphs inside.

This behavior is W3C compliant, but when it comes to editable content, such scenario causes inappropriate behavior of the tools interacting with the block elements. E.g., a paragraph in a list item cannot be considered as list item, and the tools will not be able to modify the list item. On other side, if a paragraph is considered as list item, any paragraph formatting commands will affect the paragraph, and not the list.

A suitable behavior would be to handle the paragraphs and transform them to span or br elements to keep correct formatting, and the list, indent, outdent and other block commands to interact correctly with the Editor content.

The following paste event handler transforms the paragraphs to span elements:

<telerik:RadEditor runat="server" ID="RadEditor1" OnClientPasteHtml="OnClientPasteHtml"></telerik:RadEditor>

<script type="text/javascript">
    function OnClientPasteHtml(editor, args) {
        var cleanContent = args.get_value(),
            regexp = /(<li.+)(<p)(.+)(<\/p)(.+)/gi,
            replaceString = "$1<span$3</span$5";

        while (cleanContent.match(regexp)) {
            cleanContent = cleanContent.replace(regexp, replaceString)
        }

        args.set_value(cleanContent);
    }
</script>
0 comments