mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-11-19 00:07:04 +08:00
adds keybinds that interact w/ comfy menu
This commit is contained in:
parent
3f52e7cbb1
commit
532a3e1e9d
31
web/extensions/core/keybinds.js
Normal file
31
web/extensions/core/keybinds.js
Normal file
@ -0,0 +1,31 @@
|
||||
import { app } from "/scripts/app.js";
|
||||
|
||||
const id = "Comfy.Keybinds";
|
||||
app.registerExtension({
|
||||
name: id,
|
||||
init() {
|
||||
const keybindListener = function(event) {
|
||||
const target = event.composedPath()[0];
|
||||
|
||||
if (target.tagName === "INPUT" || target.tagName === "TEXTAREA") {
|
||||
return;
|
||||
}
|
||||
|
||||
const keyToButtonIdMap = {
|
||||
"s": "save-button",
|
||||
"l": "load-button",
|
||||
"r": "refresh-button",
|
||||
"c": "clear-button",
|
||||
"d": "load-default-button"
|
||||
};
|
||||
|
||||
const buttonId = keyToButtonIdMap[event.key];
|
||||
if (buttonId) {
|
||||
const button = document.querySelector(`#${buttonId}`);
|
||||
button.dispatchEvent(new Event("click"));
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener("keyup", keybindListener);
|
||||
}
|
||||
});
|
||||
@ -517,6 +517,7 @@ export class ComfyUI {
|
||||
this.queue.element,
|
||||
this.history.element,
|
||||
$el("button", {
|
||||
id: "save-button",
|
||||
textContent: "Save",
|
||||
onclick: () => {
|
||||
const json = JSON.stringify(app.graph.serialize(), null, 2); // convert the data to a JSON string
|
||||
@ -535,15 +536,15 @@ export class ComfyUI {
|
||||
}, 0);
|
||||
},
|
||||
}),
|
||||
$el("button", { textContent: "Load", onclick: () => fileInput.click() }),
|
||||
$el("button", { textContent: "Refresh", onclick: () => app.refreshComboInNodes() }),
|
||||
$el("button", { textContent: "Clear", onclick: () => {
|
||||
$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: () => {
|
||||
if (!confirmClear.value || confirm("Clear workflow?")) {
|
||||
app.clean();
|
||||
app.graph.clear();
|
||||
}
|
||||
}}),
|
||||
$el("button", { textContent: "Load Default", onclick: () => {
|
||||
$el("button", { id: "load-default-button", textContent: "Load Default", onclick: () => {
|
||||
if (!confirmClear.value || confirm("Load default workflow?")) {
|
||||
app.loadGraphData()
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user