chore(collection/presentation): address requested changes

This commit is contained in:
Elian Doran 2025-10-16 15:32:16 +03:00
parent 04eeb28c09
commit 5d8ca1ecf7
No known key found for this signature in database
4 changed files with 12 additions and 21 deletions

View File

@ -439,7 +439,7 @@ class NoteContext extends Component implements EventListener<"entitiesReloaded">
} }
export function openInCurrentNoteContext(evt: MouseEvent | JQuery.ClickEvent | JQuery.MouseDownEvent | React.PointerEvent<HTMLCanvasElement> | null, notePath: string, viewScope?: ViewScope) { export function openInCurrentNoteContext(evt: MouseEvent | JQuery.ClickEvent | JQuery.MouseDownEvent | React.PointerEvent<HTMLCanvasElement> | null, notePath: string, viewScope?: ViewScope) {
const ntxId = $(evt?.target as any) const ntxId = $(evt?.target as Element)
.closest("[data-ntx-id]") .closest("[data-ntx-id]")
.attr("data-ntx-id"); .attr("data-ntx-id");

View File

@ -119,11 +119,10 @@ function ButtonOverlay({ containerRef, api }: { containerRef: RefObject<HTMLDivE
function Presentation({ presentation, setApi } : { presentation: PresentationModel, setApi: (api: Reveal.Api | undefined) => void }) { function Presentation({ presentation, setApi } : { presentation: PresentationModel, setApi: (api: Reveal.Api | undefined) => void }) {
const containerRef = useRef<HTMLDivElement>(null); const containerRef = useRef<HTMLDivElement>(null);
const apiRef = useRef<Reveal.Api>(null); const [revealApi, setRevealApi] = useState<Reveal.Api>();
const isFirstRenderRef = useRef(true);
useEffect(() => { useEffect(() => {
if (apiRef.current || !containerRef.current) return; if (!containerRef.current) return;
const api = new Reveal(containerRef.current, { const api = new Reveal(containerRef.current, {
transition: "slide", transition: "slide",
@ -138,23 +137,20 @@ function Presentation({ presentation, setApi } : { presentation: PresentationMod
}, },
}); });
api.initialize().then(() => { api.initialize().then(() => {
apiRef.current = api; setRevealApi(revealApi);
setApi(api); setApi(api);
}); });
return () => { return () => {
api.destroy(); api.destroy();
apiRef.current = null; setRevealApi(undefined);
setApi(undefined); setApi(undefined);
} }
}, [ ]); }, []);
useEffect(() => { useEffect(() => {
if (!isFirstRenderRef.current) { revealApi?.sync();
apiRef.current?.sync(); }, [ presentation, revealApi ]);
}
isFirstRenderRef.current = false;
}, [ presentation ]);
return ( return (
<div ref={containerRef} className="reveal"> <div ref={containerRef} className="reveal">

View File

@ -1,11 +1,6 @@
export const DEFAULT_THEME = "white"; export const DEFAULT_THEME = "white";
interface ThemeDefinition { const themes = {
name: string;
loadTheme: () => Promise<typeof import("*.css?raw")>;
}
const themes: Record<string, ThemeDefinition> = {
black: { black: {
name: "Black", name: "Black",
loadTheme: () => import("reveal.js/dist/theme/black.css?raw") loadTheme: () => import("reveal.js/dist/theme/black.css?raw")

View File

@ -359,7 +359,7 @@ function checkHiddenSubtreeRecursively(parentNoteId: string, item: HiddenSubtree
branch = note.getParentBranches().find((branch) => branch.parentNoteId === parentNoteId); branch = note.getParentBranches().find((branch) => branch.parentNoteId === parentNoteId);
if (item.content && note.getContent() !== item.content) { if (item.content && note.getContent() !== item.content) {
console.log(`Updating content of ${item.id}.`); log.info(`Updating content of ${item.id}.`);
note.setContent(item.content); note.setContent(item.content);
} }
@ -369,7 +369,7 @@ function checkHiddenSubtreeRecursively(parentNoteId: string, item: HiddenSubtree
// If the note exists but doesn't have a branch in the expected parent, // If the note exists but doesn't have a branch in the expected parent,
// create the missing branch to ensure it's in the correct location // create the missing branch to ensure it's in the correct location
if (!branch) { if (!branch) {
console.log("Creating missing branch for note", item.id, "under parent", parentNoteId); log.info(`Creating missing branch for note ${item.id} under parent ${parentNoteId}.`);
branch = new BBranch({ branch = new BBranch({
noteId: item.id, noteId: item.id,
parentNoteId: parentNoteId, parentNoteId: parentNoteId,
@ -473,7 +473,7 @@ function checkHiddenSubtreeRecursively(parentNoteId: string, item: HiddenSubtree
}).save(); }).save();
} else if (attr.name === "docName" || (existingAttribute.noteId.startsWith("_help") && attr.name === "iconClass")) { } else if (attr.name === "docName" || (existingAttribute.noteId.startsWith("_help") && attr.name === "iconClass")) {
if (existingAttribute.value !== attr.value) { if (existingAttribute.value !== attr.value) {
console.log(`Updating attribute ${attrId} from "${existingAttribute.value}" to "${attr.value}"`); log.info(`Updating attribute ${attrId} from "${existingAttribute.value}" to "${attr.value}"`);
existingAttribute.value = attr.value ?? ""; existingAttribute.value = attr.value ?? "";
existingAttribute.save(); existingAttribute.save();
} }