This is a migrated thread and some comments may be shown as answers.

contenteditable="false" and Style Selector

2 Answers 70 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Darren
Top achievements
Rank 1
Darren asked on 28 Mar 2011, 07:29 PM
Hi,

Does anyone know of a way to prevent the style selector from being able to alter the style applied to a span which as the contenteditable="false" attribute set?  Eg, I have this html in the editor:

<span class="LockedContent" id="19" contenteditable="false" 
xml="LockedContent">Some locked content</span><BR><BR>
And when I select this in the editor, I can then change the style using the style editor, which I dont want to allow.

Any ideas appreciated!

thanks

2 Answers, 1 is accepted

Sort by
0
Dobromir
Telerik team
answered on 30 Mar 2011, 12:12 PM
Hi Darren,

You can prevent this behavior by handling the ClientCommandExecuting client-side event of RadEditor, examine the selected element and if it has contentEditable attribute set you can cancel further execution of the command by calling set_cancel(true), e.g.:
<telerik:RadEditor ID="RadEditor1" runat="server" OnClientCommandExecuting="OnClientCommandExecuting">
    <Content>
        <span class="LockedContent" id="19" contenteditable="false" xml="LockedContent">Some locked content</span>
    </Content>
</telerik:RadEditor>
 
<script type="text/javascript">
    function OnClientCommandExecuting(editor, args)
    {
        if (args.get_commandName() == "ApplyClass")
        {
            var selectedElem = editor.getSelectedElement();
 
            if(selectedElem.getAttribute("contenteditable").toLowerCase() == "false")
                args.set_cancel(true);
        }
    }
</script>


Greetings,
Dobromir
the Telerik team
0
Darren
Top achievements
Rank 1
answered on 30 Mar 2011, 02:30 PM
Hi Dobromir
thats a great solution, thanks a lot for the help!
Darren
Tags
Editor
Asked by
Darren
Top achievements
Rank 1
Answers by
Dobromir
Telerik team
Darren
Top achievements
Rank 1
Share this question
or