Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(client/print): variables not loading for printing presentations
Elian Doranb0234a75f8c5
diff --git a/apps/client/src/widgets/collections/presentation/index.tsx b/apps/client/src/widgets/collections/presentation/index.tsxindex 82d0a47cd0..44341688a6 100644--- a/apps/client/src/widgets/collections/presentation/index.tsx+++ b/apps/client/src/widgets/collections/presentation/index.tsx@@ -1,4 +1,4 @@-import { ViewModeProps } from "../interface";+import { ViewModeMedia, ViewModeProps } from "../interface";import { useEffect, useLayoutEffect, useRef, useState } from "preact/hooks";import Reveal from "reveal.js";import slideBaseStylesheet from "reveal.js/dist/reveal.css?raw";@@ -18,7 +18,7 @@ export default function PresentationView({ note, noteIds, media }: ViewModePropsconst [ presentation, setPresentation ] = useState<PresentationModel>();const containerRef = useRef<HTMLDivElement>(null);const [ api, setApi ] = useState<Reveal.Api>();- const stylesheets = usePresentationStylesheets(note);+ const stylesheets = usePresentationStylesheets(note, media);function refresh() {buildPresentationModel(note).then(setPresentation);@@ -62,17 +62,22 @@ export default function PresentationView({ note, noteIds, media }: ViewModeProps}}-function usePresentationStylesheets(note: FNote) {+function usePresentationStylesheets(note: FNote, media: ViewModeMedia) {const [ themeName ] = useNoteLabelWithDefault(note, "presentation:theme", DEFAULT_THEME);const [ stylesheets, setStylesheets ] = useState<string[]>();useLayoutEffect(() => {loadPresentationTheme(themeName).then((themeStylesheet) => {- setStylesheets([+ let stylesheets = [slideBaseStylesheet,themeStylesheet,slideCustomStylesheet- ].map(stylesheet => stylesheet.replace(/:root/g, ":host")));+ ];+ if (media === "screen") {+ // We are rendering in the shadow DOM, so the global variables are not set correctly.+ stylesheets = stylesheets.map(stylesheet => stylesheet.replace(/:root/g, ":host"));+ }+ setStylesheets(stylesheets);});}, [ themeName ]);