Fix copy/paste on firefox (#432)

This commit is contained in:
bymyself
2024-08-14 19:05:15 -07:00
committed by GitHub
parent 711205b499
commit 5c4d1c2cec

View File

@@ -1155,6 +1155,9 @@ export class ComfyApp {
*/ */
#addCopyHandler() { #addCopyHandler() {
document.addEventListener('copy', (e) => { document.addEventListener('copy', (e) => {
if (!(e.target instanceof Element)) {
return
}
if ( if (
(e.target instanceof HTMLTextAreaElement && (e.target instanceof HTMLTextAreaElement &&
e.target.type === 'textarea') || e.target.type === 'textarea') ||
@@ -1163,13 +1166,12 @@ export class ComfyApp {
// Default system copy // Default system copy
return return
} }
const isTargetInGraph =
e.target.classList.contains('litegraph') ||
e.target.classList.contains('graph-canvas-container')
// copy nodes and clear clipboard // copy nodes and clear clipboard
if ( if (isTargetInGraph && this.canvas.selected_nodes) {
e.target instanceof Element &&
e.target.classList.contains('litegraph') &&
this.canvas.selected_nodes
) {
this.canvas.copyToClipboard() this.canvas.copyToClipboard()
e.clipboardData.setData('text', ' ') //clearData doesn't remove images from clipboard e.clipboardData.setData('text', ' ') //clearData doesn't remove images from clipboard
e.preventDefault() e.preventDefault()