mirror of
https://github.com/gchq/CyberChef.git
synced 2024-11-02 22:21:01 +01:00
Input pasting now works
This commit is contained in:
parent
8cb86c364d
commit
145fba5949
@ -463,6 +463,34 @@ class InputWaiter {
|
||||
}
|
||||
// inputPaste
|
||||
|
||||
/**
|
||||
* Handler for input paste events
|
||||
* Checks that the size of the input is below the display limit, otherwise treats it as a file/blob
|
||||
*
|
||||
* @param {event} e
|
||||
*/
|
||||
inputPaste(e) {
|
||||
const pastedData = e.clipboardData.getData("Text");
|
||||
if (pastedData.length < (this.app.options.ioDisplayThreshold * 1024)) {
|
||||
// inputChange() was being fired before the input value
|
||||
// was set, so add it here instead
|
||||
e.preventDefault();
|
||||
document.getElementById("input-text").value += pastedData;
|
||||
this.inputChange(e);
|
||||
} else {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
const file = new File([pastedData], "PastedData", {
|
||||
type: "text/plain",
|
||||
lastModified: Date.now()
|
||||
});
|
||||
|
||||
this.loadUIFiles([file]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handler for input dragover events.
|
||||
|
@ -145,7 +145,7 @@ class Manager {
|
||||
|
||||
// Input
|
||||
this.addMultiEventListener("#input-text", "keyup", this.input.inputChange, this.input);
|
||||
// this.addMultiEventListener("#input-text", "paste", this.input.inputPaste, this.input);
|
||||
this.addMultiEventListener("#input-text", "paste", this.input.inputPaste, this.input);
|
||||
document.getElementById("reset-layout").addEventListener("click", this.app.resetLayout.bind(this.app));
|
||||
// document.getElementById("clr-io").addEventListener("click", this.input.clearAllIoClick.bind(this.input));
|
||||
this.addListeners("#open-file,#open-folder", "change", this.input.inputOpen, this.input);
|
||||
|
Loading…
Reference in New Issue
Block a user