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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | 1x 1x 1022x 1022x 1022x 1022x 1022x 1301x 1107x 1301x 1301x 6x 1022x 80x 80x 71x 80x 80x 1022x | import { isNodeOfType } from '../../domUtils/isNodeOfType';
import type {
ContentModelBlockGroup,
ContentModelHandler,
ModelToDomContext,
} from 'roosterjs-content-model-types';
/**
* @internal
*/
export const handleBlockGroupChildren: ContentModelHandler<ContentModelBlockGroup> = (
doc: Document,
parent: Node,
group: ContentModelBlockGroup,
context: ModelToDomContext
) => {
const { listFormat } = context;
const nodeStack = listFormat.nodeStack;
let refNode: Node | null = parent.firstChild;
try {
group.blocks.forEach((childBlock, index) => {
// When process list, we need a node stack.
// When there are two continuous lists, they should share the same stack
// so that list items with same type/threadId can be merged into the same list element
// In other cases, clear the stack so that two separate lists won't share the same list element
if (
index == 0 ||
childBlock.blockType != 'BlockGroup' ||
childBlock.blockGroupType != 'ListItem'
) {
listFormat.nodeStack = [];
}
refNode = context.modelHandlers.block(doc, parent, childBlock, context, refNode);
if (childBlock.blockType == 'Entity') {
context.domIndexer?.onBlockEntity(childBlock, group);
}
});
// Remove all rest node if any since they don't appear in content model
while (refNode) {
const next = refNode.nextSibling;
if (isNodeOfType(refNode, 'ELEMENT_NODE')) {
context.rewriteFromModel.removedBlockElements.push(refNode);
}
refNode.parentNode?.removeChild(refNode);
refNode = next;
}
} finally {
listFormat.nodeStack = nodeStack;
}
};
|