Undo and redo rebuild every node in place, with the same ids. Nodes 2.0 usually keeps each node's face, and the slot that holds a DOM panel only mounts an element when it is first made. So after Ctrl+Z every AusBoss node kept showing the removed node's panel, the rebuilt node's panel never reached the screen, and changes made on that face never reached the queued prompt. When an AusBoss node is removed, the panels it has on screen are remembered by graph, node id and widget name. When a node with that id is configured, each of its off-screen panels takes the place of the remembered one if that one still sits on this node's face. Classic mode, new and pasted nodes, and faces the frontend mounted itself are left alone.
27 lines
946 B
JavaScript
27 lines
946 B
JavaScript
// After undo or redo in Nodes 2.0, every AusBoss node face shows its own
|
|
// node's panels again (the why is in shared/face_handover.mjs).
|
|
//
|
|
// The hooks go on each node as it is made. A rebuilt node's panels exist by
|
|
// the time it is configured (every panel is built in onNodeCreated), and the
|
|
// hand-over waits one microtask, so the frontend has rebuilt the whole graph
|
|
// before any panel moves.
|
|
|
|
import { app } from "/scripts/app.js";
|
|
import { chainCallback, isAusbossNode } from "../shared/index.mjs";
|
|
import { createFaceHandover } from "../shared/face_handover.mjs";
|
|
|
|
const handover = createFaceHandover();
|
|
|
|
app.registerExtension({
|
|
name: "AusBoss.FaceHandover",
|
|
nodeCreated(node) {
|
|
if (!isAusbossNode(node)) return;
|
|
chainCallback(node, "onRemoved", function () {
|
|
handover.remember(this);
|
|
});
|
|
chainCallback(node, "onConfigure", function () {
|
|
queueMicrotask(() => handover.handOver(this));
|
|
});
|
|
},
|
|
});
|