Skip to content

Build your personal knowledge base with Trilium Notes

fix(collection/presentation): CSS variables not working in shadow DOM

Elian Doran9f993363d76b
diff --git a/apps/client/src/widgets/collections/presentation/index.tsx b/apps/client/src/widgets/collections/presentation/index.tsx
index 9ac6e87e90..dca20b2a09 100644
--- a/apps/client/src/widgets/collections/presentation/index.tsx
+++ b/apps/client/src/widgets/collections/presentation/index.tsx
@@ -1,11 +1,16 @@
import { ViewModeProps } from "../interface";
import { useEffect, useLayoutEffect, useRef, useState } from "preact/hooks";
import Reveal from "reveal.js";
-import slideBaseStylesheetUrl from "reveal.js/dist/reveal.css?url";
-import slideThemeStylesheetUrl from "reveal.js/dist/theme/black.css?url";
+import slideBaseStylesheet from "reveal.js/dist/reveal.css?raw";
+import slideThemeStylesheet from "reveal.js/dist/theme/black.css?raw";
import { buildPresentationModel, PresentationModel, PresentationSlideModel } from "./model";
import ShadowDom from "../../react/ShadowDom";
+const stylesheets = [
+ slideBaseStylesheet,
+ slideThemeStylesheet
+].map(stylesheet => stylesheet.replace(/:root/g, ":host"));
+
export default function PresentationView({ note }: ViewModeProps<{}>) {
const [ presentation, setPresentation ] = useState<PresentationModel>();
@@ -15,8 +20,7 @@ export default function PresentationView({ note }: ViewModeProps<{}>) {
return presentation && (
<ShadowDom className="presentation-container" style={{ width: "100%", height: "100%" }}>
- <link rel="stylesheet" href={slideBaseStylesheetUrl} />
- <link rel="stylesheet" href={slideThemeStylesheetUrl} />
+ {stylesheets.map(stylesheet => <style>{stylesheet}</style>)}
<Presentation presentation={presentation} />
</ShadowDom>
)