mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-11-18 23:57:05 +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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (event.ctrlKey || event.altKey || event.metaKey) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const keyToButtonIdMap = {
|
const keyToButtonIdMap = {
|
||||||
"Enter": "queue-button",
|
"Enter": "queue-button",
|
||||||
"f": "queue-front-button",
|
"f": "queue-front-button",
|
||||||
"q": "view-queue-button",
|
"q": "view-queue-button",
|
||||||
"h": "view-history-button",
|
"h": "view-history-button",
|
||||||
"s": "save-button",
|
|
||||||
"l": "load-button",
|
|
||||||
"r": "refresh-button",
|
"r": "refresh-button",
|
||||||
"c": "clear-button",
|
"c": "clear-button",
|
||||||
"d": "load-default-button",
|
"d": "load-default-button",
|
||||||
|
|||||||
@ -691,11 +691,40 @@ class ComfyApp {
|
|||||||
#addKeyboardHandler() {
|
#addKeyboardHandler() {
|
||||||
window.addEventListener("keydown", (e) => {
|
window.addEventListener("keydown", (e) => {
|
||||||
this.shiftDown = e.shiftKey;
|
this.shiftDown = e.shiftKey;
|
||||||
|
const modifierPressed = e.ctrlKey || e.metaKey;
|
||||||
|
|
||||||
// Queue prompt using ctrl or command + enter
|
// 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);
|
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) => {
|
window.addEventListener("keyup", (e) => {
|
||||||
this.shiftDown = e.shiftKey;
|
this.shiftDown = e.shiftKey;
|
||||||
|
|||||||
@ -432,6 +432,7 @@ export class ComfyUI {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const fileInput = $el("input", {
|
const fileInput = $el("input", {
|
||||||
|
id: "comfy-file-input",
|
||||||
type: "file",
|
type: "file",
|
||||||
accept: ".json,image/png",
|
accept: ".json,image/png",
|
||||||
style: { display: "none" },
|
style: { display: "none" },
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user