diff --git a/apps/client/src/services/link.ts b/apps/client/src/services/link.ts index 809eb58ef..7a7b8b924 100644 --- a/apps/client/src/services/link.ts +++ b/apps/client/src/services/link.ts @@ -36,7 +36,7 @@ async function getLinkIcon(noteId: string, viewMode: ViewMode | undefined) { } // TODO: Remove `string` once all the view modes have been mapped. -type ViewMode = "default" | "source" | "attachments" | "contextual-help" | string; +export type ViewMode = "default" | "source" | "attachments" | "contextual-help" | string; export interface ViewScope { /** diff --git a/apps/client/src/widgets/react/hooks.tsx b/apps/client/src/widgets/react/hooks.tsx index 87779fa36..a8a549edb 100644 --- a/apps/client/src/widgets/react/hooks.tsx +++ b/apps/client/src/widgets/react/hooks.tsx @@ -19,6 +19,7 @@ import Mark from "mark.js"; import { DragData } from "../note_tree"; import Component from "../../components/component"; import toast, { ToastOptions } from "../../services/toast"; +import { ViewMode } from "../../services/link"; export function useTriliumEvent(eventName: T, handler: (data: EventData) => void) { const parentComponent = useContext(ParentComponent); @@ -196,6 +197,7 @@ export function useNoteContext() { const [ noteContext, setNoteContext ] = useState(); const [ notePath, setNotePath ] = useState(); const [ note, setNote ] = useState(); + const [ , setViewMode ] = useState(); const [ refreshCounter, setRefreshCounter ] = useState(0); useEffect(() => { @@ -205,6 +207,7 @@ export function useNoteContext() { useTriliumEvents([ "setNoteContext", "activeContextChanged", "noteSwitchedAndActivated", "noteSwitched" ], ({ noteContext }) => { setNoteContext(noteContext); setNotePath(noteContext.notePath); + setViewMode(noteContext.viewScope?.viewMode); }); useTriliumEvent("frocaReloaded", () => { setNote(noteContext?.note);