diff --git a/markitect/document_manager.py b/markitect/document_manager.py index 34e52504..a7055964 100644 --- a/markitect/document_manager.py +++ b/markitect/document_manager.py @@ -657,6 +657,7 @@ class DocumentManager: editor_scripts = """ class MarkitectEditor { constructor() { + this.hasEdits = false; // Track if any edits have been made this.initializeEditor(); this.setupKeyboardShortcuts(); } @@ -707,6 +708,7 @@ class DocumentManager: textarea.className = 'edit-mode'; textarea.addEventListener('blur', () => { + this.hasEdits = true; // Mark that edits have been made section.innerHTML = marked.parse(textarea.value); this.markSections(section.parentElement); }); @@ -781,6 +783,11 @@ class DocumentManager: } getMarkdownContent() { + // If no edits have been made, return the original markdown content + if (!this.hasEdits) { + return markdownContent; + } + // Reconstruct markdown content from the current state of sections const content = document.getElementById('markdown-content'); if (!content) {