Paste spreadsheets as text (#2200)
This commit is contained in:
parent
d71dad8568
commit
98fb680a92
@ -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);
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user