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 | 1x 71x 11x 11x 11x 20x 20x 16x | import type { ShallowMutableContentModelParagraph } from 'roosterjs-content-model-types';
/**
* @internal
* Preserve specific paragraph format properties from source paragraph to target paragraph
* @param formatsToPreserveOnMerge Array of format property names to preserve
* @param paragraph Source paragraph to copy format from
* @param newParagraph Target paragraph to copy format to
*/
export function preserveParagraphFormat(
formatsToPreserveOnMerge: string[] | undefined,
paragraph: ShallowMutableContentModelParagraph,
newParagraph: ShallowMutableContentModelParagraph
) {
if (formatsToPreserveOnMerge && formatsToPreserveOnMerge.length) {
const format = paragraph.format as { [key: string]: string };
const newFormat = newParagraph.format as { [key: string]: string };
formatsToPreserveOnMerge.forEach(key => {
const formatValue = format[key];
if (formatValue !== undefined) {
newFormat[key] = formatValue;
}
});
}
}
|