Переглянути джерело

Merge branch 't/815' into t/811

Piotrek Koszuliński 8 роки тому
батько
коміт
3a2aea2495

+ 2 - 1
packages/ckeditor5-engine/src/dev-utils/model.js

@@ -100,7 +100,8 @@ export function setData( document, data, options = {} ) {
 	// Parse data string to model.
 	const parsedResult = setData._parse( data, document.schema, {
 		lastRangeBackward: options.lastRangeBackward,
-		selectionAttributes: options.selectionAttributes
+		selectionAttributes: options.selectionAttributes,
+		context: [ modelRoot.name ]
 	} );
 
 	// Retrieve DocumentFragment and Selection from parsed model.

+ 2 - 2
packages/ckeditor5-engine/tests/controller/deletecontent.js

@@ -311,14 +311,14 @@ describe( 'DataController', () => {
 			it( 'deletes two inline elements', () => {
 				setData(
 					doc,
-					'<paragraph>x[<image></image><image></image>]z</paragraph>',
+					'x[<image></image><image></image>]z',
 					{ rootName: 'paragraphRoot' }
 				);
 
 				deleteContent( doc.selection, doc.batch() );
 
 				expect( getData( doc, { rootName: 'paragraphRoot' } ) )
-					.to.equal( '<paragraph>x[]z</paragraph>' );
+					.to.equal( 'x[]z' );
 			} );
 
 			it( 'creates a paragraph when text is not allowed (paragraph selected)', () => {

+ 12 - 0
packages/ckeditor5-engine/tests/dev-utils/model.js

@@ -157,6 +157,18 @@ describe( 'model test utils', () => {
 			expect( document.selection.getAttribute( 'foo' ) ).to.equal( 'bar' );
 		} );
 
+		// #815.
+		it( 'should work in a special root', () => {
+			const document = new Document();
+
+			document.schema.registerItem( 'textOnly' );
+			document.schema.allow( { name: '$text', inside: 'textOnly' } );
+			document.createRoot( 'textOnly', 'textOnly' );
+
+			setData( document, 'a[b]c', { rootName: 'textOnly' } );
+			expect( getData( document, { rootName: 'textOnly' } ) ).to.equal( 'a[b]c' );
+		} );
+
 		function test( data, expected ) {
 			expected = expected || data;