This repository has been archived by the owner on Jun 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1244 from ckeditor/t/ckeditor5/721
Fix: Fixed a bug where Firefox would throw an `NS_ERROR_FAILURE` error when moving selection from a nested editable to the root editable. Closes ckeditor/ckeditor5#721.
- Loading branch information
Showing
4 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<style> | ||
.ck-widget { | ||
border: solid 3px blue; | ||
} | ||
</style> | ||
|
||
<div id="editor"> | ||
<p>This is an <strong>editor</strong> instance.</p> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/** | ||
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md. | ||
*/ | ||
|
||
/* globals console, window, document */ | ||
|
||
import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor'; | ||
import Essentials from '@ckeditor/ckeditor5-essentials/src/essentials'; | ||
import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph'; | ||
import Bold from '@ckeditor/ckeditor5-basic-styles/src/bold'; | ||
import { toWidget } from '@ckeditor/ckeditor5-widget/src/utils'; | ||
import Widget from '@ckeditor/ckeditor5-widget/src/widget'; | ||
|
||
import AttributeContainer from '../../../../src/view/attributeelement'; | ||
import ViewContainer from '../../../../src/view/containerelement'; | ||
import { downcastElementToElement } from '../../../../src/conversion/downcast-converters'; | ||
import { setData } from '../../../../src/dev-utils/model'; | ||
import ViewEditable from '../../../../src/view/editableelement'; | ||
|
||
ClassicEditor | ||
.create( document.querySelector( '#editor' ), { | ||
plugins: [ Essentials, Paragraph, Bold, Widget ], | ||
toolbar: [ 'undo', 'redo' ] | ||
} ) | ||
.then( editor => { | ||
window.editor = editor; | ||
|
||
const model = editor.model; | ||
|
||
model.schema.register( 'widget', { | ||
inheritAllFrom: '$block', | ||
isObject: true | ||
} ); | ||
|
||
model.schema.extend( '$text', { | ||
allowIn: 'nested' | ||
} ); | ||
|
||
model.schema.register( 'nested', { | ||
allowIn: 'widget', | ||
isLimit: true | ||
} ); | ||
|
||
editor.conversion.for( 'downcast' ) | ||
.add( downcastElementToElement( { | ||
model: 'widget', | ||
view: () => { | ||
const b = new AttributeContainer( 'b' ); | ||
const div = new ViewContainer( 'div', null, b ); | ||
|
||
return toWidget( div, { label: 'element label' } ); | ||
} | ||
} ) ) | ||
.add( downcastElementToElement( { | ||
model: 'nested', | ||
view: () => new ViewEditable( 'figcaption', { contenteditable: true } ) | ||
} ) ); | ||
|
||
setData( editor.model, | ||
'<paragraph>foo[]</paragraph>' + | ||
'<widget><nested>bar</nested></widget>' + | ||
'<widget><nested>bom</nested></widget>' | ||
); | ||
} ) | ||
.catch( err => { | ||
console.error( err.stack ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
## Renderer should handle nested editables [FF] <a href="https://github.com/ckeditor/ckeditor5/issues/721">ckeditor5#721</a> | ||
|
||
### TC1 | ||
|
||
1. Put the caret in the first paragraph and type something. | ||
1. Put the caret inside the widget (in "bar"). | ||
1. Click "Undo" or press <kbd>Ctrl</kbd>+<kbd>Z</kbd> (check both). | ||
|
||
**Expected**: | ||
|
||
No error in the console. | ||
|
||
### TC2 | ||
|
||
Try the same TC as above but use both nested editables. See if the focus is correctly moved between them. | ||
|