mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-02-15 16:02:32 +08:00
Added basic ctrl+z, only undoes a single operation.
This commit is contained in:
parent
c16f5744e3
commit
af573e16a0
@ -928,6 +928,20 @@ export class ComfyApp {
|
|||||||
block_default = true;
|
block_default = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ctrl + Z undo last operation
|
||||||
|
if (e.key === 'z' && e.ctrlKey) {
|
||||||
|
try {
|
||||||
|
const json = localStorage.getItem("ctrlZ");
|
||||||
|
if (json) {
|
||||||
|
const workflow = JSON.parse(json);
|
||||||
|
self.loadGraphData(workflow, false);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Error loading previous workflow", err);
|
||||||
|
}
|
||||||
|
block_default = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Ctrl+C Copy
|
// Ctrl+C Copy
|
||||||
if ((e.key === 'c') && (e.metaKey || e.ctrlKey)) {
|
if ((e.key === 'c') && (e.metaKey || e.ctrlKey)) {
|
||||||
// Trigger onCopy
|
// Trigger onCopy
|
||||||
@ -1298,7 +1312,14 @@ export class ComfyApp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Save current workflow automatically
|
// Save current workflow automatically
|
||||||
setInterval(() => localStorage.setItem("workflow", JSON.stringify(this.graph.serialize())), 1000);
|
setInterval(function(){
|
||||||
|
const previous_workflow = localStorage.getItem("workflow")
|
||||||
|
const workflow = JSON.stringify(this.graph.serialize())
|
||||||
|
if(previous_workflow !== workflow){
|
||||||
|
localStorage.setItem("ctrlZ", previous_workflow); // Save workflow for loading at ctrl + Z
|
||||||
|
}
|
||||||
|
localStorage.setItem("workflow", workflow); // Save current workflow for loading at startup
|
||||||
|
},1000);
|
||||||
|
|
||||||
this.#addDrawNodeHandler();
|
this.#addDrawNodeHandler();
|
||||||
this.#addDrawGroupsHandler();
|
this.#addDrawGroupsHandler();
|
||||||
@ -1409,9 +1430,12 @@ export class ComfyApp {
|
|||||||
/**
|
/**
|
||||||
* Populates the graph with the specified workflow data
|
* Populates the graph with the specified workflow data
|
||||||
* @param {*} graphData A serialized graph object
|
* @param {*} graphData A serialized graph object
|
||||||
|
* @param state_reset if given and set to true, the state will not be updated
|
||||||
*/
|
*/
|
||||||
loadGraphData(graphData) {
|
loadGraphData(graphData, state_reset = true) {
|
||||||
this.clean();
|
if (state_reset){
|
||||||
|
this.clean();
|
||||||
|
}
|
||||||
|
|
||||||
let reset_invalid_values = false;
|
let reset_invalid_values = false;
|
||||||
if (!graphData) {
|
if (!graphData) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user