From: Dan Brown Date: Mon, 8 May 2023 11:21:53 +0000 (+0100) Subject: WYSWIYG code blocks: copied head styles into shadow root X-Git-Tag: v23.05.1~1^2~6 X-Git-Url: http://source.bookstackapp.com/bookstack/commitdiff_plain/2523cee0e2b7a1eb31feec65b6448ccaa45d27f4 WYSWIYG code blocks: copied head styles into shadow root Currently only link-based styles are made available in the shadow root code editor environment, this adds normal styles to apply any user-added via custom head content. Fixes #4228 --- diff --git a/resources/js/wysiwyg/plugin-codeeditor.js b/resources/js/wysiwyg/plugin-codeeditor.js index 25f774baa..2fe2ac26a 100644 --- a/resources/js/wysiwyg/plugin-codeeditor.js +++ b/resources/js/wysiwyg/plugin-codeeditor.js @@ -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';