Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' into t/1210
Browse files Browse the repository at this point in the history
  • Loading branch information
szymonkups committed Feb 15, 2018
2 parents f63f2a1 + 4b7d435 commit 226a96a
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/view/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,10 @@ export default class Renderer {
const anchor = this.domConverter.viewPositionToDom( this.selection.anchor );
const focus = this.domConverter.viewPositionToDom( this.selection.focus );

// Focus the new editing host.
// Otherwise, FF may throw an error (https://github.com/ckeditor/ckeditor5/issues/721).
domRoot.focus();

domSelection.collapse( anchor.parent, anchor.offset );
domSelection.extend( focus.parent, focus.offset );
}
Expand Down
9 changes: 9 additions & 0 deletions tests/manual/tickets/ckeditor5-721/1.html
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>
68 changes: 68 additions & 0 deletions tests/manual/tickets/ckeditor5-721/1.js
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 );
} );
16 changes: 16 additions & 0 deletions tests/manual/tickets/ckeditor5-721/1.md
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.

0 comments on commit 226a96a

Please sign in to comment.