All files / roosterjs-content-model-markdown/lib/markdownToModel/creators createBlockQuoteFromMarkdown.ts

100% Statements 9/9
100% Branches 2/2
100% Functions 1/1
100% Lines 9/9

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 311x 1x           1x                         1x       11x 11x 11x 11x 11x    
import { createFormatContainer } from 'roosterjs-content-model-dom';
import { createParagraphFromMarkdown } from './createParagraphFromMarkdown';
import type {
    ContentModelFormatContainer,
    ContentModelFormatContainerFormat,
} from 'roosterjs-content-model-types';
 
const QuoteFormat: ContentModelFormatContainerFormat = {
    borderLeft: '3px solid rgb(200, 200, 200)',
    textColor: 'rgb(102, 102, 102)',
    marginTop: '1em',
    marginBottom: '1em',
    marginLeft: '40px',
    marginRight: '40px',
    paddingLeft: '10px',
};
 
/**
 * @internal
 */
export function createBlockQuoteFromMarkdown(
    text: string,
    blockquote?: ContentModelFormatContainer
): ContentModelFormatContainer {
    text = text.replace('>', '');
    const paragraph = createParagraphFromMarkdown(text);
    const quote = blockquote || createFormatContainer('blockquote', QuoteFormat);
    quote.blocks.push(paragraph);
    return quote;
}