chore(react): finalize note title porting

This commit is contained in:
Elian Doran 2025-08-21 13:18:39 +03:00
parent bea352855a
commit 009fd63ce9
No known key found for this signature in database
2 changed files with 1 additions and 39 deletions

View File

@ -1,39 +0,0 @@
import NoteContextAwareWidget from "./note_context_aware_widget.js";
import SpacedUpdate from "../services/spaced_update.js";
import appContext, { type EventData } from "../components/app_context.js";
import branchService from "../services/branches.js";
import shortcutService from "../services/shortcuts.js";
export default class NoteTitleWidget extends NoteContextAwareWidget {
private $noteTitle!: JQuery<HTMLElement>;
private deleteNoteOnEscape: boolean;
constructor() {
super();
this.deleteNoteOnEscape = false;
}
doRender() {
this.$widget = $(TPL);
this.$noteTitle = this.$widget.find(".note-title");
this.$noteTitle.on("blur", () => {
});
}
async beforeNoteSwitchEvent({ noteContext }: EventData<"beforeNoteSwitch">) {
if (this.isNoteContext(noteContext.ntxId)) {
await this.spacedUpdate.updateNowIfNecessary();
}
}
async beforeNoteContextRemoveEvent({ ntxIds }: EventData<"beforeNoteContextRemove">) {
if (this.isNoteContext(ntxIds)) {
await this.spacedUpdate.updateNowIfNecessary();
}
}
}

View File

@ -48,6 +48,7 @@ export default function NoteTitleWidget() {
useEffect(() => {
appContext.addBeforeUnloadListener(() => spacedUpdate.isAllSavedAndTriggerUpdate());
}, []);
useTriliumEventBeta([ "beforeNoteSwitch", "beforeNoteContextRemove" ], () => spacedUpdate.updateNowIfNecessary());
// Manage focus.
const textBoxRef = useRef<HTMLInputElement>(null);