diff --git a/src/plugins/webContextMenus.web/index.ts b/src/plugins/webContextMenus.web/index.ts index 4cdbcd98..26ae19c5 100644 --- a/src/plugins/webContextMenus.web/index.ts +++ b/src/plugins/webContextMenus.web/index.ts @@ -218,10 +218,19 @@ export default definePlugin({ }, async paste() { - const text = await navigator.clipboard.readText(); + const clip = (await navigator.clipboard.read())[0]; + if (!clip) return; const data = new DataTransfer(); - data.setData("text/plain", text); + for (const type of clip.types) { + if (type === "image/png") { + const file = new File([await clip.getType(type)], "unknown.png", { type }); + data.items.add(file); + } else if (type === "text/plain") { + const blob = await clip.getType(type); + data.setData(type, await blob.text()); + } + } document.dispatchEvent( new ClipboardEvent("paste", {