]> BookStack Code Mirror - bookstack/blobdiff - resources/js/wysiwyg/plugin-codeeditor.js
CSS: Removed redundant calc
[bookstack] / resources / js / wysiwyg / plugin-codeeditor.js
index 25f774baabd18064642caae7b66abd24850c39fe..f86760214e1ed93d124b6a9f777463f1bb1525e5 100644 (file)
@@ -53,8 +53,8 @@ function defineCodeBlockCustomElement(editor) {
             super();
             this.attachShadow({mode: 'open'});
 
-            const stylesToCopy = document.querySelectorAll('link[rel="stylesheet"]:not([media="print"])');
-            const copiedStyles = Array.from(stylesToCopy).map(styleEl => styleEl.cloneNode(false));
+            const stylesToCopy = document.head.querySelectorAll('link[rel="stylesheet"]:not([media="print"]),style');
+            const copiedStyles = Array.from(stylesToCopy).map(styleEl => styleEl.cloneNode(true));
 
             const cmContainer = document.createElement('div');
             cmContainer.style.pointerEvents = 'none';
@@ -205,6 +205,11 @@ function register(editor) {
                     contenteditable: 'false',
                 });
 
+                const direction = el.attr('dir');
+                if (direction) {
+                    wrapper.attr('dir', direction);
+                }
+
                 const spans = el.getAll('span');
                 for (const span of spans) {
                     span.unwrap();
@@ -222,6 +227,13 @@ function register(editor) {
 
         editor.serializer.addNodeFilter('code-block', elms => {
             for (const el of elms) {
+                const direction = el.attr('dir');
+                if (direction && el.firstChild) {
+                    el.firstChild.attr('dir', direction);
+                } else if (el.firstChild) {
+                    el.firstChild.attr('dir', null);
+                }
+
                 el.unwrap();
             }
         });