Opened 10 years ago

Closed 9 years ago

#11948 closed Bug (invalid)

No range in selection after inline editor init

Reported by: Marek 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 10 years ago by Marek Lewandowski

Summary: 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, FFNo range in selection after inline editor init

comment:2 Changed 10 years ago by Jakub Ś

Status: newconfirmed
Version: 4.0 Beta

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

comment:3 Changed 10 years ago by Piotrek Koszuliński

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

Resolution: invalid
Status: confirmedclosed

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 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy