From c69b85afc84a2400bb113eb16eb266551b251c95 Mon Sep 17 00:00:00 2001 From: soufiane Date: Thu, 5 Mar 2026 11:19:24 +0100 Subject: [PATCH] wait #8038 @1:30 --- resources/markdowneditor/js/markdowneditor.js | 16 ++++++++++++++++ .../markdowneditor/js/markdowneditor.undo.js | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/resources/markdowneditor/js/markdowneditor.js b/resources/markdowneditor/js/markdowneditor.js index f181745fc..b02912d2e 100644 --- a/resources/markdowneditor/js/markdowneditor.js +++ b/resources/markdowneditor/js/markdowneditor.js @@ -174,6 +174,22 @@ MarkdownEditor.prototype = { $this.undo.pushState() $this.save.hasChanged() }) + + const observerOptions = { + childList: true, + subtree: true, + }; + + const observer = new MutationObserver((records, observer) => { + $this.undo.pushState() + $this.save.hasChanged() + for (const record of records) { + if (record.target.childNodes.length === 0) { + observer.disconnect(); + } + } + }); + observer.observe(document.querySelector('.toastui-editor-main'), observerOptions); }, initIcons: function () { diff --git a/resources/markdowneditor/js/markdowneditor.undo.js b/resources/markdowneditor/js/markdowneditor.undo.js index dd81a6893..a4c4333cd 100644 --- a/resources/markdowneditor/js/markdowneditor.undo.js +++ b/resources/markdowneditor/js/markdowneditor.undo.js @@ -71,7 +71,7 @@ MarkdowneditorUndo.prototype = { let cs = this.markdowneditor.editor.getMarkdown(); let ps = this.states[this.markdowneditor.getCurrentPage()][index - 1]; - if (ps == cs) { + if (ps === cs) { console.log('skipped : no change'); return; } -- 2.39.5