]> BookStack Code Mirror - bookstack/blobdiff - resources/js/components/markdown-editor.js
removed test_slug_multi_byte_lower_casing and added new test test_slug_multi_byte_ur...
[bookstack] / resources / js / components / markdown-editor.js
index f88cb765104d617095bdf0fd95f9d9a24a24cc78..cc9a7b859ddb9eeb6f540d1b1c545dd8f1820987 100644 (file)
@@ -127,7 +127,13 @@ class MarkdownEditor {
 
     loadStylesIntoDisplay() {
         if (this.displayStylesLoaded) return;
-        this.displayDoc.documentElement.className = 'markdown-editor-display';
+        this.displayDoc.documentElement.classList.add('markdown-editor-display');
+        // Set display to be dark mode if parent is
+
+        if (document.documentElement.classList.contains('dark-mode')) {
+            this.displayDoc.documentElement.style.backgroundColor = '#222';
+            this.displayDoc.documentElement.classList.add('dark-mode');
+        }
 
         this.displayDoc.head.innerHTML = '';
         const styles = document.head.querySelectorAll('style,link[rel=stylesheet]');
@@ -551,6 +557,11 @@ class MarkdownEditor {
             const prependLineCount = markdown.split('\n').length;
             this.cm.setCursor(cursorPos.line + prependLineCount, cursorPos.ch);
         });
+
+        // Focus on editor
+        window.$events.listen('editor::focus', () => {
+            this.cm.focus();
+        });
     }
 }