- Implemented ComfyGenerateRequest type and associated functions for generating images using various architectures and modes. - Added functions for listing generation options and handling image uploads. - Created workflows for different generation modes including SDXL, Z-Image, Z-Image Turbo, and Anima. - Introduced GenerationJobStatus component to display the status of ongoing generation jobs. - Developed MaskControls for managing mask operations and displaying mask analysis. - Created palette items for tool selection, layer management, and generation settings.
56 lines
1.5 KiB
TypeScript
56 lines
1.5 KiB
TypeScript
import type { Command } from "./command";
|
|
import type { EditorState } from "@editor/state";
|
|
import { commandIds } from "./ids";
|
|
|
|
export const historyUndoCommand: Command = {
|
|
id: commandIds.historyUndo,
|
|
name: "Undo",
|
|
history: { mode: "ignore" },
|
|
execute({ state }) {
|
|
const previous = state.history.past.at(-1);
|
|
if (!previous) return state;
|
|
|
|
return {
|
|
...state,
|
|
document: previous.document,
|
|
editor: preserveGenerationJobs(previous.editor, state.editor),
|
|
history: {
|
|
past: state.history.past.slice(0, -1),
|
|
future: [{ document: state.document, editor: state.editor }, ...state.history.future],
|
|
},
|
|
};
|
|
},
|
|
};
|
|
|
|
export const historyRedoCommand: Command = {
|
|
id: commandIds.historyRedo,
|
|
name: "Redo",
|
|
history: { mode: "ignore" },
|
|
execute({ state }) {
|
|
const next = state.history.future[0];
|
|
if (!next) return state;
|
|
|
|
return {
|
|
...state,
|
|
document: next.document,
|
|
editor: preserveGenerationJobs(next.editor, state.editor),
|
|
history: {
|
|
past: [...state.history.past, { document: state.document, editor: state.editor }],
|
|
future: state.history.future.slice(1),
|
|
},
|
|
};
|
|
},
|
|
};
|
|
|
|
export const historyCommands = [historyUndoCommand, historyRedoCommand] satisfies Command<unknown>[];
|
|
|
|
function preserveGenerationJobs(target: EditorState, current: EditorState): EditorState {
|
|
return {
|
|
...target,
|
|
generation: {
|
|
...target.generation,
|
|
jobs: current.generation.jobs,
|
|
},
|
|
};
|
|
}
|