From 1fef809cc29b71a7607172aa18f7758700e91180 Mon Sep 17 00:00:00 2001 From: EllangoK Date: Fri, 14 Apr 2023 13:20:50 -0400 Subject: [PATCH] update keybinds table, prepends comfy to ids --- README.md | 16 ++++++------- web/extensions/core/keybinds.js | 42 ++++++++------------------------- web/scripts/ui.js | 24 ++++++++++++------- 3 files changed, 34 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index 5244306f1..f610f9497 100644 --- a/README.md +++ b/README.md @@ -31,13 +31,13 @@ This ui will let you design and execute advanced stable diffusion pipelines usin Workflow examples can be found on the [Examples page](https://comfyanonymous.github.io/ComfyUI_examples/) -## Shortcuts/Keybinds +## Shortcuts | Keybind | Explanation | | - | - | -| Ctrl + Enter | Queues up current graph for generation | -| Ctrl + Shift + Enter | Queues up current graph as first for generation | -| Ctrl + S | Saves workflow | +| Ctrl + Enter | Queue up current graph for generation | +| Ctrl + Shift + Enter | Queue up current graph as first for generation | +| Ctrl + S | Save workflow | | Ctrl + O | Load workflow | | Ctrl + A | Select all nodes | | Ctrl + M | Mute/unmute selected nodes | @@ -48,10 +48,10 @@ Workflow examples can be found on the [Examples page](https://comfyanonymous.git | Ctrl + C/Ctrl + V | Copy and paste selected nodes (without maintaining connections to outputs of unselected nodes) | | Ctrl + C/Ctrl + Shift + V| Copy and paste selected nodes (maintaining connections from outputs of unselected nodes to inputs of pasted nodes) | | Shift + Drag | Move multiple selected nodes at the same time | -| Q | Toggles visibility of the queue | -| H | Toggles visibility of history | -| R | Refreshes graph | -| D | Loads default graph | +| Ctrl + D | Load default graph | +| Q | Toggle visibility of the queue | +| H | Toggle visibility of history | +| R | Refresh graph | Ctrl can also be replaced with Cmd instead for MacOS users diff --git a/web/extensions/core/keybinds.js b/web/extensions/core/keybinds.js index b42ebbb7c..ffb139cbc 100644 --- a/web/extensions/core/keybinds.js +++ b/web/extensions/core/keybinds.js @@ -23,30 +23,8 @@ app.registerExtension({ if (modifierPressed && (event.key === "s" || event.keyCode === 83)) { event.preventDefault(); - const json = JSON.stringify(app.graph.serialize(), null, 2); // convert the data to a JSON string - const blob = new Blob([json], { type: "application/json" }); - const url = URL.createObjectURL(blob); - - const defaultFileName = "workflow.json"; - const userFileName = prompt("Save workflow as:", defaultFileName); - if (userFileName === null) return; - const fileName = userFileName ? userFileName : defaultFileName; - - if (!fileName.endsWith(".json")) { - fileName += ".json"; - } - - const a = $el("a", { - href: url, - download: fileName, - style: { display: "none" }, - parent: document.body, - }); - a.click(); - setTimeout(() => { - a.remove(); - window.URL.revokeObjectURL(url); - }, 0); + const saveButton = document.querySelector("#comfy-save-button"); + saveButton.click() } // Load workflow using ctrl or command + o @@ -59,14 +37,14 @@ app.registerExtension({ // Delete all nodes using ctrl or command + backspace or delete if (modifierPressed && ((event.key === "Backspace" || event.keyCode === 8) || (event.key === "Delete" || event.keyCode === 46))) { - const clearButton = document.querySelector("#clear-button"); + const clearButton = document.querySelector("#comfy-clear-button"); clearButton.click() } // Load default workflow using ctrl or command + d if (modifierPressed && (event.key === "d" || event.keyCode === 68)) { event.preventDefault(); - const loadDefaultButton = document.querySelector("#load-default-button"); + const loadDefaultButton = document.querySelector("#comfy-load-default-button"); loadDefaultButton.click() } @@ -76,12 +54,12 @@ app.registerExtension({ } const keyToButtonIdMap = { - "q": "view-queue-button", - 81: "view-queue-button", - "h": "view-history-button", - 72: "view-history-button", - "r": "refresh-button", - 82: "refresh-button", + "q": "comfy-view-queue-button", + 81: "comfy-view-queue-button", + "h": "comfy-view-history-button", + 72: "comfy-view-history-button", + "r": "comfy-refresh-button", + 82: "comfy-refresh-button", }; const buttonId = keyToButtonIdMap[event.key] || keyToButtonIdMap[event.keyCode]; diff --git a/web/scripts/ui.js b/web/scripts/ui.js index 83ad0fbab..8b75cda72 100644 --- a/web/scripts/ui.js +++ b/web/scripts/ui.js @@ -501,7 +501,7 @@ export class ComfyUI { $el("button", { id: "queue-front-button", textContent: "Queue Front", onclick: () => app.queuePrompt(-1, this.batchCount) }), $el("button", { $: (b) => (this.queue.button = b), - id: "view-queue-button", + id: "comfy-view-queue-button", textContent: "View Queue", onclick: () => { this.history.hide(); @@ -510,7 +510,7 @@ export class ComfyUI { }), $el("button", { $: (b) => (this.history.button = b), - id: "view-history-button", + id: "comfy-view-history-button", textContent: "View History", onclick: () => { this.queue.hide(); @@ -521,15 +521,23 @@ export class ComfyUI { this.queue.element, this.history.element, $el("button", { - id: "save-button", + id: "comfy-save-button", textContent: "Save", onclick: () => { + const defaultFileName = "workflow.json"; + const userFileName = prompt("Save workflow as:", defaultFileName); + if (userFileName === null) return; + let fileName = userFileName ? userFileName : defaultFileName; + + if (!fileName.endsWith(".json")) { + fileName += ".json"; + } const json = JSON.stringify(app.graph.serialize(), null, 2); // convert the data to a JSON string const blob = new Blob([json], { type: "application/json" }); const url = URL.createObjectURL(blob); const a = $el("a", { href: url, - download: "workflow.json", + download: fileName, style: { display: "none" }, parent: document.body, }); @@ -540,15 +548,15 @@ export class ComfyUI { }, 0); }, }), - $el("button", { id: "load-button", textContent: "Load", onclick: () => fileInput.click() }), - $el("button", { id: "refresh-button", textContent: "Refresh", onclick: () => app.refreshComboInNodes() }), - $el("button", { id: "clear-button", textContent: "Clear", onclick: () => { + $el("button", { id: "comfy-load-button", textContent: "Load", onclick: () => fileInput.click() }), + $el("button", { id: "comfy-refresh-button", textContent: "Refresh", onclick: () => app.refreshComboInNodes() }), + $el("button", { id: "comfy-clear-button", textContent: "Clear", onclick: () => { if (!confirmClear.value || confirm("Clear workflow?")) { app.clean(); app.graph.clear(); } }}), - $el("button", { id: "load-default-button", textContent: "Load Default", onclick: () => { + $el("button", { id: "comfy-load-default-button", textContent: "Load Default", onclick: () => { if (!confirmClear.value || confirm("Load default workflow?")) { app.loadGraphData() }