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 | 1x 1x 1x 1x 1x 2328x 1164x 1164x 40x 40x 40x 40x 40x 1164x 7x 7x 7x 7x | import { applyFormat } from '../utils/applyFormat';
import { isNodeOfType } from '../../domUtils/isNodeOfType';
import { stackFormat } from '../utils/stackFormat';
import { wrapAllChildNodes } from '../../domUtils/moveChildNodes';
import type {
ContentModelSegment,
ContentModelSegmentHandler,
} from 'roosterjs-content-model-types';
/**
* @internal
*/
export const handleSegmentDecorator: ContentModelSegmentHandler<ContentModelSegment> = (
_,
parent,
segment,
context
) => {
const { code, link } = segment;
Eif (isNodeOfType(parent, 'ELEMENT_NODE')) {
if (link) {
stackFormat(context, 'a', () => {
const a = wrapAllChildNodes(parent, 'a');
applyFormat(a, context.formatAppliers.link, link.format, context);
applyFormat(a, context.formatAppliers.dataset, link.dataset, context);
context.onNodeCreated?.(link, a);
});
}
if (code) {
stackFormat(context, 'code', () => {
const codeNode = wrapAllChildNodes(parent, 'code');
applyFormat(codeNode, context.formatAppliers.code, code.format, context);
context.onNodeCreated?.(code, codeNode);
});
}
}
};
|