diff --git a/src/composables/toast/useCopyText.ts b/src/composables/toast/useCopyText.ts index 33e9bbfd0c..7b2fc47446 100644 --- a/src/composables/toast/useCopyText.ts +++ b/src/composables/toast/useCopyText.ts @@ -4,15 +4,19 @@ const useCopyText = () => { const { execWithToast } = useExecWithToast() const copyText = async (text: string, description?: string) => { + const type = 'text/plain' + const blob = new Blob([text], { type }) + const data = new ClipboardItem({ [type]: blob }) + if (description === undefined) { await execWithToast('コピーしました', 'コピーに失敗しました', () => - navigator.clipboard.writeText(text) + navigator.clipboard.write([data]) ) } else { await execWithToast( `${description}をコピーしました`, `${description}のコピーに失敗しました`, - () => navigator.clipboard.writeText(text) + () => navigator.clipboard.write([data]) ) } }