fix: properly append drakonwidget container to DOM for diagram rendering
This commit is contained in:
1 parent
ce137675c3
commit
c88b55d470
1 file changed
+8
-24
+8
-24
@@ -1356,30 +1356,14 @@ window.addEventListener('load', function() {
|
||||
// Set the diagram content
|
||||
widget.setDiagram('business-process', drakonDiagram, null, true);
|
||||
|
||||
// Position the widget in the container
|
||||
// The render() method creates a container with the canvas
|
||||
// We need to move it into our container
|
||||
setTimeout(function() {
|
||||
// The widget creates its own container - we need to extract the canvas
|
||||
var widgetContainer = widget.container || widget.canvas.parentElement;
|
||||
if (widgetContainer) {
|
||||
// Set explicit dimensions on our container
|
||||
canvasContainer.style.display = 'flex';
|
||||
canvasContainer.style.alignItems = 'center';
|
||||
canvasContainer.style.justifyContent = 'center';
|
||||
canvasContainer.style.overflow = 'hidden';
|
||||
|
||||
// Try to append the widget's content
|
||||
if (widget.canvas && widget.canvas.parentElement) {
|
||||
// The canvas might already be in the DOM
|
||||
// Just ensure our container has the right size
|
||||
var rect = canvasContainer.getBoundingClientRect();
|
||||
if (rect.width === 0 || rect.height === 0) {
|
||||
canvasContainer.style.height = '400px';
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 100);
|
||||
// Append the widget's container (with canvas) to our #drakon-canvas element
|
||||
if (widget.container) {
|
||||
canvasContainer.appendChild(widget.container);
|
||||
canvasContainer.style.display = 'flex';
|
||||
canvasContainer.style.alignItems = 'center';
|
||||
canvasContainer.style.justifyContent = 'center';
|
||||
canvasContainer.style.overflow = 'hidden';
|
||||
}
|
||||
});
|
||||
|
||||
// ============================================
|
||||
|
||||
Reference in new issue
Block a user