Browse Source

Merge branch 'master' into t/ckeditor5-engine/1198

# Conflicts:
#	src/headingengine.js
#	tests/headingcommand.js
Maciej Gołaszewski 8 years ago
parent
commit
16783f61a4

+ 8 - 12
packages/ckeditor5-heading/src/headingcommand.js

@@ -48,10 +48,10 @@ export default class HeadingCommand extends Command {
 	 * @inheritDoc
 	 */
 	refresh() {
-		const block = first( this.editor.document.selection.getSelectedBlocks() );
+		const block = first( this.editor.model.document.selection.getSelectedBlocks() );
 
 		this.value = !!block && block.is( this.modelElement );
-		this.isEnabled = !!block && checkCanBecomeHeading( block, this.modelElement, this.editor.document.schema );
+		this.isEnabled = !!block && checkCanBecomeHeading( block, this.modelElement, this.editor.model.schema );
 	}
 
 	/**
@@ -59,24 +59,20 @@ export default class HeadingCommand extends Command {
 	 * block is a heading already, turns selected headings (of this level only) to paragraphs.
 	 *
 	 * @fires execute
-	 * @param {Object} [options] Options for executed command.
-	 * @param {module:engine/model/batch~Batch} [options.batch] Batch to collect all the change steps.
-	 * New batch will be created if this option is not set.
 	 */
-	execute( options = {} ) {
-		const editor = this.editor;
-		const document = editor.document;
+	execute() {
+		const model = this.editor.model;
+		const document = model.document;
 
-		document.enqueueChanges( () => {
-			const batch = options.batch || document.batch();
+		model.change( writer => {
 			const blocks = Array.from( document.selection.getSelectedBlocks() )
 				.filter( block => {
-					return checkCanBecomeHeading( block, this.modelElement, document.schema );
+					return checkCanBecomeHeading( block, this.modelElement, model.schema );
 				} );
 
 			for ( const block of blocks ) {
 				if ( !block.is( this.modelElement ) ) {
-					batch.rename( block, this.modelElement );
+					writer.rename( block, this.modelElement );
 				}
 			}
 		} );

+ 4 - 4
packages/ckeditor5-heading/src/headingengine.js

@@ -86,7 +86,7 @@ export default class HeadingEngine extends Plugin {
 			// Skip paragraph - it is defined in required Paragraph feature.
 			if ( option.model !== defaultModelElement ) {
 				// Schema.
-				editor.document.schema.registerItem( option.model, '$block' );
+				editor.model.schema.registerItem( option.model, '$block' );
 
 				// Build converter from model to view for data and editing pipelines.
 				modelElementToViewContainerElement( option, [ data.modelToView, editing.modelToView ] );
@@ -111,13 +111,13 @@ export default class HeadingEngine extends Plugin {
 		const options = editor.config.get( 'heading.options' );
 
 		if ( enterCommand ) {
+			// @TODO This should be handled by a post-fixer.
 			this.listenTo( enterCommand, 'afterExecute', ( evt, data ) => {
-				const positionParent = editor.document.selection.getFirstPosition().parent;
-				const batch = data.batch;
+				const positionParent = editor.model.document.selection.getFirstPosition().parent;
 				const isHeading = options.some( option => positionParent.is( option.model ) );
 
 				if ( isHeading && !positionParent.is( defaultModelElement ) && positionParent.childCount === 0 ) {
-					batch.rename( positionParent, defaultModelElement );
+					data.writer.rename( positionParent, defaultModelElement );
 				}
 			} );
 		}

+ 3 - 3
packages/ckeditor5-heading/tests/heading.js

@@ -54,7 +54,7 @@ describe( 'Heading', () => {
 				dropdown = editor.ui.componentFactory.create( 'headings' );
 
 				// Set data so the commands will be enabled.
-				setData( editor.document, '<paragraph>f{}oo</paragraph>' );
+				setData( editor.model, '<paragraph>f{}oo</paragraph>' );
 			} );
 	} );
 
@@ -78,7 +78,7 @@ describe( 'Heading', () => {
 
 			expect( dropdown ).to.be.instanceOf( DropdownView );
 			expect( dropdown.buttonView.isEnabled ).to.be.true;
-			expect( dropdown.buttonView.isOn ).to.be.undefined;
+			expect( dropdown.buttonView.isOn ).to.be.false;
 			expect( dropdown.buttonView.label ).to.equal( 'Paragraph' );
 			expect( dropdown.buttonView.tooltip ).to.equal( 'Heading' );
 		} );
@@ -262,7 +262,7 @@ describe( 'Heading', () => {
 			it( 'reflects the #value of the commands', () => {
 				const listView = dropdown.listView;
 
-				setData( editor.document, '<heading2>f{}oo</heading2>' );
+				setData( editor.model, '<heading2>f{}oo</heading2>' );
 
 				expect( listView.items.map( item => item.isActive ) ).to.deep.equal( [
 					false,

+ 43 - 43
packages/ckeditor5-heading/tests/headingcommand.js

@@ -16,14 +16,15 @@ const options = [
 ];
 
 describe( 'HeadingCommand', () => {
-	let editor, document, commands, root, schema;
+	let editor, model, document, commands, root, schema;
 
 	beforeEach( () => {
 		return ModelTestEditor.create().then( newEditor => {
 			editor = newEditor;
-			document = editor.document;
+			model = editor.model;
+			document = model.document;
 			commands = {};
-			schema = document.schema;
+			schema = model.schema;
 
 			editor.commands.add( 'paragraph', new ParagraphCommand( editor ) );
 			schema.registerItem( 'paragraph', '$block' );
@@ -60,7 +61,7 @@ describe( 'HeadingCommand', () => {
 
 		function test( { model: modelElement } ) {
 			it( `equals ${ modelElement } when collapsed selection is placed inside ${ modelElement } element`, () => {
-				setData( document, `<${ modelElement }>foobar</${ modelElement }>` );
+				setData( model, `<${ modelElement }>foobar</${ modelElement }>` );
 				const element = root.getChild( 0 );
 				document.selection.addRange( Range.createFromParentsAndOffsets( element, 3, element, 3 ) );
 
@@ -68,16 +69,16 @@ describe( 'HeadingCommand', () => {
 			} );
 
 			it( 'equals false if inside to non-block element', () => {
-				setData( document, '<notBlock>[foo]</notBlock>' );
+				setData( model, '<notBlock>[foo]</notBlock>' );
 
 				expect( commands[ modelElement ].value ).to.be.false;
 			} );
 
 			it( `equals false if moved from ${ modelElement } to non-block element`, () => {
-				setData( document, `<${ modelElement }>[foo]</${ modelElement }><notBlock>foo</notBlock>` );
+				setData( model, `<${ modelElement }>[foo]</${ modelElement }><notBlock>foo</notBlock>` );
 				const element = document.getRoot().getChild( 1 );
 
-				document.enqueueChanges( () => {
+				model.change( () => {
 					document.selection.setRanges( [ Range.createIn( element ) ] );
 				} );
 
@@ -86,10 +87,10 @@ describe( 'HeadingCommand', () => {
 
 			it( 'should be refreshed after calling refresh()', () => {
 				const command = commands[ modelElement ];
-				setData( document, `<${ modelElement }>[foo]</${ modelElement }><notBlock>foo</notBlock>` );
+				setData( model, `<${ modelElement }>[foo]</${ modelElement }><notBlock>foo</notBlock>` );
 				const element = document.getRoot().getChild( 1 );
 
-				// Purposely not putting it in `document.enqueueChanges` to update command manually.
+				// Purposely not putting it in `model.change` to update command manually.
 				document.selection.setRanges( [ Range.createIn( element ) ] );
 
 				expect( command.value ).to.be.true;
@@ -103,24 +104,24 @@ describe( 'HeadingCommand', () => {
 		it( 'should update value after execution', () => {
 			const command = commands.heading1;
 
-			setData( document, '<paragraph>[]</paragraph>' );
+			setData( model, '<paragraph>[]</paragraph>' );
 			command.execute();
 
-			expect( getData( document ) ).to.equal( '<heading1>[]</heading1>' );
+			expect( getData( model ) ).to.equal( '<heading1>[]</heading1>' );
 			expect( command.value ).to.be.true;
 		} );
 
 		// https://github.com/ckeditor/ckeditor5-heading/issues/73
 		it( 'should not rename blocks which cannot become headings', () => {
-			document.schema.registerItem( 'restricted' );
-			document.schema.allow( { name: 'restricted', inside: '$root' } );
-			document.schema.disallow( { name: 'heading1', inside: 'restricted' } );
+			schema.registerItem( 'restricted' );
+			schema.allow( { name: 'restricted', inside: '$root' } );
+			schema.disallow( { name: 'heading1', inside: 'restricted' } );
 
-			document.schema.registerItem( 'fooBlock', '$block' );
-			document.schema.allow( { name: 'fooBlock', inside: 'restricted' } );
+			schema.registerItem( 'fooBlock', '$block' );
+			schema.allow( { name: 'fooBlock', inside: 'restricted' } );
 
 			setData(
-				document,
+				model,
 				'<paragraph>a[bc</paragraph>' +
 				'<restricted><fooBlock></fooBlock></restricted>' +
 				'<paragraph>de]f</paragraph>'
@@ -128,25 +129,24 @@ describe( 'HeadingCommand', () => {
 
 			commands.heading1.execute();
 
-			expect( getData( document ) ).to.equal(
+			expect( getData( model ) ).to.equal(
 				'<heading1>a[bc</heading1>' +
 				'<restricted><fooBlock></fooBlock></restricted>' +
 				'<heading1>de]f</heading1>'
 			);
 		} );
 
-		describe( 'custom options', () => {
-			it( 'should use provided batch', () => {
-				const batch = editor.document.batch();
-				const command = commands.heading1;
+		it( 'should use parent batch', () => {
+			const command = commands.heading1;
 
-				setData( document, '<paragraph>foo[]bar</paragraph>' );
+			setData( model, '<paragraph>foo[]bar</paragraph>' );
 
-				expect( batch.deltas.length ).to.equal( 0 );
+			model.change( writer => {
+				expect( writer.batch.deltas.length ).to.equal( 0 );
 
-				command.execute( { batch } );
+				command.execute();
 
-				expect( batch.deltas.length ).to.be.above( 0 );
+				expect( writer.batch.deltas.length ).to.be.above( 0 );
 			} );
 		} );
 
@@ -159,28 +159,28 @@ describe( 'HeadingCommand', () => {
 			}
 
 			it( 'does nothing when executed with already applied option', () => {
-				setData( document, '<heading1>foo[]bar</heading1>' );
+				setData( model, '<heading1>foo[]bar</heading1>' );
 
 				commands.heading1.execute();
-				expect( getData( document ) ).to.equal( '<heading1>foo[]bar</heading1>' );
+				expect( getData( model ) ).to.equal( '<heading1>foo[]bar</heading1>' );
 			} );
 
 			it( 'converts topmost blocks', () => {
 				schema.registerItem( 'inlineImage', '$inline' );
 				schema.allow( { name: '$text', inside: 'inlineImage' } );
 
-				setData( document, '<paragraph><inlineImage>foo[]</inlineImage>bar</paragraph>' );
+				setData( model, '<paragraph><inlineImage>foo[]</inlineImage>bar</paragraph>' );
 				commands.heading1.execute();
 
-				expect( getData( document ) ).to.equal( '<heading1><inlineImage>foo[]</inlineImage>bar</heading1>' );
+				expect( getData( model ) ).to.equal( '<heading1><inlineImage>foo[]</inlineImage>bar</heading1>' );
 			} );
 
 			function test( from, to ) {
 				it( `converts ${ from.model } to ${ to.model } on collapsed selection`, () => {
-					setData( document, `<${ from.model }>foo[]bar</${ from.model }>` );
+					setData( model, `<${ from.model }>foo[]bar</${ from.model }>` );
 					commands[ to.model ].execute();
 
-					expect( getData( document ) ).to.equal( `<${ to.model }>foo[]bar</${ to.model }>` );
+					expect( getData( model ) ).to.equal( `<${ to.model }>foo[]bar</${ to.model }>` );
 				} );
 			}
 		} );
@@ -194,29 +194,29 @@ describe( 'HeadingCommand', () => {
 			}
 
 			it( 'converts all elements where selection is applied', () => {
-				setData( document, '<heading1>foo[</heading1><heading2>bar</heading2><heading3>baz]</heading3>' );
+				setData( model, '<heading1>foo[</heading1><heading2>bar</heading2><heading3>baz]</heading3>' );
 
 				commands.heading3.execute();
 
-				expect( getData( document ) ).to.equal(
+				expect( getData( model ) ).to.equal(
 					'<heading3>foo[</heading3><heading3>bar</heading3><heading3>baz]</heading3>'
 				);
 			} );
 
 			it( 'does nothing to the elements with same option (#1)', () => {
-				setData( document, '<heading1>[foo</heading1><heading1>bar]</heading1>' );
+				setData( model, '<heading1>[foo</heading1><heading1>bar]</heading1>' );
 				commands.heading1.execute();
 
-				expect( getData( document ) ).to.equal(
+				expect( getData( model ) ).to.equal(
 					'<heading1>[foo</heading1><heading1>bar]</heading1>'
 				);
 			} );
 
 			it( 'does nothing to the elements with same option (#2)', () => {
-				setData( document, '<heading1>[foo</heading1><heading1>bar</heading1><heading2>baz]</heading2>' );
+				setData( model, '<heading1>[foo</heading1><heading1>bar</heading1><heading2>baz]</heading2>' );
 				commands.heading1.execute();
 
-				expect( getData( document ) ).to.equal(
+				expect( getData( model ) ).to.equal(
 					'<heading1>[foo</heading1><heading1>bar</heading1><heading1>baz]</heading1>'
 				);
 			} );
@@ -224,13 +224,13 @@ describe( 'HeadingCommand', () => {
 			function test( { model: fromElement }, { model: toElement } ) {
 				it( `converts ${ fromElement } to ${ toElement } on non-collapsed selection`, () => {
 					setData(
-						document,
+						model,
 						`<${ fromElement }>foo[bar</${ fromElement }><${ fromElement }>baz]qux</${ fromElement }>`
 					);
 
 					commands[ toElement ].execute();
 
-					expect( getData( document ) ).to.equal(
+					expect( getData( model ) ).to.equal(
 						`<${ toElement }>foo[bar</${ toElement }><${ toElement }>baz]qux</${ toElement }>`
 					);
 				} );
@@ -252,19 +252,19 @@ describe( 'HeadingCommand', () => {
 
 			describe( `${ modelElement } command`, () => {
 				it( 'should be enabled when inside another block', () => {
-					setData( document, '<paragraph>f{}oo</paragraph>' );
+					setData( model, '<paragraph>f{}oo</paragraph>' );
 
 					expect( command.isEnabled ).to.be.true;
 				} );
 
 				it( 'should be disabled if inside non-block', () => {
-					setData( document, '<notBlock>f{}oo</notBlock>' );
+					setData( model, '<notBlock>f{}oo</notBlock>' );
 
 					expect( command.isEnabled ).to.be.false;
 				} );
 
 				it( 'should be disabled if selection is placed on non-block', () => {
-					setData( document, '[<notBlock>foo</notBlock>]' );
+					setData( model, '[<notBlock>foo</notBlock>]' );
 
 					expect( command.isEnabled ).to.be.false;
 				} );

+ 23 - 23
packages/ckeditor5-heading/tests/headingengine.js

@@ -11,7 +11,7 @@ import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtest
 import { getData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 
 describe( 'HeadingEngine', () => {
-	let editor, document;
+	let editor, model;
 
 	beforeEach( () => {
 		return VirtualTestEditor
@@ -20,7 +20,7 @@ describe( 'HeadingEngine', () => {
 			} )
 			.then( newEditor => {
 				editor = newEditor;
-				document = editor.document;
+				model = editor.model;
 			} );
 	} );
 
@@ -33,18 +33,18 @@ describe( 'HeadingEngine', () => {
 	} );
 
 	it( 'should set proper schema rules', () => {
-		expect( document.schema.hasItem( 'heading1' ) ).to.be.true;
-		expect( document.schema.hasItem( 'heading2' ) ).to.be.true;
-		expect( document.schema.hasItem( 'heading3' ) ).to.be.true;
+		expect( model.schema.hasItem( 'heading1' ) ).to.be.true;
+		expect( model.schema.hasItem( 'heading2' ) ).to.be.true;
+		expect( model.schema.hasItem( 'heading3' ) ).to.be.true;
 
-		expect( document.schema.check( { name: 'heading1', inside: '$root' } ) ).to.be.true;
-		expect( document.schema.check( { name: '$inline', inside: 'heading1' } ) ).to.be.true;
+		expect( model.schema.check( { name: 'heading1', inside: '$root' } ) ).to.be.true;
+		expect( model.schema.check( { name: '$inline', inside: 'heading1' } ) ).to.be.true;
 
-		expect( document.schema.check( { name: 'heading2', inside: '$root' } ) ).to.be.true;
-		expect( document.schema.check( { name: '$inline', inside: 'heading2' } ) ).to.be.true;
+		expect( model.schema.check( { name: 'heading2', inside: '$root' } ) ).to.be.true;
+		expect( model.schema.check( { name: '$inline', inside: 'heading2' } ) ).to.be.true;
 
-		expect( document.schema.check( { name: 'heading3', inside: '$root' } ) ).to.be.true;
-		expect( document.schema.check( { name: '$inline', inside: 'heading3' } ) ).to.be.true;
+		expect( model.schema.check( { name: 'heading3', inside: '$root' } ) ).to.be.true;
+		expect( model.schema.check( { name: '$inline', inside: 'heading3' } ) ).to.be.true;
 	} );
 
 	it( 'should register #commands', () => {
@@ -57,21 +57,21 @@ describe( 'HeadingEngine', () => {
 	it( 'should convert heading1', () => {
 		editor.setData( '<h2>foobar</h2>' );
 
-		expect( getData( document, { withoutSelection: true } ) ).to.equal( '<heading1>foobar</heading1>' );
+		expect( getData( model, { withoutSelection: true } ) ).to.equal( '<heading1>foobar</heading1>' );
 		expect( editor.getData() ).to.equal( '<h2>foobar</h2>' );
 	} );
 
 	it( 'should convert heading2', () => {
 		editor.setData( '<h3>foobar</h3>' );
 
-		expect( getData( document, { withoutSelection: true } ) ).to.equal( '<heading2>foobar</heading2>' );
+		expect( getData( model, { withoutSelection: true } ) ).to.equal( '<heading2>foobar</heading2>' );
 		expect( editor.getData() ).to.equal( '<h3>foobar</h3>' );
 	} );
 
 	it( 'should convert heading3', () => {
 		editor.setData( '<h4>foobar</h4>' );
 
-		expect( getData( document, { withoutSelection: true } ) ).to.equal( '<heading3>foobar</heading3>' );
+		expect( getData( model, { withoutSelection: true } ) ).to.equal( '<heading3>foobar</heading3>' );
 		expect( editor.getData() ).to.equal( '<h4>foobar</h4>' );
 	} );
 
@@ -96,21 +96,21 @@ describe( 'HeadingEngine', () => {
 				} )
 				.then( newEditor => {
 					editor = newEditor;
-					document = editor.document;
+					model = editor.model;
 				} );
 		} );
 
 		it( 'should convert from defined h element', () => {
 			editor.setData( '<h1>foobar</h1>' );
 
-			expect( getData( document, { withoutSelection: true } ) ).to.equal( '<heading1>foobar</heading1>' );
+			expect( getData( model, { withoutSelection: true } ) ).to.equal( '<heading1>foobar</heading1>' );
 			expect( editor.getData() ).to.equal( '<h1>foobar</h1>' );
 		} );
 
 		it( 'should convert from defined paragraph with attributes', () => {
 			editor.setData( '<p data-heading="h1">foobar</p><p>Normal paragraph</p>' );
 
-			expect( getData( document, { withoutSelection: true } ) )
+			expect( getData( model, { withoutSelection: true } ) )
 				.to.equal( '<heading1>foobar</heading1><paragraph>Normal paragraph</paragraph>' );
 
 			expect( editor.getData() ).to.equal( '<h1>foobar</h1><p>Normal paragraph</p>' );
@@ -151,17 +151,17 @@ describe( 'HeadingEngine', () => {
 						}
 					} )
 					.then( editor => {
-						document = editor.document;
+						model = editor.model;
 
 						expect( editor.commands.get( 'h4' ) ).to.be.instanceOf( HeadingCommand );
 						expect( editor.commands.get( 'paragraph' ) ).to.be.instanceOf( ParagraphCommand );
 
-						expect( document.schema.hasItem( 'paragraph' ) ).to.be.true;
-						expect( document.schema.hasItem( 'h4' ) ).to.be.true;
+						expect( model.schema.hasItem( 'paragraph' ) ).to.be.true;
+						expect( model.schema.hasItem( 'h4' ) ).to.be.true;
 
-						expect( document.schema.hasItem( 'heading1' ) ).to.be.false;
-						expect( document.schema.hasItem( 'heading2' ) ).to.be.false;
-						expect( document.schema.hasItem( 'heading3' ) ).to.be.false;
+						expect( model.schema.hasItem( 'heading1' ) ).to.be.false;
+						expect( model.schema.hasItem( 'heading2' ) ).to.be.false;
+						expect( model.schema.hasItem( 'heading3' ) ).to.be.false;
 					} );
 			} );
 		} );

+ 11 - 10
packages/ckeditor5-heading/tests/integration.js

@@ -17,7 +17,7 @@ import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictest
 import { getData as getModelData, setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 
 describe( 'Heading integration', () => {
-	let editor, doc, element;
+	let editor, model, doc, element;
 
 	beforeEach( () => {
 		element = document.createElement( 'div' );
@@ -29,7 +29,8 @@ describe( 'Heading integration', () => {
 			} )
 			.then( newEditor => {
 				editor = newEditor;
-				doc = editor.document;
+				model = editor.model;
+				doc = model.document;
 			} );
 	} );
 
@@ -46,7 +47,7 @@ describe( 'Heading integration', () => {
 
 			editor.execute( 'enter' );
 
-			expect( getModelData( doc ) ).to.equal( '<heading1>foobar</heading1><paragraph>[]</paragraph>' );
+			expect( getModelData( model ) ).to.equal( '<heading1>foobar</heading1><paragraph>[]</paragraph>' );
 		} );
 
 		it( 'should not alter the "enter" command if selection not ended at the end of a heading block', () => {
@@ -56,14 +57,14 @@ describe( 'Heading integration', () => {
 
 			editor.execute( 'enter' );
 
-			expect( getModelData( doc ) ).to.equal( '<heading1>foo</heading1><heading1>[]bar</heading1>' );
+			expect( getModelData( model ) ).to.equal( '<heading1>foo</heading1><heading1>[]bar</heading1>' );
 		} );
 	} );
 
 	describe( 'with the image feature', () => {
 		// https://github.com/ckeditor/ckeditor5-heading/issues/73
 		it( 'should not destroy the image when a selection converted to a heading', () => {
-			setModelData( editor.document,
+			setModelData( model,
 				'<paragraph>fo[o</paragraph>' +
 				'<image src="foo.png">' +
 					'<caption>xxx</caption>' +
@@ -73,7 +74,7 @@ describe( 'Heading integration', () => {
 
 			editor.execute( 'heading1' );
 
-			expect( getModelData( doc ) ).to.equal(
+			expect( getModelData( model ) ).to.equal(
 				'<heading1>fo[o</heading1>' +
 				'<image src="foo.png">' +
 					'<caption>xxx</caption>' +
@@ -85,19 +86,19 @@ describe( 'Heading integration', () => {
 
 	describe( 'with the undo feature', () => {
 		it( 'does not create undo steps when applied to an existing heading (collapsed selection)', () => {
-			setModelData( editor.document, '<heading1>foo[]bar</heading1>' );
+			setModelData( model, '<heading1>foo[]bar</heading1>' );
 
 			editor.execute( 'heading1' );
-			expect( getModelData( editor.document ) ).to.equal( '<heading1>foo[]bar</heading1>' );
+			expect( getModelData( model ) ).to.equal( '<heading1>foo[]bar</heading1>' );
 
 			expect( editor.commands.get( 'undo' ).isEnabled ).to.be.false;
 		} );
 
 		it( 'does not create undo steps when applied to an existing heading (non–collapsed selection)', () => {
-			setModelData( editor.document, '<heading1>[foo</heading1><heading1>bar]</heading1>' );
+			setModelData( model, '<heading1>[foo</heading1><heading1>bar]</heading1>' );
 
 			editor.execute( 'heading1' );
-			expect( getModelData( editor.document ) ).to.equal( '<heading1>[foo</heading1><heading1>bar]</heading1>' );
+			expect( getModelData( model ) ).to.equal( '<heading1>[foo</heading1><heading1>bar]</heading1>' );
 
 			expect( editor.commands.get( 'undo' ).isEnabled ).to.be.false;
 		} );

+ 4 - 4
packages/ckeditor5-heading/tests/tickets/40.js

@@ -23,11 +23,11 @@ describe( 'Bug ckeditor5-heading#40', () => {
 			.then( newEditor => {
 				editor = newEditor;
 
-				setData( editor.document, '<heading1>foo[]</heading1>' );
+				setData( editor.model, '<heading1>foo[]</heading1>' );
 
 				editor.execute( 'enter' );
 
-				expect( getData( editor.document ) ).to.equal( '<heading1>foo</heading1><paragraph>[]</paragraph>' );
+				expect( getData( editor.model ) ).to.equal( '<heading1>foo</heading1><paragraph>[]</paragraph>' );
 			} );
 	} );
 
@@ -39,11 +39,11 @@ describe( 'Bug ckeditor5-heading#40', () => {
 			.then( newEditor => {
 				editor = newEditor;
 
-				setData( editor.document, '<heading1>foo[]</heading1>' );
+				setData( editor.model, '<heading1>foo[]</heading1>' );
 
 				editor.execute( 'enter' );
 
-				expect( getData( editor.document ) ).to.equal( '<heading1>foo</heading1><paragraph>[]</paragraph>' );
+				expect( getData( editor.model ) ).to.equal( '<heading1>foo</heading1><paragraph>[]</paragraph>' );
 			} );
 	} );
 } );