All files / roosterjs-content-model-api/lib/publicApi/image setImageBorder.ts

100% Statements 6/6
100% Branches 0/0
100% Functions 2/2
100% Lines 6/6

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 191x 1x                   1x 9x   9x 6x      
import { applyImageBorderFormat } from '../../modelApi/image/applyImageBorderFormat';
import { formatImageWithContentModel } from '../utils/formatImageWithContentModel';
import type { Border, ContentModelImage, IEditor } from 'roosterjs-content-model-types';
 
/**
 * Set image border style for all selected images at selection.
 * @param editor The editor instance
 * @param border the border format object. Ex: { color: 'red', width: '10px', style: 'solid'}, if one of the value in object is undefined
 * its value will not be changed. Passing null instead of an object will remove the border
 * @param borderRadius the border radius value, if undefined, the border radius will keep the actual value
 */
export function setImageBorder(editor: IEditor, border: Border | null, borderRadius?: string) {
    editor.focus();
 
    formatImageWithContentModel(editor, 'setImageBorder', (image: ContentModelImage) => {
        applyImageBorderFormat(image, border, borderRadius);
    });
}