Opened 9 years ago

Last modified 9 years ago

#14634 confirmed Bug

getSelectedText omits <br> characters in IE

Reported by: RHabib Owned by:
Priority: Normal Milestone:
Component: General Version: 3.6.1
Keywords: IE Cc:

Description

Steps to reproduce

  1. Enter following text in CKEditor in IE 11

line 1
line 2
line 3

  1. select text and In JS call
    CKEDITOR.instances[yourid].getSelection().getSelectedText()
    
  1. The returned text is "line 1line 2line 3"
  2. The length of string is 18. While in chrome it is 21

Expected result

The returned text should have \n characters

Actual result

The returned text is "line 1line 2line 3" The length of string is 18. While in chrome it is 21

Other details (browser, OS, CKEditor version, installed plugins)

Chrome: The returned text is "line 1\nline 2\nline 3"
IE11: The returned text is "line 1line 2line 3"

Change History (1)

comment:1 Changed 9 years ago by Jakub Ś

Keywords: IE added
Status: newconfirmed
Version: 4.4.73.6.1

Problem can be reproduced in IE browsers from CKEditor 3.6.1 (when getSelectedText was introduced).

This method uses native selection methods and in IE something like below is executed:

console.log(CKEDITOR.instances.editor1.document.getSelection()._.cache.nativeSel.toString());

This can be simplified to:

// Get native selection and change it to string
console.log(CKEDITOR.instances.editor1.window.$.getSelection().toString());

It looks like the native toString() method for native selection returns text without line breaks.

This will require some research but from what I have checked for this test case a much better would be using focusNode.innerText which returns text with line breaks.

console.log(CKEDITOR.instances.editor1.window.$.getSelection().focusNode.innerText);
Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy