mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-11-18 19:57:04 +08:00
ctrl s and o save and open workflow
This commit is contained in:
parent
17d6f0548f
commit
dd3aa2f0a3
@ -11,13 +11,15 @@ app.registerExtension({
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.ctrlKey || event.altKey || event.metaKey) {
|
||||
return;
|
||||
}
|
||||
|
||||
const keyToButtonIdMap = {
|
||||
"Enter": "queue-button",
|
||||
"f": "queue-front-button",
|
||||
"q": "view-queue-button",
|
||||
"h": "view-history-button",
|
||||
"s": "save-button",
|
||||
"l": "load-button",
|
||||
"r": "refresh-button",
|
||||
"c": "clear-button",
|
||||
"d": "load-default-button",
|
||||
|
||||
@ -691,11 +691,40 @@ class ComfyApp {
|
||||
#addKeyboardHandler() {
|
||||
window.addEventListener("keydown", (e) => {
|
||||
this.shiftDown = e.shiftKey;
|
||||
const modifierPressed = e.ctrlKey || e.metaKey;
|
||||
|
||||
// Queue prompt using ctrl or command + enter
|
||||
if ((e.ctrlKey || e.metaKey) && (e.key === "Enter" || e.keyCode === 13 || e.keyCode === 10)) {
|
||||
if (modifierPressed && (e.key === "Enter" || e.keyCode === 13 || e.keyCode === 10)) {
|
||||
this.queuePrompt(e.shiftKey ? -1 : 0);
|
||||
}
|
||||
|
||||
// Save workflow using ctrl or command + s
|
||||
if (modifierPressed && (e.key === "s" || e.keyCode === 83)) {
|
||||
e.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 a = $el("a", {
|
||||
href: url,
|
||||
download: "workflow.json",
|
||||
style: { display: "none" },
|
||||
parent: document.body,
|
||||
});
|
||||
a.click();
|
||||
setTimeout(function () {
|
||||
a.remove();
|
||||
window.URL.revokeObjectURL(url);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
// Load workflow using ctrl or command + o
|
||||
if (modifierPressed && (e.key === "o" || e.keyCode === 79)) {
|
||||
e.preventDefault();
|
||||
|
||||
const fileInput = document.querySelector("#comfy-file-input");
|
||||
fileInput.click()
|
||||
}
|
||||
});
|
||||
window.addEventListener("keyup", (e) => {
|
||||
this.shiftDown = e.shiftKey;
|
||||
|
||||
@ -432,6 +432,7 @@ export class ComfyUI {
|
||||
});
|
||||
|
||||
const fileInput = $el("input", {
|
||||
id: "comfy-file-input",
|
||||
type: "file",
|
||||
accept: ".json,image/png",
|
||||
style: { display: "none" },
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user