2
0
mirror of https://github.com/gchq/CyberChef synced 2026-02-27 18:13:17 +00:00

Paste spreadsheets as text (#2200)

This commit is contained in:
GCHQ Developer 85297
2026-02-20 17:08:11 +00:00
committed by GitHub
parent d71dad8568
commit 98fb680a92

View File

@@ -153,16 +153,22 @@ class InputWaiter {
paste(event, view) {
const clipboardData = event.clipboardData;
const items = clipboardData.items;
const files = [];
let files = [];
for (let i = 0; i < items.length; i++) {
const item = items[i];
if (item.kind === "file") {
const file = item.getAsFile();
files.push(file);
event.preventDefault(); // Prevent the default paste behavior
if (item.kind === "string") {
// If there are any string items they should be preferred over
// files.
files = [];
break;
} else if (item.kind === "file") {
files.push(item.getAsFile());
}
}
if (files.length > 0) {
// Prevent the default paste behavior, afterPaste will load the files instead
event.preventDefault();
}
setTimeout(() => {
self.afterPaste(files);
});