]> BookStack Code Mirror - bookstack/commitdiff
Fixed no md editor preview in FireFox
authorDan Brown <redacted>
Sun, 1 Sep 2019 09:51:52 +0000 (10:51 +0100)
committerDan Brown <redacted>
Sun, 1 Sep 2019 09:51:52 +0000 (10:51 +0100)
resources/assets/js/components/markdown-editor.js
resources/views/pages/markdown-editor.blade.php

index 7f3d4ef247d15f9aea1c88d496de415fb0c15df3..c89a7ad8be87c41673c5e998bdef200f8bbe8f19 100644 (file)
@@ -18,21 +18,18 @@ class MarkdownEditor {
         this.markdown.use(mdTasksLists, {label: true});
 
         this.display = this.elem.querySelector('.markdown-display');
-        this.displayDoc = this.display.contentDocument;
+
         this.displayStylesLoaded = false;
         this.input = this.elem.querySelector('textarea');
         this.htmlInput = this.elem.querySelector('input[name=html]');
         this.cm = code.markdownEditor(this.input);
 
         this.onMarkdownScroll = this.onMarkdownScroll.bind(this);
-        this.init();
 
-        // Scroll to text if needed.
-        const queryParams = (new URL(window.location)).searchParams;
-        const scrollText = queryParams.get('content-text');
-        if (scrollText) {
-            this.scrollToText(scrollText);
-        }
+        this.display.addEventListener('load', () => {
+            this.displayDoc = this.display.contentDocument;
+            this.init();
+        });
     }
 
     init() {
@@ -94,6 +91,13 @@ class MarkdownEditor {
 
         this.codeMirrorSetup();
         this.listenForBookStackEditorEvents();
+
+        // Scroll to text if needed.
+        const queryParams = (new URL(window.location)).searchParams;
+        const scrollText = queryParams.get('content-text');
+        if (scrollText) {
+            this.scrollToText(scrollText);
+        }
     }
 
     // Update the input content and render the display.
index d4f6323b01188538f1919c3453bb8d32e54c45e0..e39f39fc2765a27a68faed7a52f3d32ff866209d 100644 (file)
@@ -28,7 +28,7 @@
         <div class="editor-toolbar">
             <div class="editor-toolbar-label">{{ trans('entities.pages_md_preview') }}</div>
         </div>
-        <iframe class="markdown-display" sandbox="allow-same-origin"></iframe>
+        <iframe srcdoc="" class="markdown-display" sandbox="allow-same-origin"></iframe>
     </div>
     <input type="hidden" name="html"/>