ComfyUI takes undo steps on mouse-up and key-up; a drag-and-drop ends in neither, and writes made in click handlers or after a fetch landed in no step, so Ctrl+Z could undo the step before instead. canvas_history.js asks for a step after each write (applied values, drops, created or inserted nodes, recipes, prompt notes). A drop's receipt also pops up at the top right with Undo (shared with the receipt's own button); prompt nodes made by a drop on empty canvas can be undone there. canvas_undo.js keeps what each canvas activity entry did, in full, while the page is open; the log offers Undo while nothing changed it since. Entries that removed nodes or rewired existing ones, seeds, and choices this computer no longer has are never offered. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
31 lines
1.2 KiB
JavaScript
31 lines
1.2 KiB
JavaScript
/**
|
|
* A short message at the top right. With `action` ({ label, run }) it carries a button
|
|
* (an undo, say) and stays longer, and as long as the pointer is on it.
|
|
*/
|
|
export function showWorkbenchToast(message, action = null) {
|
|
const toast = document.createElement('div');
|
|
toast.className = 'anomalous-mixer-toast';
|
|
toast.append(document.createTextNode(message));
|
|
let timer = null;
|
|
const close = () => {
|
|
clearTimeout(timer);
|
|
toast.classList.remove('is-show');
|
|
setTimeout(() => toast.remove(), 300);
|
|
};
|
|
const wait = () => { timer = setTimeout(close, action ? 8000 : 2400); };
|
|
if (action) {
|
|
toast.classList.add('has-action');
|
|
const button = document.createElement('button');
|
|
button.type = 'button';
|
|
button.className = 'anomalous-mixer-toast-action';
|
|
button.textContent = action.label;
|
|
button.onclick = () => { close(); action.run(); };
|
|
toast.append(button);
|
|
toast.onpointerenter = () => clearTimeout(timer);
|
|
toast.onpointerleave = wait;
|
|
}
|
|
document.body.appendChild(toast);
|
|
setTimeout(() => toast.classList.add('is-show'), 10);
|
|
wait();
|
|
}
|