Opened 3 years ago

Closed 3 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 3 years ago by Piotrek Koszuliński

Keywords: selectElement removed
Status: newpending

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:

<p>foo</p>
<p>[abc]</p>
<p>foo</p>

Instead of this:

<p>foo</p>
[<p>abc</p>]
<p>foo</p>

Because this will be changed by most browsers to:

<p>foo</p>
<p>[abc</p>
<p>]foo</p>

Hence, two blocks selected.

Let us know if this is what you tried to do.

comment:2 Changed 3 years ago by Vahid

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 3 years ago by Jakub Ś

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 3 years ago by Piotrek Koszuliński

Resolution: invalid
Status: pendingclosed

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().

Note: See TracTickets for help on using tickets.
© 2003 – 2017 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy