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

How to get the cursor between two closing tags?

1 Answer 36 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Cole
Top achievements
Rank 1
Cole asked on 04 Jun 2012, 07:43 PM
Hi, I have a strange problem that I cannot solve.  See this screen cast: http://screencast.com/t/SaskytTTX5V

As you'll notice I end up with two closing tags nested and butted up against each other, like so:

<p>Some <b>text</b></p>

The problem is that our customers get "stuck" in bold mode because there is no way they can get the cursor between the closing bold and closing paragraph tags without manually editing the HTML code. The screen cast was filmed using an up-to-date version of Chrome, but I think we see this problem in other browsers as well.

How can I get the cursor between those two closing tags?

Also, we have this issue when pasting in HTML from a custom toolbar button. How can I programmatically move the cursor between those two closing tags?  I've looked at many forum posts about using ranges to move the cursor, but none have helped me get in between the two closing tags.

Thanks in advance!

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 06 Jun 2012, 02:08 PM
Hi,

This is the default browser behavior when applying a command to the last word to not break the formatting until the user does not execute the formatting command once again as shown in the following video: http://screencast.com/t/pV0cvB5IW. The behavior can be reproduced in a standard editable div / iframe elements as in the attached page with an editable iframe in it.

My personal suggestion is to not handle this scenario with code, because you can instruct your users to click on the Bold, Italic, etc buttons once again and they will remove the formatting. Even more these buttons are highlighted (look pressed) when the cursor is over formatted content.

As to the range object of the browser. You can find information about it in this Wrox article: http://www.wrox.com/WileyCDA/Section/JavaScript-DOM-Ranges.id-292301.html. If you implement your scenario with the attached editable iframe page, send us the code and we will help you to integrate it in RadEditor.

Greetings,
Rumen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Editor
Asked by
Cole
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or