update keybinds table, prepends comfy to ids

This commit is contained in:
EllangoK 2023-04-14 13:20:50 -04:00
parent 39ad59ec61
commit 1fef809cc2
3 changed files with 34 additions and 48 deletions

View File

@ -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/) Workflow examples can be found on the [Examples page](https://comfyanonymous.github.io/ComfyUI_examples/)
## Shortcuts/Keybinds ## Shortcuts
| Keybind | Explanation | | Keybind | Explanation |
| - | - | | - | - |
| Ctrl + Enter | Queues up current graph for generation | | Ctrl + Enter | Queue up current graph for generation |
| Ctrl + Shift + Enter | Queues up current graph as first for generation | | Ctrl + Shift + Enter | Queue up current graph as first for generation |
| Ctrl + S | Saves workflow | | Ctrl + S | Save workflow |
| Ctrl + O | Load workflow | | Ctrl + O | Load workflow |
| Ctrl + A | Select all nodes | | Ctrl + A | Select all nodes |
| Ctrl + M | Mute/unmute selected 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 + 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) | | 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 | | Shift + Drag | Move multiple selected nodes at the same time |
| Q | Toggles visibility of the queue | | Ctrl + D | Load default graph |
| H | Toggles visibility of history | | Q | Toggle visibility of the queue |
| R | Refreshes graph | | H | Toggle visibility of history |
| D | Loads default graph | | R | Refresh graph |
Ctrl can also be replaced with Cmd instead for MacOS users Ctrl can also be replaced with Cmd instead for MacOS users

View File

@ -23,30 +23,8 @@ app.registerExtension({
if (modifierPressed && (event.key === "s" || event.keyCode === 83)) { if (modifierPressed && (event.key === "s" || event.keyCode === 83)) {
event.preventDefault(); event.preventDefault();
const json = JSON.stringify(app.graph.serialize(), null, 2); // convert the data to a JSON string const saveButton = document.querySelector("#comfy-save-button");
const blob = new Blob([json], { type: "application/json" }); saveButton.click()
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);
} }
// Load workflow using ctrl or command + o // Load workflow using ctrl or command + o
@ -59,14 +37,14 @@ app.registerExtension({
// Delete all nodes using ctrl or command + backspace or delete // Delete all nodes using ctrl or command + backspace or delete
if (modifierPressed && ((event.key === "Backspace" || event.keyCode === 8) || (event.key === "Delete" || event.keyCode === 46))) { 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() clearButton.click()
} }
// Load default workflow using ctrl or command + d // Load default workflow using ctrl or command + d
if (modifierPressed && (event.key === "d" || event.keyCode === 68)) { if (modifierPressed && (event.key === "d" || event.keyCode === 68)) {
event.preventDefault(); event.preventDefault();
const loadDefaultButton = document.querySelector("#load-default-button"); const loadDefaultButton = document.querySelector("#comfy-load-default-button");
loadDefaultButton.click() loadDefaultButton.click()
} }
@ -76,12 +54,12 @@ app.registerExtension({
} }
const keyToButtonIdMap = { const keyToButtonIdMap = {
"q": "view-queue-button", "q": "comfy-view-queue-button",
81: "view-queue-button", 81: "comfy-view-queue-button",
"h": "view-history-button", "h": "comfy-view-history-button",
72: "view-history-button", 72: "comfy-view-history-button",
"r": "refresh-button", "r": "comfy-refresh-button",
82: "refresh-button", 82: "comfy-refresh-button",
}; };
const buttonId = keyToButtonIdMap[event.key] || keyToButtonIdMap[event.keyCode]; const buttonId = keyToButtonIdMap[event.key] || keyToButtonIdMap[event.keyCode];

View File

@ -501,7 +501,7 @@ export class ComfyUI {
$el("button", { id: "queue-front-button", textContent: "Queue Front", onclick: () => app.queuePrompt(-1, this.batchCount) }), $el("button", { id: "queue-front-button", textContent: "Queue Front", onclick: () => app.queuePrompt(-1, this.batchCount) }),
$el("button", { $el("button", {
$: (b) => (this.queue.button = b), $: (b) => (this.queue.button = b),
id: "view-queue-button", id: "comfy-view-queue-button",
textContent: "View Queue", textContent: "View Queue",
onclick: () => { onclick: () => {
this.history.hide(); this.history.hide();
@ -510,7 +510,7 @@ export class ComfyUI {
}), }),
$el("button", { $el("button", {
$: (b) => (this.history.button = b), $: (b) => (this.history.button = b),
id: "view-history-button", id: "comfy-view-history-button",
textContent: "View History", textContent: "View History",
onclick: () => { onclick: () => {
this.queue.hide(); this.queue.hide();
@ -521,15 +521,23 @@ export class ComfyUI {
this.queue.element, this.queue.element,
this.history.element, this.history.element,
$el("button", { $el("button", {
id: "save-button", id: "comfy-save-button",
textContent: "Save", textContent: "Save",
onclick: () => { 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 json = JSON.stringify(app.graph.serialize(), null, 2); // convert the data to a JSON string
const blob = new Blob([json], { type: "application/json" }); const blob = new Blob([json], { type: "application/json" });
const url = URL.createObjectURL(blob); const url = URL.createObjectURL(blob);
const a = $el("a", { const a = $el("a", {
href: url, href: url,
download: "workflow.json", download: fileName,
style: { display: "none" }, style: { display: "none" },
parent: document.body, parent: document.body,
}); });
@ -540,15 +548,15 @@ export class ComfyUI {
}, 0); }, 0);
}, },
}), }),
$el("button", { id: "load-button", textContent: "Load", onclick: () => fileInput.click() }), $el("button", { id: "comfy-load-button", textContent: "Load", onclick: () => fileInput.click() }),
$el("button", { id: "refresh-button", textContent: "Refresh", onclick: () => app.refreshComboInNodes() }), $el("button", { id: "comfy-refresh-button", textContent: "Refresh", onclick: () => app.refreshComboInNodes() }),
$el("button", { id: "clear-button", textContent: "Clear", onclick: () => { $el("button", { id: "comfy-clear-button", textContent: "Clear", onclick: () => {
if (!confirmClear.value || confirm("Clear workflow?")) { if (!confirmClear.value || confirm("Clear workflow?")) {
app.clean(); app.clean();
app.graph.clear(); 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?")) { if (!confirmClear.value || confirm("Load default workflow?")) {
app.loadGraphData() app.loadGraphData()
} }