aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorV <vendicated@riseup.net>2023-09-27 04:13:40 +0200
committerV <vendicated@riseup.net>2023-09-27 04:13:40 +0200
commit4facc3cad70fed86828ce7700e8fe11b3504bc0f (patch)
tree1d7b0a7321516280aeee2d8916d64989b7289568 /src
parent837d1fc08334f569da8fe332ee72ef8c8560d9ef (diff)
downloadVencord-4facc3cad70fed86828ce7700e8fe11b3504bc0f.tar.gz
Vencord-4facc3cad70fed86828ce7700e8fe11b3504bc0f.tar.bz2
Vencord-4facc3cad70fed86828ce7700e8fe11b3504bc0f.zip
webContextMenus: support pasting images
Diffstat (limited to 'src')
-rw-r--r--src/plugins/webContextMenus.web/index.ts13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/plugins/webContextMenus.web/index.ts b/src/plugins/webContextMenus.web/index.ts
index 4cdbcd9..26ae19c 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", {