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

100% Statements 14/14
100% Branches 4/4
100% Functions 2/2
100% Lines 13/13

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 29 30 31 32 331x 1x 1x 1x           1x 4x           4x   4x   4x 1x     4x 1x     4x        
import { addBlock } from '../../modelApi/common/addBlock';
import { createDivider } from '../../modelApi/creators/createDivider';
import { parseFormat } from '../utils/parseFormat';
import { stackFormat } from '../utils/stackFormat';
import type { ElementProcessor } from 'roosterjs-content-model-types';
 
/**
 * @internal
 */
export const hrProcessor: ElementProcessor<HTMLHRElement> = (group, element, context) => {
    stackFormat(
        context,
        {
            paragraph: 'shallowClone',
        },
        () => {
            parseFormat(element, context.formatParsers.divider, context.blockFormat, context);
 
            const hr = createDivider('hr', context.blockFormat);
 
            if (element.size) {
                hr.size = element.size;
            }
 
            if (context.isInSelection) {
                hr.isSelected = true;
            }
 
            addBlock(group, hr);
        }
    );
};