All files / roosterjs-content-model-dom/lib/domToModel/processors delimiterProcessor.ts

100% Statements 12/12
90% Branches 18/20
100% Functions 1/1
100% Lines 11/11

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 16 17 18 19 20 21 22 23 24 25 26 27 28 291x                 1x 43x   43x 42x 13x   13x     42x 17x 17x     17x        
import { addSelectionMarker } from '../utils/addSelectionMarker';
import type { ElementProcessor } from 'roosterjs-content-model-types';
 
/**
 * @internal
 * @param group
 * @param node
 * @param context
 */
export const delimiterProcessor: ElementProcessor<Node> = (group, node, context) => {
    const range = context.selection?.type == 'range' ? context.selection.range : null;
 
    if (range) {
        if (node.contains(range.startContainer)) {
            context.isInSelection = true;
 
            addSelectionMarker(group, context);
        }
 
        if (context.selection?.type == 'range' && node.contains(range.endContainer)) {
            Eif (!context.selection.range.collapsed) {
                addSelectionMarker(group, context);
            }
 
            context.isInSelection = false;
        }
    }
};