feat(react): basic implementation of note title

This commit is contained in:
Elian Doran
2025-08-21 10:05:53 +03:00
parent 799e705ff8
commit ca40360f7d
4 changed files with 73 additions and 18 deletions

View File

@@ -86,7 +86,9 @@ export default function useTriliumEvent<T extends EventNames>(eventName: T, hand
export function useTriliumEventBeta<T extends EventNames>(eventName: T, handler: TriliumEventHandler<T>) {
const parentComponent = useContext(ParentComponent) as ReactWrappedWidget;
parentComponent.listeners[eventName] = handler;
parentComponent.registerHandler(eventName, handler);
return (() => parentComponent.removeHandler(eventName, handler));
}
export function useSpacedUpdate(callback: () => Promise<void>, interval = 1000) {
@@ -247,13 +249,16 @@ export function useNoteContext() {
console.warn("Note switched", notePath);
setNotePath(notePath);
});
const parentComponent = useContext(ParentComponent) as ReactWrappedWidget;
return {
note: noteContext?.note,
noteId: noteContext?.note?.noteId,
notePath: noteContext?.notePath,
hoistedNoteId: noteContext?.hoistedNoteId,
ntxId: noteContext?.ntxId
ntxId: noteContext?.ntxId,
componentId: parentComponent.componentId
};
}