contenteditable="false" and Style Selector

3 posts, 0 answers
  1. Darren
    Darren avatar
    6 posts
    Member since:
    Apr 2008

    Posted 28 Mar 2011 Link to this post

    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. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 30 Mar 2011 Link to this post

    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
  3. Darren
    Darren avatar
    6 posts
    Member since:
    Apr 2008

    Posted 30 Mar 2011 Link to this post

    Hi Dobromir
    thats a great solution, thanks a lot for the help!
    Darren
Back to Top