Fixed custom code theme not showing in WYSIWYG

Fixes #3753
Was caused by not including added styles to the code block shadow root.
This commit is contained in:
Dan Brown 2022-09-27 18:44:06 +01:00
parent b716fd2b8b
commit af434d0216
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9

View 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() {