Refactor canvas preview visibility and widget loading

Refactored Canvas.js to use an async waitForWidget method for reliably finding widgets before manipulating them. The setPreviewVisibility method is now async and simplified, with excessive debug logging removed. CanvasState.js now triggers a render after saving state. In CanvasView.js, initial state loading is deferred and preview visibility is managed in the Canvas constructor, removing redundant calls.
This commit is contained in:
Dariusz L
2025-07-01 06:32:06 +02:00
parent 40c1dbfb5d
commit 30fb89451f
3 changed files with 37 additions and 70 deletions

View File

@@ -1105,14 +1105,12 @@ async function createCanvasWidget(node, widget, app) {
if (!window.canvasExecutionStates) {
window.canvasExecutionStates = new Map();
}
node.canvasWidget = canvas;
console.log('Canvas widget element:', node.element);
console.log('Canvas widget canvas:', node.canvas);
console.log('Canvas widget parent:', node.parent);
setTimeout(() => {
canvas.loadInitialState();
}, 100);
// Konfiguracja opcji ukrywania podglądu
const showPreviewWidget = node.widgets.find(w => w.name === "show_preview");
@@ -1134,11 +1132,12 @@ async function createCanvasWidget(node, widget, app) {
node.setDirtyCanvas(true, true);
}
};
// Podgląd jest automatycznie ukrywany w konstruktorze Canvas.js
// Nie potrzebujemy już wywoływać setInitialPreviewVisibility
}
setTimeout(() => {
canvas.loadInitialState();
}, 100);
return {
canvas: canvas,