diff --git a/markitect/clean_document_manager.py b/markitect/clean_document_manager.py index d5e1e23b..d3d3cd72 100644 --- a/markitect/clean_document_manager.py +++ b/markitect/clean_document_manager.py @@ -1104,9 +1104,16 @@ class CleanDocumentManager: document.addEventListener('DOMContentLoaded', function() {{ console.log("Rendering content..."); + // Check if modular components are being used + if (typeof SectionManager !== 'undefined') {{ + console.log("✓ Modular components detected - skipping direct content rendering"); + console.log("✓ Content will be rendered by modular architecture"); + return; + }} + const contentDiv = document.getElementById('markdown-content'); - // Step 1: Ensure content is always displayed + // Step 1: Ensure content is always displayed (fallback for non-modular mode) if (contentDiv) {{ if (typeof marked !== 'undefined') {{ try {{ @@ -1259,11 +1266,14 @@ document.addEventListener('DOMContentLoaded', function() { debugPanel.addMessage(`Changes cancelled for section: ${data.sectionId}`, 'WARNING'); }); - // Initialize with existing markdown content if present - const existingContent = container.textContent || container.innerText || ''; - if (existingContent.trim()) { - const sections = sectionManager.createSectionsFromMarkdown(existingContent); + // Initialize with markdown content + const markdownToRender = markdownContent || ''; + if (markdownToRender.trim()) { + const sections = sectionManager.createSectionsFromMarkdown(markdownToRender); domRenderer.renderAllSections(sections); + debugPanel.addMessage(`Initialized with ${sections.length} sections`, 'INFO'); + } else { + debugPanel.addMessage('No markdown content to initialize', 'WARNING'); } // Make components globally available for debugging