mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-22 07:46:16 -04:00
feat: added the ability to paste images onto the input tab
This commit is contained in:
parent
d635cca210
commit
3c40137c2d
1 changed files with 17 additions and 0 deletions
|
@ -151,6 +151,20 @@ class InputWaiter {
|
|||
// Event handlers
|
||||
EditorView.domEventHandlers({
|
||||
paste(event, view) {
|
||||
const clipboardData = event.clipboardData || window.clipboardData;
|
||||
const items = clipboardData.items;
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
const item = items[i];
|
||||
if (item.type.indexOf("image") !== -1) {
|
||||
const file = item.getAsFile();
|
||||
|
||||
const files = [file];
|
||||
event.target.files = files;
|
||||
|
||||
event.preventDefault(); // Prevent the default paste behavior
|
||||
}
|
||||
}
|
||||
setTimeout(() => {
|
||||
self.afterPaste(event);
|
||||
});
|
||||
|
@ -917,6 +931,9 @@ class InputWaiter {
|
|||
* @param {event} e
|
||||
*/
|
||||
afterPaste(e) {
|
||||
if (e.target.files) {
|
||||
this.loadUIFiles(e.target.files);
|
||||
}
|
||||
// If EOL has been fixed, skip this.
|
||||
if (this.eolState > 1) return;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue