All files / app/codeCharta/util/clipboard clipboardWriter.ts

100% Statements 5/5
100% Branches 2/2
100% Functions 2/2
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 93x 1x 1x     3x 4x    
export async function setToClipboard(blob: Blob) {
    const data = [new ClipboardItem({ [blob.type]: blob })]
    await navigator.clipboard.write(data)
}
 
export function checkWriteToClipboardAllowed(): boolean {
    return "clipboard" in navigator && "write" in navigator.clipboard
}