Explorar o código

Export normalizeNodes from writer.

Piotr Jasiun %!s(int64=9) %!d(string=hai) anos
pai
achega
d601a58067

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

@@ -32,7 +32,8 @@ export default {
 	remove,
 	remove,
 	move,
 	move,
 	setAttribute,
 	setAttribute,
-	removeAttribute
+	removeAttribute,
+	normalizeNodes
 };
 };
 
 
 /**
 /**

+ 8 - 9
packages/ckeditor5-engine/tests/model/writer.js

@@ -13,7 +13,6 @@ import TextProxy from '/ckeditor5/engine/model/textproxy.js';
 import Position from '/ckeditor5/engine/model/position.js';
 import Position from '/ckeditor5/engine/model/position.js';
 import Range from '/ckeditor5/engine/model/range.js';
 import Range from '/ckeditor5/engine/model/range.js';
 import writer from '/ckeditor5/engine/model/writer.js';
 import writer from '/ckeditor5/engine/model/writer.js';
-import { normalizeNodes } from '/ckeditor5/engine/model/writer.js';
 import { getData } from '/tests/engine/_utils/model.js';
 import { getData } from '/tests/engine/_utils/model.js';
 
 
 import CKEditorError from '/ckeditor5/utils/ckeditorerror.js';
 import CKEditorError from '/ckeditor5/utils/ckeditorerror.js';
@@ -162,11 +161,11 @@ describe( 'normalizeNodes', () => {
 	it( 'should change single object into an array', () => {
 	it( 'should change single object into an array', () => {
 		const p = new Element( 'p' );
 		const p = new Element( 'p' );
 
 
-		expect( normalizeNodes( p ) ).to.deep.equal( [ p ] );
+		expect( writer.normalizeNodes( p ) ).to.deep.equal( [ p ] );
 	} );
 	} );
 
 
 	it( 'should change strings to text nodes', () => {
 	it( 'should change strings to text nodes', () => {
-		const text = normalizeNodes( 'abc' )[ 0 ];
+		const text = writer.normalizeNodes( 'abc' )[ 0 ];
 
 
 		expect( text ).to.be.instanceof( Text );
 		expect( text ).to.be.instanceof( Text );
 		expect( text.data ).to.equal( 'abc' );
 		expect( text.data ).to.equal( 'abc' );
@@ -176,7 +175,7 @@ describe( 'normalizeNodes', () => {
 		const textNode = new Text( 'abc' );
 		const textNode = new Text( 'abc' );
 		const textProxy = new TextProxy( textNode, 1, 1 );
 		const textProxy = new TextProxy( textNode, 1, 1 );
 
 
-		const text = normalizeNodes( textProxy )[ 0 ];
+		const text = writer.normalizeNodes( textProxy )[ 0 ];
 
 
 		expect( text ).to.be.instanceof( Text );
 		expect( text ).to.be.instanceof( Text );
 		expect( text.data ).to.equal( 'b' );
 		expect( text.data ).to.equal( 'b' );
@@ -185,11 +184,11 @@ describe( 'normalizeNodes', () => {
 	it( 'should not change elements', () => {
 	it( 'should not change elements', () => {
 		const p = new Element( 'p' );
 		const p = new Element( 'p' );
 
 
-		expect( normalizeNodes( p )[ 0 ] ).to.equal( p );
+		expect( writer.normalizeNodes( p )[ 0 ] ).to.equal( p );
 	} );
 	} );
 
 
 	it( 'should omit unrecognized objects', () => {
 	it( 'should omit unrecognized objects', () => {
-		expect( normalizeNodes( 1 ) ).to.deep.equal( [] );
+		expect( writer.normalizeNodes( 1 ) ).to.deep.equal( [] );
 	} );
 	} );
 
 
 	it( 'should accept arrays', () => {
 	it( 'should accept arrays', () => {
@@ -197,7 +196,7 @@ describe( 'normalizeNodes', () => {
 		const image = new Element( 'image' );
 		const image = new Element( 'image' );
 		const nodes = [ 'abc', text, image, 1, 'xyz' ];
 		const nodes = [ 'abc', text, image, 1, 'xyz' ];
 
 
-		const normalized = normalizeNodes( nodes );
+		const normalized = writer.normalizeNodes( nodes );
 
 
 		expect( normalized[ 0 ] ).to.be.instanceof( Text );
 		expect( normalized[ 0 ] ).to.be.instanceof( Text );
 		expect( normalized[ 1 ] ).to.equal( text );
 		expect( normalized[ 1 ] ).to.equal( text );
@@ -206,7 +205,7 @@ describe( 'normalizeNodes', () => {
 	} );
 	} );
 
 
 	it( 'should merge text nodes if mergeTextNodes flag is set to true', () => {
 	it( 'should merge text nodes if mergeTextNodes flag is set to true', () => {
-		const normalized = normalizeNodes( [ 'foo', 'bar' ], true );
+		const normalized = writer.normalizeNodes( [ 'foo', 'bar' ], true );
 
 
 		expect( normalized.length ).to.equal( 1 );
 		expect( normalized.length ).to.equal( 1 );
 		expect( normalized[ 0 ].data ).to.equal( 'foobar' );
 		expect( normalized[ 0 ].data ).to.equal( 'foobar' );
@@ -219,7 +218,7 @@ describe( 'normalizeNodes', () => {
 			'xyz'
 			'xyz'
 		];
 		];
 
 
-		const normalized = normalizeNodes( nodes, true );
+		const normalized = writer.normalizeNodes( nodes, true );
 
 
 		expect( normalized[ 0 ] ).to.be.instanceof( Text );
 		expect( normalized[ 0 ] ).to.be.instanceof( Text );
 		expect( normalized[ 0 ].getAttribute( 'bold' ) ).to.be.true;
 		expect( normalized[ 0 ].getAttribute( 'bold' ) ).to.be.true;