Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions packages/ckeditor5-paste-from-office/src/filters/space.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@ export function normalizeSpacing( htmlString ) {
*/
export function normalizeSpacerunSpans( htmlDocument ) {
htmlDocument.querySelectorAll( 'span[style*=spacerun]' ).forEach( el => {
const innerTextLength = el.innerText.length || 0;

el.innerHTML = Array( innerTextLength + 1 ).join( '\u00A0 ' ).substr( 0, innerTextLength );
// For paste contents from WPS Office, the span's inner text is not all of spaces or blank,
// so we should keep the origin contents, or replace ONLY space characters.
if ( /[^\b]/.test( el.innerText.trim() ) === false ) {
const innerTextLength = el.innerText.length || 0;
el.innerHTML = Array( innerTextLength + 1 ).join( '\u00A0 ' ).substr( 0, innerTextLength );
}
} );
}

Expand Down