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 | 1x 1x 204x 204x 39x 39x 2x 202x | import { MarkdownHeadings } from '../../constants/headings';
import type {
ContentModelParagraphDecorator,
ContentModelText,
} from 'roosterjs-content-model-types';
/**
* @internal
*/
export function adjustHeading(
textSegment: ContentModelText,
decorator?: ContentModelParagraphDecorator
): ContentModelText | null {
const markdownToBeRemoved = MarkdownHeadings[decorator?.tagName || ''];
if (markdownToBeRemoved) {
textSegment.text = textSegment.text.replace(markdownToBeRemoved, '');
if (textSegment.text.length === 0) {
// If the text becomes empty after removing the heading markdown, we can remove the segment
return null;
}
}
return textSegment;
}
|