All files / roosterjs-content-model-plugins/lib/imageEdit/utils getHTMLImageOptions.ts

100% Statements 6/6
64.29% Branches 9/14
100% Functions 1/1
100% Lines 5/5

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 271x               1x 1x         1x         21x              
import { isASmallImage } from './imageEditUtils';
import type { IEditor, ImageMetadataFormat } from 'roosterjs-content-model-types';
import type { ImageEditOptions } from '../types/ImageEditOptions';
import type { ImageHtmlOptions } from '../types/ImageHtmlOptions';
 
/**
 * Default background colors for rotate handle
 */
const LIGHT_MODE_BGCOLOR = 'white';
const DARK_MODE_BGCOLOR = '#333';
 
/**
 * @internal
 */
export const getHTMLImageOptions = (
    editor: IEditor,
    options: ImageEditOptions,
    editInfo: ImageMetadataFormat
): ImageHtmlOptions => {
    return {
        borderColor:
            options.borderColor || (editor.isDarkMode() ? DARK_MODE_BGCOLOR : LIGHT_MODE_BGCOLOR),
        rotateHandleBackColor: editor.isDarkMode() ? DARK_MODE_BGCOLOR : LIGHT_MODE_BGCOLOR,
        isSmallImage: isASmallImage(editInfo.widthPx ?? 0, editInfo.heightPx ?? 0),
    };
};