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

100% Statements 15/15
100% Branches 0/0
100% Functions 2/2
100% Lines 14/14

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 301x 1x 1x 1x 1x 1x           1x 139x       139x   139x   139x 139x   139x       139x    
import { addBlock } from '../../modelApi/common/addBlock';
import { blockProcessor } from './blockProcessor';
import { createParagraph } from '../../modelApi/creators/createParagraph';
import { createParagraphDecorator } from '../../modelApi/creators/createParagraphDecorator';
import { parseFormat } from '../utils/parseFormat';
import { stackFormat } from '../utils/stackFormat';
import type { ContentModelSegmentFormat, ElementProcessor } from 'roosterjs-content-model-types';
 
/**
 * @internal
 */
export const pProcessor: ElementProcessor<HTMLElement> = (group, element, context) => {
    stackFormat(
        context,
        { blockDecorator: 'empty', segment: 'shallowCloneForBlock', paragraph: 'shallowClone' },
        () => {
            context.blockDecorator = createParagraphDecorator(element.tagName);
 
            const segmentFormat: ContentModelSegmentFormat = {};
 
            parseFormat(element, context.formatParsers.segmentOnBlock, segmentFormat, context);
            Object.assign(context.segmentFormat, segmentFormat);
 
            blockProcessor(group, element, context, segmentFormat);
        }
    );
 
    addBlock(group, createParagraph(true /*isImplicit*/, context.blockFormat));
};