Clear clipboard on copy

This commit is contained in:
Michael Abrahams 2023-09-08 11:17:45 -04:00
parent 1e6b67101c
commit 264867bf87
1 changed files with 16 additions and 5 deletions

View File

@ -735,9 +735,17 @@ export class ComfyApp {
*/
#addCopyHandler() {
document.addEventListener("copy", (e) => {
// copy
if (e.target.type === "text" || e.target.type === "textarea") {
// Default system copy
return;
}
// copy nodes and clear clipboard
if (this.canvas.selected_nodes) {
this.canvas.copyToClipboard();
this.canvas.copyToClipboard();
e.clipboardData.clearData();
e.preventDefault();
e.stopImmediatePropagation();
return false;
}
});
}
@ -842,10 +850,13 @@ export class ComfyApp {
if ((e.key === 'c') && (e.metaKey || e.ctrlKey)) {
if (e.shiftKey) {
this.copyToClipboard(true);
e.clipboardData.clearData();
block_default = true;
}
// Trigger default onCopy
return true;
else {
// Trigger onCopy
return true;
}
}
// Ctrl+V Paste
@ -855,7 +866,7 @@ export class ComfyApp {
block_default = true;
}
else {
// Trigger default onPaste
// Trigger onPaste
return true;
}
}