mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 15:19:01 +02:00
fix(ribbon): not visible when coming from view source on same note
This commit is contained in:
parent
ae0bb78b1c
commit
efcd54be50
@ -36,7 +36,7 @@ async function getLinkIcon(noteId: string, viewMode: ViewMode | undefined) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove `string` once all the view modes have been mapped.
|
// 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 {
|
export interface ViewScope {
|
||||||
/**
|
/**
|
||||||
|
@ -19,6 +19,7 @@ import Mark from "mark.js";
|
|||||||
import { DragData } from "../note_tree";
|
import { DragData } from "../note_tree";
|
||||||
import Component from "../../components/component";
|
import Component from "../../components/component";
|
||||||
import toast, { ToastOptions } from "../../services/toast";
|
import toast, { ToastOptions } from "../../services/toast";
|
||||||
|
import { ViewMode } from "../../services/link";
|
||||||
|
|
||||||
export function useTriliumEvent<T extends EventNames>(eventName: T, handler: (data: EventData<T>) => void) {
|
export function useTriliumEvent<T extends EventNames>(eventName: T, handler: (data: EventData<T>) => void) {
|
||||||
const parentComponent = useContext(ParentComponent);
|
const parentComponent = useContext(ParentComponent);
|
||||||
@ -196,6 +197,7 @@ export function useNoteContext() {
|
|||||||
const [ noteContext, setNoteContext ] = useState<NoteContext>();
|
const [ noteContext, setNoteContext ] = useState<NoteContext>();
|
||||||
const [ notePath, setNotePath ] = useState<string | null | undefined>();
|
const [ notePath, setNotePath ] = useState<string | null | undefined>();
|
||||||
const [ note, setNote ] = useState<FNote | null | undefined>();
|
const [ note, setNote ] = useState<FNote | null | undefined>();
|
||||||
|
const [ , setViewMode ] = useState<ViewMode>();
|
||||||
const [ refreshCounter, setRefreshCounter ] = useState(0);
|
const [ refreshCounter, setRefreshCounter ] = useState(0);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -205,6 +207,7 @@ export function useNoteContext() {
|
|||||||
useTriliumEvents([ "setNoteContext", "activeContextChanged", "noteSwitchedAndActivated", "noteSwitched" ], ({ noteContext }) => {
|
useTriliumEvents([ "setNoteContext", "activeContextChanged", "noteSwitchedAndActivated", "noteSwitched" ], ({ noteContext }) => {
|
||||||
setNoteContext(noteContext);
|
setNoteContext(noteContext);
|
||||||
setNotePath(noteContext.notePath);
|
setNotePath(noteContext.notePath);
|
||||||
|
setViewMode(noteContext.viewScope?.viewMode);
|
||||||
});
|
});
|
||||||
useTriliumEvent("frocaReloaded", () => {
|
useTriliumEvent("frocaReloaded", () => {
|
||||||
setNote(noteContext?.note);
|
setNote(noteContext?.note);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user