8
0
Pārlūkot izejas kodu

Adjusted special 'spacerun span' elements normalization function for Edge browser.

Krzysztof Krztoń 7 gadi atpakaļ
vecāks
revīzija
b6fb36b7cc

+ 4 - 2
packages/ckeditor5-paste-from-office/src/filters/utils.js

@@ -109,8 +109,10 @@ function normalizeEndTagsPrecedingSpace( htmlString ) {
 // @param {Document} htmlDocument Native `Document` object in which spacing should be normalized.
 function normalizeSpacerunSpans( htmlDocument ) {
 	htmlDocument.querySelectorAll( 'span[style*=spacerun]' ).forEach( el => {
-		const spacesReplacemanet = Array( el.innerText.length + 1 ).join( '\u00A0 ' ).substr( 0, el.innerText.length );
+		// Use `el.childNodes[ 0 ].data.length` instead of `el.innerText.length`. For `el.innerText.length` which
+		// contains spaces mixed with ` `, Edge browser returns incorrect length.
+		const innerTextLength = el.childNodes[ 0 ].data.length;
 
-		el.innerHTML = spacesReplacemanet;
+		el.innerHTML = Array( innerTextLength + 1 ).join( '\u00A0 ' ).substr( 0, innerTextLength );
 	} );
 }