]> BookStack Code Mirror - bookstack/commitdiff
Fixed custom code theme not showing in WYSIWYG
authorDan Brown <redacted>
Tue, 27 Sep 2022 17:44:06 +0000 (18:44 +0100)
committerDan Brown <redacted>
Tue, 27 Sep 2022 17:44:06 +0000 (18:44 +0100)
Fixes #3753
Was caused by not including added styles to the code block shadow root.

resources/js/wysiwyg/plugin-codeeditor.js

index b9fc355e1696a2a2692e4d8402c71c2b655085fe..5377f564e862aef84bde451d1707d221eb875ad7 100644 (file)
@@ -39,16 +39,16 @@ function defineCodeBlockCustomElement(editor) {
         constructor() {
             super();
             this.attachShadow({mode: 'open'});
-            const linkElem = document.createElement('link');
-            linkElem.setAttribute('rel', 'stylesheet');
-            linkElem.setAttribute('href', window.baseUrl('/dist/styles.css'));
+
+            const stylesToCopy = document.querySelectorAll('link[rel="stylesheet"]:not([media="print"])');
+            const copiedStyles = Array.from(stylesToCopy).map(styleEl => styleEl.cloneNode(false));
 
             const cmContainer = document.createElement('div');
             cmContainer.style.pointerEvents = 'none';
             cmContainer.contentEditable = 'false';
             cmContainer.classList.add('CodeMirrorContainer');
 
-            this.shadowRoot.append(linkElem, cmContainer);
+            this.shadowRoot.append(...copiedStyles, cmContainer);
         }
 
         getLanguage() {
Morty Proxy This is a proxified and sanitized view of the page, visit original site.