Opened 8 years ago

Closed 8 years ago

#8435 closed Bug (invalid)

IE 7/8 Cannot get text selection for the first time

Reported by: Wilfrid Li Owned by:
Priority: Normal Milestone:
Component: Core : Selection Version:
Keywords: Cc:

Description

There is a bug in the latest CKEditor release (3.6.2), where CKEditor cannot obtain the text selection (either selected via 'doubleclick' or 'mouse drag from A to B') under IE (either 7 or 8, not sure about 9 and 10). I managed to recreate the issue here: http://staging.clients.webling.com.au/Wilfrid/ckeditor/_samples/mytemplate.html

Select some text in the middle of the sentence, 'text' for example. Click on the yellow icon in the middle of the toolbars, it will open up an iframe dialog. Type in anything in the text box and click 'insert link'. If you debug the javascript, you'll see mySelection.getNative().createRange().text == ""

If you undo the changes in CKEditor and try to insert the text again on the same word, the selection will work as normal.

The following bug above applies to any text the user hasn't previously selected.

The test case files can be downloaded in the link below: http://staging.clients.webling.com.au/Wilfrid/ckeditor_3.6.2_IE_Selection_Test_Case.zip

Attachments (1)

testplugin.html (1.9 KB) - added by Jakub Ś 8 years ago.

Download all attachments as: .zip

Change History (4)

comment:1 Changed 8 years ago by Wilfrid Li

This bug is has caused one of my major project stalled for weeks now, can I get someone to give me a reply about this issue and if there's anyway to bypass this issue?

Thanks

comment:2 Changed 8 years ago by Wilfrid Li

I debugged the source code for CKEditor and have found a solution (I think):

When we call mySelection.unlock(true)

  • it calls the function 'unlock' in the 'selection' plugin
  • doc.getBody().focus(); [function 'unlock' - line 1312], eventually calls 'CKEDITOR.dom.range.prototype.select'
  • ieRange within 'CKEDITOR.dom.range.prototype.select' returned the appropriate selected text for the first time
  • However, when this.selectRanges(ranges) runs [function 'unlock' - line 1317], the code somehow tries to getSelection again through 'CKEDITOR.dom.range.prototype.select'
  • this created start/end bookmark right next to each other in the html and thus overwritten the first getSelection attempt made by 'doc.getBody().focus();'
  • removing line 1312 'doc.getBody().focus();' fixes the issue.
  • I'm not sure if that will break anything else though...

comment:3 Changed 8 years ago by Jakub Ś

Keywords: IE Selection Bug removed
Resolution: invalid
Status: newclosed
Version: 3.6.2

Have you tried to use getSelectedText() method? http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.dom.selection.html#getSelectedText

I had made some changes to your code and had no problems with getting the code to work as expected. Please see attachment.

Closing the ticket as invalid.

Last edited 8 years ago by Jakub Ś (previous) (diff)

Changed 8 years ago by Jakub Ś

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