Hi,
I encounter an issue with range selection on Safari (whereas it works properly on Chrome).
I suspect this is a problem related to Safari.
Does someone can confirm me if this is a known problem ? If yes, is there a work-around for that ?
Basically, my goal is to select the whole paragraph that embeds the cursor position to replace it by a widget.
Here is an illustration.
With this initial state :
<p>^Some text</p>
I want to have this selection :
[<p>Some text</p>]
It is what I get on Chrome, but with Safari I get this :
<p>[Some text]</p>
To to this I wrote this code :
var range = editorInstance.getSelection().getRanges()[0]; // p here is the paragraph element range.setStartBefore(p); range.setEndAfter(p); editorInstance.getSelection().selectRanges([range]);
Thanks for your help.
It doesn't work on Safari,
It doesn't work on Safari, because Safari does not support such selections. Webkit will always move selection boundaries to the closest text nodes.
Blink does not support such selections as well, but it does pretend to support them. It will tell you that you selected [<p>x</p>], but it's only a virtual success - whatever you do (type, delete, navigate) Blink will perform the normalisation as Webkit.
This is a symptom of a very ugly bug that Webkit and Blink have for years:
BTW. It doesn't really make sense to select the paragraph from outside and you should avoid that. It may lead to problems, like if user presses the left arrow key, then the selection is placed outside the paragraph.
Piotrek (Reinmar) Koszuliński
CKEditor JavaScript Developer
--
CKSource - http://cksource.com
--
Follow CKEditor on: Twitter | Facebook | Google+
Thank you Piotrek for this
Thank you Piotrek for this answer. You confirm what I thought.
This selection is just an intermediary process.
To give more insight of what I'm trying to do I post a screenshot of our application that embeds CKEditor.
We have developed a widget for creating "annotated block".
An annotated block is rendered with the tags that has been associated to is content.
The plugin is downcasted using a microdata representation.
Our goal is to facilitate the semantic annotation of a document.
Technically, what we do when initializing the widget is :
Do you think this not the right approach to do this ?
Many thanks
Attachments: