Add katex style to root of notebook

Fixes #128490

This is needed to ensure the katex font-face is loaded properly

Seems like this is needed to work around a bug: https://bugs.chromium.org/p/chromium/issues/detail?id=336876
This commit is contained in:
Matt Bierner 2021-08-03 21:46:02 -07:00
parent fd48df6c7f
commit b2142b93e0
No known key found for this signature in database
GPG key ID: 099C331567E11888

View file

@ -14,11 +14,21 @@ export async function activate(ctx: {
throw new Error('Could not load markdownItRenderer');
}
// Add katex styles to be copied to shadow dom
const link = document.createElement('link');
link.rel = 'stylesheet';
link.classList.add('markdown-style');
link.href = styleHref;
// Add same katex style to root document.
// This is needed for the font to be loaded correctly inside the shadow dom.
//
// Seems like https://bugs.chromium.org/p/chromium/issues/detail?id=336876
const linkHead = document.createElement('link');
linkHead.rel = 'stylesheet';
linkHead.href = styleHref;
document.head.appendChild(linkHead);
const style = document.createElement('style');
style.textContent = `
.katex-error {