All files / roosterjs-content-model-plugins/lib/paste/PowerPoint processPastedContentFromPowerPoint.ts

100% Statements 6/6
88.89% Branches 8/9
100% Functions 1/1
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 19 20 21 22 23 241x                 1x       20x   10x     1x   1x      
import { moveChildNodes } from 'roosterjs-content-model-dom';
import type { BeforePasteEvent, DOMCreator } from 'roosterjs-content-model-types';
 
/**
 * @internal
 * Convert pasted content from PowerPoint
 * @param event The BeforePaste event
 */
 
export function processPastedContentFromPowerPoint(
    event: BeforePasteEvent,
    domCreator: DOMCreator
) {
    const { fragment, clipboardData } = event;
 
    if (clipboardData.html && !clipboardData.text && clipboardData.image) {
        // It is possible that PowerPoint copied both image and HTML but not plain text.
        // We always prefer HTML if any.
        const doc = domCreator.htmlToDOM(clipboardData.html);
 
        moveChildNodes(fragment, doc?.body);
    }
}