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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

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