Skip to content

Build your personal knowledge base with Trilium Notes

fix(ribbon): not visible when coming from view source on same note

Elian Doranefcd54be5008
diff --git a/apps/client/src/services/link.ts b/apps/client/src/services/link.ts
index 809eb58ef6..7a7b8b924a 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 87779fa366..a8a549edbf 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<T extends EventNames>(eventName: T, handler: (data: EventData<T>) => void) {
const parentComponent = useContext(ParentComponent);
@@ -196,6 +197,7 @@ export function useNoteContext() {
const [ noteContext, setNoteContext ] = useState<NoteContext>();
const [ notePath, setNotePath ] = useState<string | null | undefined>();
const [ note, setNote ] = useState<FNote | null | undefined>();
+ const [ , setViewMode ] = useState<ViewMode>();
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);