Skip to content

Commit 98fb680

Browse files
authored
Paste spreadsheets as text (gchq#2200)
1 parent d71dad8 commit 98fb680

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

src/web/waiters/InputWaiter.mjs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,22 @@ class InputWaiter {
153153
paste(event, view) {
154154
const clipboardData = event.clipboardData;
155155
const items = clipboardData.items;
156-
const files = [];
156+
let files = [];
157157
for (let i = 0; i < items.length; i++) {
158158
const item = items[i];
159-
if (item.kind === "file") {
160-
const file = item.getAsFile();
161-
files.push(file);
162-
163-
event.preventDefault(); // Prevent the default paste behavior
159+
if (item.kind === "string") {
160+
// If there are any string items they should be preferred over
161+
// files.
162+
files = [];
163+
break;
164+
} else if (item.kind === "file") {
165+
files.push(item.getAsFile());
164166
}
165167
}
168+
if (files.length > 0) {
169+
// Prevent the default paste behavior, afterPaste will load the files instead
170+
event.preventDefault();
171+
}
166172
setTimeout(() => {
167173
self.afterPaste(files);
168174
});

0 commit comments

Comments
 (0)