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

RadEditor - issue with lists and links in IE

3 Answers 67 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Marco
Top achievements
Rank 1
Marco asked on 30 Mar 2011, 09:50 PM
Hi there,

We have an issue on a site that I was also able to recreate on a Telerik demo site, http://demos.telerik.com/aspnet-ajax/editor/examples/default/defaultcs.aspx.

In IE: If you paste in the folowing code:

<ul>
    <li><a href="AAA http://www.telerik.com/purchase">AAA</a></li>
    <li><a href="DDD https://www.telerik.com/login.aspx">DDD</a></li>
    <li><a href="FFF http://www.telerik.com/community">FFF</a></li>
    <li><a href="SSS http://www.telerik.com/support">SSS</a></li>
</ul>

into the HTML view, switch to design view, add a new list item (add a space somewhere in the middle of the new text if possible), select the list item (all text in item), it will select the text as well as one more character to the right. Make this text a link either by the link manager or the custom links drop-down. If you go to the HTML view, you see the code gets mangled because it selected that one character to the right, which I'm sure id the closing LI tag. If you do not select the last character it works fine, but it is very unintuitive and we could never tell our clients to check for the selection of that last character. Is this something you are working on, is fixed in a version soon to be released, or fixable with a config/tool XML file change? Any help would be so greatly appreciated.

Thanks so much,

Marco Andrade

3 Answers, 1 is accepted

Sort by
0
Dobromir
Telerik team
answered on 31 Mar 2011, 10:49 AM
Hi Marco,

We are aware of this issue and are working on its fix.

As you suspected the reason for this problem to occur is because the selection includes the <li> as well. The root of the problem is that the mouse selection is not very accurate and the browser's default RichTextEditing engine selects the element wrapping the text as well. Unfortunately, I am unable to provide a firm estimate for when the fix will be available. For the time being you can use the following workaround:
<telerik:RadEditor ID="RadEditor1" runat="server" OnClientCommandExecuting="OnClientCommandExecuting">
</telerik:RadEditor>
 
<script type="text/javascript">
    function OnClientCommandExecuting(editor, args)
    {
        if ($telerik.isIE && !$telerik.isIE9 && args.get_commandName() == "LinkManager")
        {
 
            var range = editor.getSelection().getRange();
            var selectedElement = editor.getSelectedElement();
 
            if(selectedElement.tagName == "LI")
            {
                range.findText(range.text);
                editor.getSelection().selectRange(range);
            }
        }
    }
</script>


Kind regards,
Dobromir
the Telerik team
0
Marco
Top achievements
Rank 1
answered on 31 Mar 2011, 03:19 PM
Thanks so much! Below is code I modified in case it helps anyone else, catches more issues like selecting text and pasting, using the custom links box, etc.:

function OnClientCommandExecuting(editor, args)
{
    if($telerik.isIE && !$telerik.isIE9 && (args.get_commandName() == "InsertCustomLink" || args.get_commandName() == "LinkManager" || args.get_commandName() == "DocumentManager" || args.get_commandName().indexOf('Paste') > -1))
    {
        var range = editor.getSelection().getRange();
        var selectedElement = editor.getSelectedElement();
   
        if(selectedElement.tagName == "LI")
        {
            range.findText(range.text);
            editor.getSelection().selectRange(range);
        }
    }
}
0
Matz
Top achievements
Rank 1
answered on 22 Jun 2011, 02:42 PM
Seems to be the same if you select text with <p>-tag round it. So I changed some of the code to
if(selectedElement.tagName == "LI" || selectedElement.tagName == "P")
Tags
Editor
Asked by
Marco
Top achievements
Rank 1
Answers by
Dobromir
Telerik team
Marco
Top achievements
Rank 1
Matz
Top achievements
Rank 1
Share this question
or