All files / roosterjs-content-model-core/lib/override pasteTextProcessor.ts

100% Statements 7/7
80% Branches 8/10
100% Functions 1/1
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 161x           1x 453x   453x 11x     453x    
import { isWhiteSpacePreserved } from 'roosterjs-content-model-dom';
import type { ElementProcessor } from 'roosterjs-content-model-types';
 
/**
 * @internal
 */
export const pasteTextProcessor: ElementProcessor<Text> = (group, text, context) => {
    const whiteSpace = context.blockFormat.whiteSpace;
 
    if (isWhiteSpacePreserved(whiteSpace)) {
        text.nodeValue = text.nodeValue?.replace(/\u0020\u0020/g, '\u0020\u00A0') ?? '';
    }
 
    context.defaultElementProcessors['#text'](group, text, context);
};