mirror of
https://github.com/zadam/trilium.git
synced 2025-11-15 09:45:52 +01:00
feat(collection/presentation): get slidejs to render
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import { ViewModeProps } from "../interface";
|
||||
import FNote from "../../../entities/fnote";
|
||||
import { useLayoutEffect, useState } from "preact/hooks";
|
||||
import { useEffect, useLayoutEffect, useRef, useState } from "preact/hooks";
|
||||
import Reveal from "reveal.js";
|
||||
import "reveal.js/dist/reveal.css";
|
||||
import "reveal.js/dist/theme/black.css";
|
||||
|
||||
export default function PresentationView({ note }: ViewModeProps<{}>) {
|
||||
return note && (
|
||||
@@ -10,13 +13,33 @@ export default function PresentationView({ note }: ViewModeProps<{}>) {
|
||||
|
||||
function Presentation({ note }: { note: FNote }) {
|
||||
const [ slides, setSlides ] = useState<FNote[]>();
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
const apiRef = useRef<Reveal.Api | null>(null);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
note.getChildNotes().then(setSlides);
|
||||
}, [ note ]);
|
||||
|
||||
useEffect(() => {
|
||||
if (apiRef.current || !containerRef.current) return;
|
||||
|
||||
apiRef.current = new Reveal(containerRef.current, {
|
||||
transition: "slide"
|
||||
});
|
||||
apiRef.current.initialize().then(() => {
|
||||
console.log("Slide.js initialized.");
|
||||
});
|
||||
|
||||
return () => {
|
||||
if (apiRef.current) {
|
||||
apiRef.current.destroy();
|
||||
apiRef.current = null;
|
||||
}
|
||||
}
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="reveal">
|
||||
<div ref={containerRef} className="reveal">
|
||||
<div className="slides">
|
||||
{slides && slides?.map(slide => (
|
||||
<Slide note={slide} />
|
||||
|
||||
Reference in New Issue
Block a user