Przeglądaj źródła

Fixed: view.Writer merging did not correctly merge several subsequent similar nodes.

Szymon Cofalik 9 lat temu
rodzic
commit
644a851cb5

+ 2 - 0
packages/ckeditor5-engine/src/view/writer.js

@@ -887,6 +887,8 @@ function wrapChildren( parent, startOffset, endOffset, attribute ) {
 	let offsetChange = 0;
 
 	for ( let position of wrapPositions ) {
+		position.offset -= offsetChange;
+
 		// Do not merge with elements outside selected children.
 		if ( position.offset == startOffset ) {
 			continue;

+ 12 - 0
packages/ckeditor5-engine/tests/view/writer/wrap.js

@@ -192,6 +192,18 @@ describe( 'writer', () => {
 			);
 		} );
 
+		it( 'merges wrapped nodes #6', () => {
+			test(
+				'<container:div>f{o<attribute:strong>ob</attribute:strong>a}r</container:div>',
+				'<attribute:span view-priority="1"></attribute:span>',
+				'<container:div>f[' +
+					'<attribute:span view-priority="1">o' +
+						'<attribute:strong view-priority="10">ob</attribute:strong>' +
+					'a</attribute:span>' +
+				']r</container:div>'
+			);
+		} );
+
 		it( 'should wrap single element by merging attributes', () => {
 			test(
 				'<container:p>[<attribute:b view-priority="1" foo="bar" one="two"></attribute:b>]</container:p>',