|
622 | 622 | mermaidDiv.style.display = 'block'; |
623 | 623 | mermaidDiv.style.visibility = 'visible'; |
624 | 624 | mermaidDiv.style.opacity = '1'; |
| 625 | + mermaidDiv.style.width = 'auto'; |
| 626 | + mermaidDiv.style.height = 'auto'; |
625 | 627 | wrapper.appendChild(mermaidDiv); |
626 | 628 |
|
627 | 629 | // Re-render with Mermaid |
|
630 | 632 | if (svg) { |
631 | 633 | svg.style.display = 'block'; |
632 | 634 | svg.style.visibility = 'visible'; |
| 635 | + svg.style.opacity = '1'; |
| 636 | + svg.style.width = 'auto'; |
| 637 | + svg.style.height = 'auto'; |
| 638 | + svg.style.maxWidth = 'none'; |
| 639 | + svg.style.maxHeight = 'none'; |
| 640 | + svg.removeAttribute('style'); // Remove any inline styles that might hide it |
| 641 | + svg.setAttribute('style', 'display: block !important; visibility: visible !important; opacity: 1 !important; width: auto !important; height: auto !important;'); |
633 | 642 | } |
| 643 | + |
| 644 | + // Also ensure the mermaid div itself is visible |
| 645 | + mermaidDiv.style.display = 'block'; |
| 646 | + mermaidDiv.style.visibility = 'visible'; |
| 647 | + mermaidDiv.style.opacity = '1'; |
| 648 | + }).catch((err) => { |
| 649 | + console.error('Mermaid rendering error:', err); |
| 650 | + // Fallback: clone the existing diagram |
| 651 | + const clone = diagramElement.cloneNode(true); |
| 652 | + clone.style.display = 'block'; |
| 653 | + clone.style.visibility = 'visible'; |
| 654 | + clone.style.opacity = '1'; |
| 655 | + wrapper.appendChild(clone); |
634 | 656 | }); |
635 | 657 | } else { |
636 | 658 | // Fallback: clone the existing diagram |
637 | 659 | const clone = diagramElement.cloneNode(true); |
638 | 660 | clone.style.display = 'block'; |
639 | 661 | clone.style.visibility = 'visible'; |
640 | 662 | clone.style.opacity = '1'; |
| 663 | + |
| 664 | + // Ensure SVG in clone is visible |
| 665 | + const svg = clone.querySelector('svg'); |
| 666 | + if (svg) { |
| 667 | + svg.style.display = 'block'; |
| 668 | + svg.style.visibility = 'visible'; |
| 669 | + svg.style.opacity = '1'; |
| 670 | + svg.style.width = 'auto'; |
| 671 | + svg.style.height = 'auto'; |
| 672 | + } |
| 673 | + |
641 | 674 | wrapper.appendChild(clone); |
642 | 675 | } |
643 | 676 |
|
|
669 | 702 | wrapper.style.display = 'flex'; |
670 | 703 | wrapper.style.visibility = 'visible'; |
671 | 704 | wrapper.style.opacity = '1'; |
| 705 | + wrapper.style.width = 'fit-content'; |
| 706 | + wrapper.style.height = 'fit-content'; |
672 | 707 |
|
673 | 708 | const mermaidEl = wrapper.querySelector('.mermaid'); |
674 | 709 | if (mermaidEl) { |
675 | 710 | mermaidEl.style.display = 'block'; |
676 | 711 | mermaidEl.style.visibility = 'visible'; |
677 | 712 | mermaidEl.style.opacity = '1'; |
| 713 | + mermaidEl.style.width = 'auto'; |
| 714 | + mermaidEl.style.height = 'auto'; |
678 | 715 | } |
679 | 716 |
|
680 | 717 | const svg = wrapper.querySelector('svg'); |
681 | 718 | if (svg) { |
682 | 719 | svg.style.display = 'block'; |
683 | 720 | svg.style.visibility = 'visible'; |
684 | 721 | svg.style.opacity = '1'; |
| 722 | + svg.style.width = 'auto'; |
| 723 | + svg.style.height = 'auto'; |
| 724 | + svg.style.maxWidth = 'none'; |
| 725 | + svg.style.maxHeight = 'none'; |
| 726 | + // Force visibility with important |
| 727 | + svg.setAttribute('style', 'display: block !important; visibility: visible !important; opacity: 1 !important; width: auto !important; height: auto !important; max-width: none !important; max-height: none !important;'); |
685 | 728 | } |
686 | 729 |
|
687 | 730 | // Center scroll position |
|
693 | 736 | content.scrollLeft = (content.scrollWidth - content.clientWidth) / 2; |
694 | 737 | } |
695 | 738 | }, 200); |
696 | | - }, 300); |
| 739 | + }, 500); // Increased timeout to ensure Mermaid has finished rendering |
697 | 740 |
|
698 | 741 | // Focus on close button for accessibility |
699 | 742 | const closeBtn = overlay.querySelector('.close-fullscreen-btn'); |
|
0 commit comments