| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- /**
- * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
- /* globals document */
- import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
- import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
- import buildViewConverter from '../../src/conversion/buildviewconverter';
- import buildModelConverter from '../../src/conversion/buildmodelconverter';
- import { getData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
- describe( 'Bug ckeditor5-engine#699', () => {
- let element;
- beforeEach( () => {
- element = document.createElement( 'div' );
- document.body.appendChild( element );
- } );
- afterEach( () => {
- element.remove();
- } );
- it( 'the engine sets the initial selection on the first widget', () => {
- return ClassicTestEditor
- .create( element, { plugins: [ Paragraph, WidgetPlugin ] } )
- .then( editor => {
- editor.setData( '<widget></widget><p>foo</p>' );
- expect( getData( editor.document ) ).to.equal( '[<widget></widget>]<paragraph>foo</paragraph>' );
- return editor.destroy();
- } );
- } );
- } );
- function WidgetPlugin( editor ) {
- const schema = editor.document.schema;
- schema.registerItem( 'widget' );
- schema.allow( { name: 'widget', inside: '$root' } );
- schema.objects.add( 'widget' );
- buildModelConverter().for( editor.data.modelToView, editor.editing.modelToView )
- .fromElement( 'widget' )
- .toElement( 'widget' );
- buildViewConverter().for( editor.data.viewToModel )
- .fromElement( 'widget' )
- .toElement( 'widget' );
- }
|