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

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

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    1x             1x 11x   11x            
import type { GetSourceFunction, GetSourceInputParams } from './getPasteSource';
 
const ShadowWorkbookClipboardType = 'web data/shadow-workbook';
 
/**
 * @internal
 * When the clipboard content is retrieved programatically, the clipboard html does not contain the usual
 * attributes we use to determine if the content is from Excel. This function is used to handle that case.
 */
export const isExcelNotNativeEvent: GetSourceFunction = (props: GetSourceInputParams) => {
    const { clipboardData } = props;
 
    return (
        clipboardData.types.includes(ShadowWorkbookClipboardType) &&
        clipboardData.htmlFirstLevelChildTags?.length == 1 &&
        clipboardData.htmlFirstLevelChildTags[0] == 'TABLE'
    );
};