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 33 34 35 36 37 | 1x 1x 1x 1x 1x 1x 1x 1x 8x 8x 8x 8x 17x 8x 8x 8x | import { addBlock } from '../../modelApi/common/addBlock'; import { blockProcessor } from './blockProcessor'; import { createParagraph } from '../../modelApi/creators/createParagraph'; import { createParagraphDecorator } from '../../modelApi/creators/createParagraphDecorator'; import { getObjectKeys } from '../../domUtils/getObjectKeys'; import { parseFormat } from '../utils/parseFormat'; import { stackFormat } from '../utils/stackFormat'; import type { ContentModelSegmentFormat, ElementProcessor } from 'roosterjs-content-model-types'; /** * @internal */ export const headingProcessor: ElementProcessor<HTMLHeadingElement> = (group, element, context) => { stackFormat( context, { segment: 'shallowCloneForBlock', paragraph: 'shallowClone', blockDecorator: 'empty' }, () => { const segmentFormat: ContentModelSegmentFormat = {}; parseFormat(element, context.formatParsers.segmentOnBlock, segmentFormat, context); // These formats are already declared on heading element, no need to keep them in context. // And we should not duplicate them in context, either. Because when we want to turn off heading, // inner text should not keep those text format from heading. getObjectKeys(segmentFormat).forEach(key => { delete context.segmentFormat[key]; }); context.blockDecorator = createParagraphDecorator(element.tagName, segmentFormat); blockProcessor(group, element, context); } ); addBlock(group, createParagraph(true /*isImplicit*/, context.blockFormat)); }; |