usehooks
usehooks copied to clipboard
Update useCopyToClipboard to handle multiple formats
Example of how to do this outside this hook. Would be nice to use this hook and be able to pass multiple formats.
const plainText = "Hello, this is plain text!";
const htmlText = `<p style="color:blue;">Hello, this is <strong>HTML</strong> text!</p>`;
const markdownText = "**Hello**, this is Markdown text!";
// Create a ClipboardItem with multiple formats
const clipboardItem = new ClipboardItem({
"text/plain": new Blob([plainText], { type: "text/plain" }),
"text/html": new Blob([htmlText], { type: "text/html" }),
"text/markdown": new Blob([markdownText], { type: "text/markdown" }),
});
// Write to clipboard
await navigator.clipboard.write([clipboardItem]);