Pending Review
Last Updated: 28 Nov 2019 10:40 by ADMIN

On Google Chrome, the following assingment ends up displaying the body of the html twice within the editor:

radEditor.Content="<HTML><HEAD><STYLE>@import url(./CSS/CI.css);</STYLE></HEAD><BODY><H3>OUTPUT LAYOUT</H3><P>First Name:</P><P>Kerry</P></BODY></HTML>"

The resulting html becomes:
"<html><head><link href="/WebResource.axd?d=IgLlf5SIEZ-4m-Qr1qYVOGbMUL9-osMaMQXxs1c-ODIbmiiieGrgJ2ZuegoRNaCpJJ5zKojqJuk_FD7Cb69kb713UUGq1dCMsrFtihWFgnKkbYnlqQv7Lo2rUoUhmXHopZnTw7Cs3STs4GHdRuMnVHVdYHhRrcdV8Dgdv-U213Y1&amp;t=637050242483188892" type="text/css" id="RADEDITORSTYLESHEET0" rel="stylesheet"></head><body><h3>OUTPUT LAYOUT</h3><p>First Name:</p><p>Kerry</p><h3>OUTPUT LAYOUT</h3><p>First Name:</p><p>Kerry</p></body></html>"

The issue is the "@import url(./CSS/CI.css);" within the Style tag, if the @import url, is removed, then it works as expected.

Works as expected on IE11.

If you add 2 <style> tags, the second one is displayed twice within the editor:

radEditor.Content = "<HTML><HEAD></HEAD><BODY><H3>OUTPUT LAYOUT</H3><P>First Name:</P><P>Kerry</P><style>@import url(\"./CSS/CI.css\");</style><style>@import url(\"./CSS/CI2.css\");</style></BODY></HTML>";
  
Pending Review
Last Updated: 25 Jun 2018 09:44 by ADMIN
Repro steps: 
- use the editor below and the attached Word document in the archive at the end
- copy the document content in the editor
- clean the word formatting
- select some of the content (e.g., one paragraph)
- click the format stripper dropdown and choose Strip Span Elements
- run get_html(true) in the console

Expected: spans are stripped only from the selected content

Actual: nothing is stripped. Changing to HTML mode and back to Design fixes this, so you should not use that to check the HTML

        <telerik:RadEditor RenderMode="Lightweight" runat="server" ID="RadEditor1">
            <Tools>
                <telerik:EditorToolGroup>
                    <telerik:EditorTool Name="FormatStripper" />
                </telerik:EditorToolGroup>
            </Tools>
        </telerik:RadEditor>


WORKAROUNDS:

For the majority of cases you can set up automatic stripping of span elements when pasting from Word, so your users do not need to do that themselves. Here is an example:

<telerik:RadEditor RenderMode="Lightweight" runat="server" ID="RadEditor1"
    StripFormattingOptions="ConvertWordLists, MSWordNoMargins, Span">
    <Tools>
        <telerik:EditorToolGroup>
            <telerik:EditorTool Name="FormatStripper" />
        </telerik:EditorToolGroup>
    </Tools>
</telerik:RadEditor>

You can read more on how stripping MS Word content works in the following demo, and play around with the various options to see what works best for your case: http://demos.telerik.com/aspnet-ajax/editor/examples/cleaningwordformatting/defaultcs.aspx and in the following documentation article: https://docs.telerik.com/devtools/aspnet-ajax/controls/editor/managing-content/pasting-content/clean-ms-word-formatting

There are also two possible code workarounds so advanced users can retain more control over the HTML without switching to the HTML mode themselves.
The second is likely to be a tad faster with large content, but the first is likely to produce better user experience.

1) this changes the mode to HTML and back to design with each paste so that the stripping tool can work with the selection


<telerik:RadEditor RenderMode="Lightweight" runat="server" ID="RadEditor1"
     OnClientCommandExecuted="OnClientCommandExecuted">
    <Tools>
        <telerik:EditorToolGroup>
            <telerik:EditorTool Name="FormatStripper" />
        </telerik:EditorToolGroup>
    </Tools>
</telerik:RadEditor>
<script>
    function OnClientCommandExecuted(sender, args) {
        if (args.get_commandName() == "Paste") {
            sender.set_mode(2);
            setTimeout(function () {
                sender.set_mode(1);
            }, 50);
        }
    }
</script>

2) this one is a workaround that allows the stripping tool to work without mode change, but it will not operate with the selection but with all the content


<telerik:RadEditor RenderMode="Lightweight" runat="server" ID="RadEditor1"
     OnClientCommandExecuting="OnClientCommandExecuting">
    <Tools>
        <telerik:EditorToolGroup>
            <telerik:EditorTool Name="FormatStripper" />
        </telerik:EditorToolGroup>
    </Tools>
</telerik:RadEditor>
<script>
    function OnClientCommandExecuting(sender, args) {
        if (args.get_commandName() == "StripSpan") {
            sender.set_html(sender.get_html(true));
        }
    }
</script>