From c79cfd19c96bd088227b0bc6181e8f960e988978 Mon Sep 17 00:00:00 2001 From: tegwick Date: Fri, 2 Oct 2026 23:07:03 +0200 Subject: [PATCH] fix(main-updated): register section-manager handlers before the documentControls early return setupEventHandlers returned immediately when documentControls was absent (it is never created now), so changes-accepted was never wired and accepted edits updated the model but not the page. Verified end to end with a headless Chromium edit through markitect md-render. Co-Authored-By: Claude Sonnet 5.5 Assistant: claude-code Assistant-Model: sonnet Assistant-Process: 299063@bnt-lap001 Assistant-Session: 53eb1e1c-c13a-4277-9ce2-3702960d93f7 --- js/main-updated.js | 51 +++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/js/main-updated.js b/js/main-updated.js index 7575dff..070cbed 100644 --- a/js/main-updated.js +++ b/js/main-updated.js @@ -127,6 +127,32 @@ const MarkitectMain = { setupEventHandlers: function() { console.log('🔌 Setting up event handlers...'); + // Setup section manager event handlers + if (this.sectionManager) { + // The DOM refresh must not depend on the optional debug panel. + this.sectionManager.on('changes-accepted', (data) => { + if (this.debugPanel) { + this.debugPanel.addMessage(`Changes accepted for section: ${data.sectionId}`, 'SUCCESS'); + } + this.updateSectionDOM(data.sectionId); + }); + } + + if (this.sectionManager && this.debugPanel) { + this.sectionManager.on('sections-created', (data) => { + this.debugPanel.addMessage(`Created ${data.count} sections`, 'INFO'); + }); + + this.sectionManager.on('edit-started', (data) => { + this.debugPanel.addMessage(`Edit started for section: ${data.sectionId}`, 'DEBUG'); + }); + + this.sectionManager.on('changes-cancelled', (data) => { + this.debugPanel.addMessage(`Changes cancelled for section: ${data.sectionId}`, 'WARNING'); + }); + } + + // Document-controls handlers need the (optional) document controls if (!this.documentControls) return; this.documentControls.setEventHandlers({ @@ -187,31 +213,6 @@ const MarkitectMain = { } } }); - - // Setup section manager event handlers - if (this.sectionManager) { - // The DOM refresh must not depend on the optional debug panel. - this.sectionManager.on('changes-accepted', (data) => { - if (this.debugPanel) { - this.debugPanel.addMessage(`Changes accepted for section: ${data.sectionId}`, 'SUCCESS'); - } - this.updateSectionDOM(data.sectionId); - }); - } - - if (this.sectionManager && this.debugPanel) { - this.sectionManager.on('sections-created', (data) => { - this.debugPanel.addMessage(`Created ${data.count} sections`, 'INFO'); - }); - - this.sectionManager.on('edit-started', (data) => { - this.debugPanel.addMessage(`Edit started for section: ${data.sectionId}`, 'DEBUG'); - }); - - this.sectionManager.on('changes-cancelled', (data) => { - this.debugPanel.addMessage(`Changes cancelled for section: ${data.sectionId}`, 'WARNING'); - }); - } }, // Render content using the configuration