]> _ Git - fluidbook-toolbox.git/commitdiff
wait #8038 @1:30
authorsoufiane <soufiane@cubedesigners.com>
Thu, 5 Mar 2026 10:19:24 +0000 (11:19 +0100)
committersoufiane <soufiane@cubedesigners.com>
Thu, 5 Mar 2026 10:19:24 +0000 (11:19 +0100)
resources/markdowneditor/js/markdowneditor.js
resources/markdowneditor/js/markdowneditor.undo.js

index f181745fc9a82ea82b00e17a8c37cc622db2d92a..b02912d2edb2e4e02b70a16ebfd7f9ec39b5a645 100644 (file)
@@ -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 () {
index dd81a6893c42754da364e52ed11713063d803081..a4c4333cde90e4893e5cb888fa61ea485ad3a1c7 100644 (file)
@@ -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;
         }