Opened 11 years ago
Closed 10 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.
- open any sample with CKEditor in inline / divarea mode (i.e. samples/inlineall.html)
- 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:
- open sample page with editor
- execute following code in JavaScript console:
CKEDITOR.instances.editor1.execCommand( 'link' )
- fill URL field with some random domain
- 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 11 years ago by
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, FF → No range in selection after inline editor init |
---|
comment:2 Changed 11 years ago by
Status: | new → confirmed |
---|---|
Version: | → 4.0 Beta |
comment:3 Changed 11 years ago by
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 10 years ago by
Resolution: | → invalid |
---|---|
Status: | confirmed → 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.
Problem can be reproduced from CKEditor 4.0 beta in every browser.