Opened 3 years ago

Closed 2 years ago

#11948 closed Bug (invalid)

No range in selection after inline editor init

Reported by: m.lewandowski Owned by:
Priority: Normal Milestone:
Component: General Version: 4.0 Beta
Keywords: Cc:

Description

Seems that inline editor does not create a (collapsed) range after its (editor) initialization, like it does in case of classic editor. As a result commands, which expects to have a range, will throw exceptions and work incorrectly.

  1. open any sample with CKEditor in inline / divarea mode (i.e. samples/inlineall.html)
  2. evaluate following code in JavaScript console:
    CKEDITOR.instances.editor1.getSelection().getRanges().length
    

Expected result:
1

Current result:
0

A simple UC which causes the problem would be inserting a link to editor:

  1. open sample page with editor
  2. execute following code in JavaScript console:
    CKEDITOR.instances.editor1.execCommand( 'link' )
    
  3. fill URL field with some random domain
  4. click ok

Expected result:
link should be inserted to the editor

Current result:
exception is thrown: Uncaught TypeError: Cannot read property 'collapsed' of undefined

or FF: TypeError: range is undefined

Tested in: Chrome, FF

Change History (4)

comment:1 Changed 3 years ago by m.lewandowski

  • Summary changed from Seems that inline editor does not create a (collapsed) range after its (editor) initialization, like it does in case of classic editor. As a result commands, which expects to have a range, will throw exceptions and work incorrectly. 1. open any sample with CKEditor in **inline / divarea** mode (i.e. samples/inlineall.html) 2. evaluate following code in JavaScript console: {{{ CKEDITOR.instances.editor1.getSelection().getRanges().length }}} '''Expected result:'''[[BR]] 1 '''Current result:'''[[BR]] 0 A simple UC which causes the problem would be inserting a link to editor: 1. open sample page with editor 2. execute following code in JavaScript console: {{{ CKEDITOR.instances.editor1.execCommand( 'link' ) }}} 3. fill URL field with some random domain 4. click ok '''Expected result:'''[[BR]] link should be inserted to the editor '''Current result:'''[[BR]] exception is thrown: {{{Uncaught TypeError: Cannot read property 'collapsed' of undefined}}} or FF: {{{TypeError: range is undefined}}} Tested in: Chrome, FF to No range in selection after inline editor init

comment:2 Changed 3 years ago by j.swiderski

  • Status changed from new to confirmed
  • Version set to 4.0 Beta

Problem can be reproduced from CKEditor 4.0 beta in every browser.

comment:3 Changed 3 years ago by Reinmar

It think that it's a bug in link plugin rather than a general think. Link plugin should focus editor before it inserts anything.

comment:4 Changed 2 years ago by Reinmar

  • Resolution set to invalid
  • Status changed from confirmed to closed

Actually, it's not a bug that there's no selection in an editor. It's absolutely natural. Therefore, every feature which needs selection must assure that it exists or that it aborts when there's no selection. The link button for instance works just fine - apparently at some point editable is focused.

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