diff --git a/src/tools/base64-file-converter/base64-file-converter.vue b/src/tools/base64-file-converter/base64-file-converter.vue index a489f9a1..1d626dde 100644 --- a/src/tools/base64-file-converter/base64-file-converter.vue +++ b/src/tools/base64-file-converter/base64-file-converter.vue @@ -76,10 +76,28 @@ async function onUpload(file: File) { fileInput.value = file; } } + +function onPaste(event: ClipboardEvent) { + if (event.clipboardData) { + const { items } = event.clipboardData; + for (const item of items) { + if (item.kind === 'file') { + fileInput.value = item.getAsFile()!; + } + else if (item.kind === 'string' && item.type.match('^text/plain')) { + item.getAsString(s => base64Input.value = s); + } + else { + // eslint-disable-next-line no-console + console.info('Unsupport clipboardData', item); + } + } + } +}