All files / roosterjs-content-model-plugins/lib/paste/pasteSourceValidations shouldConvertToSingleImage.ts

100% Statements 4/4
85.71% Branches 6/7
100% Functions 1/1
100% Lines 3/3

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                  1x 32x 16x            
import type { GetSourceFunction } from './getPasteSource';
 
/**
 * @internal
 * Checks whether the fragment only contains a single image to paste
 * and the editor have the ConvertSingleImageBody Experimental feature
 * @param props Properties related to the PasteEvent
 * @returns
 */
export const shouldConvertToSingleImage: GetSourceFunction = props => {
    const { shouldConvertSingleImage, clipboardData } = props;
    return (
        shouldConvertSingleImage &&
        clipboardData.htmlFirstLevelChildTags?.length == 1 &&
        clipboardData.htmlFirstLevelChildTags[0] == 'IMG'
    );
};