1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2024-10-30 07:32:39 +01:00

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
This commit is contained in:
Dan Brown 2023-05-08 12:21:53 +01:00
parent b5cc0a8e38
commit 2523cee0e2
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9

View File

@ -53,8 +53,8 @@ function defineCodeBlockCustomElement(editor) {
super(); super();
this.attachShadow({mode: 'open'}); this.attachShadow({mode: 'open'});
const stylesToCopy = document.querySelectorAll('link[rel="stylesheet"]:not([media="print"])'); const stylesToCopy = document.head.querySelectorAll('link[rel="stylesheet"]:not([media="print"]),style');
const copiedStyles = Array.from(stylesToCopy).map(styleEl => styleEl.cloneNode(false)); const copiedStyles = Array.from(stylesToCopy).map(styleEl => styleEl.cloneNode(true));
const cmContainer = document.createElement('div'); const cmContainer = document.createElement('div');
cmContainer.style.pointerEvents = 'none'; cmContainer.style.pointerEvents = 'none';