Approved
Last Updated: 06 Jul 2018 12:33 by ADMIN
ADMIN
Rumen
Created on: 06 Jul 2018 12:15
Category: Editor
Type: Bug Report
0
The FormatBlock tool does not remove the class/style attributes
We have an issue with paragraph styles which have some custom classes.
It has different behavior depending on how you select your paragraph.
In some cases, when you fully select your paragraph the class remains the same the previous paragraph.
Please see the video of issue reproducing on the Telerik demo for more details:
https://www.screencast.com/t/xg9b1imVO

Workaround:
<script type="text/javascript">
    function OnClientCommandExecuting(editor, args) {
        //The command name   
        var commandName = args.get_commandName();
        //The tool that initiated the command   
        if (commandName == "FormatBlock") {
            //editor.get_document().execCommand("FormatBlock", false, "div");
            var selectedElement = editor.getSelectedElement();
            if (selectedElement.getAttribute("style")) {
                selectedElement.removeAttribute("style");
            }
            else if (selectedElement.getAttribute("class")) {
                selectedElement.removeAttribute("class");
            }
        }
    }
</script>
<telerik:RadEditor RenderMode="Lightweight" runat="server" ID="RadEditor1" ToolsFile="Tools.xml" Width="800px" OnClientCommandExecuting="OnClientCommandExecuting">
    <Content>
            some plain text
    </Content>
    <CssFiles>
        <telerik:EditorCssFile Value="Styles.css" />
    </CssFiles>
</telerik:RadEditor>
0 comments