]> BookStack Code Mirror - bookstack/blobdiff - resources/js/components/page-editor.js
Added testing for our request method overrides
[bookstack] / resources / js / components / page-editor.js
index a0d8d38b129b3c4c8d4c8fde8eeb4f51e4a3f4a8..dae8071220720d6126c81f77406f88c77af5e2a0 100644 (file)
@@ -40,6 +40,7 @@ class PageEditor {
             frequency: 30000,
             last: 0,
         };
+        this.shownWarningsCache = new Set();
 
         if (this.pageId !== 0 && this.draftsEnabled) {
             window.setTimeout(() => {
@@ -74,7 +75,6 @@ class PageEditor {
     }
 
     setInitialFocus() {
-        console.log({'HAS': this.hasDefaultTitle});
         if (this.hasDefaultTitle) {
             return this.titleElem.select();
         }
@@ -120,6 +120,10 @@ class PageEditor {
             }
             this.draftNotifyChange(`${resp.data.message} ${Dates.utcTimeStampToLocalTime(resp.data.timestamp)}`);
             this.autoSave.last = Date.now();
+            if (resp.data.warning && !this.shownWarningsCache.has(resp.data.warning)) {
+                window.$events.emit('warning', resp.data.warning);
+                this.shownWarningsCache.add(resp.data.warning);
+            }
         } catch (err) {
             // Save the editor content in LocalStorage as a last resort, just in case.
             try {
@@ -154,8 +158,10 @@ class PageEditor {
 
         this.draftDisplay.innerText = this.editingPageText;
         this.toggleDiscardDraftVisibility(false);
-        window.$events.emit('editor-html-update', response.data.html || '');
-        window.$events.emit('editor-markdown-update', response.data.markdown || response.data.html);
+        window.$events.emit('editor::replace', {
+            html: response.data.html,
+            markdown: response.data.markdown,
+        });
 
         this.titleElem.value = response.data.name;
         window.setTimeout(() => {