Revert "chore(react): prototype for note context"

This reverts commit 660db3b3ab.
This commit is contained in:
Elian Doran
2025-08-25 13:51:43 +03:00
parent 660db3b3ab
commit 1eaeec8100
6 changed files with 19 additions and 61 deletions

View File

@@ -1,4 +1,4 @@
import { useContext, useEffect, useRef, useState } from "preact/hooks";
import { useEffect, useRef, useState } from "preact/hooks";
import { t } from "../services/i18n";
import FormTextBox from "./react/FormTextBox";
import { useNoteContext, useNoteProperty, useSpacedUpdate, useTriliumEvent } from "./react/hooks";
@@ -8,13 +8,9 @@ import "./note_title.css";
import { isLaunchBarConfig } from "../services/utils";
import appContext from "../components/app_context";
import branches from "../services/branches";
import { NoteContext, ParentComponent } from "./react/react_utils";
export default function NoteTitleWidget() {
const parentComponent = useContext(ParentComponent);
const noteContext = useContext(NoteContext);
const { noteId, note, componentId, viewScope } = noteContext ?? {};
const { note, noteId, componentId, viewScope, noteContext, parentComponent } = useNoteContext();
const title = useNoteProperty(note, "title", componentId);
const isProtected = useNoteProperty(note, "isProtected");
const newTitle = useRef("");
@@ -35,7 +31,7 @@ export default function NoteTitleWidget() {
// Manage the title for read-only notes
useEffect(() => {
if (isReadOnly) {
noteContext?.getNavigationTitle?.().then(setNavigationTitle);
noteContext?.getNavigationTitle().then(setNavigationTitle);
}
}, [isReadOnly]);
@@ -82,7 +78,7 @@ export default function NoteTitleWidget() {
// Focus on the note content when pressing enter.
if (e.key === "Enter") {
e.preventDefault();
parentComponent?.triggerCommand("focusOnDetail", { ntxId: noteContext?.ntxId });
parentComponent.triggerCommand("focusOnDetail", { ntxId: noteContext?.ntxId });
return;
}