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 | 1x 1x 1x 5x 5x 3x 3x 3x 2x 1x 1x 3x 3x | import { createParagraphDecorator } from 'roosterjs-content-model-dom';
import { formatParagraphWithContentModel } from '../utils/formatParagraphWithContentModel';
import type { IEditor } from 'roosterjs-content-model-types';
/**
* Toggles the current block(s) margin properties.
* null deletes any existing value, undefined is ignored
* @param editor The editor to operate on
* @param marginTop value for top margin
* @param marginBottom value for bottom margin
*/
export function setParagraphMargin(
editor: IEditor,
marginTop?: string | null,
marginBottom?: string | null
) {
editor.focus();
formatParagraphWithContentModel(editor, 'setParagraphMargin', para => {
Eif (!para.decorator) {
para.decorator = createParagraphDecorator('p');
}
if (marginTop) {
para.format.marginTop = marginTop;
} else Eif (marginTop === null) {
delete para.format.marginTop;
}
Iif (marginBottom) {
para.format.marginBottom = marginBottom;
} else Iif (marginBottom === null) {
delete para.format.marginBottom;
}
});
}
|