]> BookStack Code Mirror - bookstack/commitdiff
Added codemirror refresh on details blog toggle
authorDan Brown <redacted>
Sat, 30 Jan 2021 17:04:30 +0000 (17:04 +0000)
committerDan Brown <redacted>
Sat, 30 Jan 2021 17:04:30 +0000 (17:04 +0000)
For #781

resources/js/components/page-display.js

index 2be1c1c48b8cc93f5ac147b64023cf910eabc3fa..cc55fe35e1e38caae9de9f9cca013e0c7b1d14f6 100644 (file)
@@ -12,6 +12,7 @@ class PageDisplay {
         Code.highlight();
         this.setupPointer();
         this.setupNavHighlighting();
+        this.setupDetailsCodeBlockRefresh();
 
         // Check the hash on load
         if (window.location.hash) {
@@ -196,6 +197,16 @@ class PageDisplay {
             });
         }
     }
+
+    setupDetailsCodeBlockRefresh() {
+        const onToggle = event => {
+            const codeMirrors = [...event.target.querySelectorAll('.CodeMirror')];
+            codeMirrors.forEach(cm => cm.CodeMirror && cm.CodeMirror.refresh());
+        };
+
+        const details = [...this.elem.querySelectorAll('details')];
+        details.forEach(detail => detail.addEventListener('toggle', onToggle));
+    }
 }
 
 export default PageDisplay;
Morty Proxy This is a proxified and sanitized view of the page, visit original site.