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 | 1x 1x 1x 1x 1x 2x 2x 2x 2x 2x 2x | import { toggleModelBlockQuote } from '../../modelApi/block/toggleModelBlockQuote'; import type { ContentModelFormatContainerFormat, IEditor } from 'roosterjs-content-model-types'; const DefaultQuoteFormatLtr: ContentModelFormatContainerFormat = { borderLeft: '3px solid rgb(200, 200, 200)', textColor: 'rgb(102, 102, 102)', }; const DefaultQuoteFormatRtl: ContentModelFormatContainerFormat = { borderRight: '3px solid rgb(200, 200, 200)', textColor: 'rgb(102, 102, 102)', }; const BuildInQuoteFormat: ContentModelFormatContainerFormat = { marginTop: '1em', marginBottom: '1em', marginLeft: '40px', marginRight: '40px', }; /** * Toggle BLOCKQUOTE state of selected paragraphs. * If any selected paragraph is not under a BLOCKQUOTE, wrap them into a BLOCKQUOTE. * Otherwise, unwrap all related BLOCKQUOTEs. * @param editor The editor object to toggle BLOCKQUOTE onto * @param quoteFormat @optional Block format for the new quote object */ export function toggleBlockQuote( editor: IEditor, quoteFormat?: ContentModelFormatContainerFormat, quoteFormatRtl?: ContentModelFormatContainerFormat ) { const fullQuoteFormatLtr: ContentModelFormatContainerFormat = { ...BuildInQuoteFormat, paddingLeft: '10px', ...(quoteFormat ?? DefaultQuoteFormatLtr), }; const fullQuoteFormatRtl: ContentModelFormatContainerFormat = { ...BuildInQuoteFormat, paddingRight: '10px', direction: 'rtl', ...(quoteFormatRtl ?? quoteFormat ?? DefaultQuoteFormatRtl), }; editor.focus(); editor.formatContentModel( (model, context) => { context.newPendingFormat = 'preserve'; return toggleModelBlockQuote(model, fullQuoteFormatLtr, fullQuoteFormatRtl); }, { apiName: 'toggleBlockQuote', } ); } |