Opened 10 years ago
Closed 9 years ago
#13271 closed Bug (invalid)
Issue with Select an Element in Safari Browser
Reported by: | Vahid | Owned by: | |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | Core : Selection | Version: | |
Keywords: | Cc: |
Description
Suppose we have following Code :
editor.getSelection().selectElement(element);
When you want to select and element by using this method (which in our case is current line in editor) , it works fine in all browsers except any version of Safari. Actually it looks like selecting two element/line instead of requested element.
Change History (4)
comment:1 Changed 10 years ago by
Keywords: | selectElement removed |
---|---|
Status: | new → pending |
comment:2 Changed 9 years ago by
Thanks for prompt response.
What I need do is , I create a range of Div tags using following code
var iterator = range.createIterator(); var element = iterator.getNextParagraph('div'); while(element != null) { elements.push(element); element = iterator.getNextParagraph('div'); } return elements;
and I need to go through every single element (Div) from elements collectionto apply a style on that like this :
editor.getSelection().selectElement(element); editor.getCommand(style).exec();
But in this case selectElement method is selecting two DiV in Safari, while in all other browsers it works fine.
comment:3 Changed 9 years ago by
Could you provide reduced and working HTML file that contains JS and HTML that shows this problem? (I'm talking about HTML page like the ones in samples folder).
It will be easier for us to investigate this issue when working with exactly same code that doesn't work for you.
comment:4 Changed 9 years ago by
Resolution: | → invalid |
---|---|
Status: | pending → closed |
comment:2 contains enough information. I guessed correctly that @CKEditorUser tries to select block elements and that's incorrect. You need to create range, use e.g. the range.selectNodeContents( element )
method and then select this range. Actually - you don't even need to select it - if you have the style definition you can use style.applyToRange()
.
What element you tried to select? I guess it was a block like paragraph or header. In such case the result may be different in all browsers because you tied to make an unrealistic selection. Normal blocks cannot be selected from outside using
selectElement()
. This method exists for images, tables, etc. But paragraph can be selected from inside only. You should do a selection which looks like this:Instead of this:
Because this will be changed by most browsers to:
Hence, two blocks selected.
Let us know if this is what you tried to do.