diff --git a/src/public/app/widgets/note_context_aware_widget.js b/src/public/app/widgets/note_context_aware_widget.ts similarity index 76% rename from src/public/app/widgets/note_context_aware_widget.js rename to src/public/app/widgets/note_context_aware_widget.ts index ffb64d0b0..2a9afdbc5 100644 --- a/src/public/app/widgets/note_context_aware_widget.js +++ b/src/public/app/widgets/note_context_aware_widget.ts @@ -1,12 +1,17 @@ import BasicWidget from "./basic_widget.js"; -import appContext from "../components/app_context.js"; +import appContext, { EventData } from "../components/app_context.js"; +import FNote from "../entities/fnote.js"; +import NoteContext from "../components/note_context.js"; /** * This widget allows for changing and updating depending on the active note. * @extends {BasicWidget} */ class NoteContextAwareWidget extends BasicWidget { - isNoteContext(ntxId) { + + private noteContext?: NoteContext; + + isNoteContext(ntxId: string) { if (Array.isArray(ntxId)) { return this.noteContext && ntxId.includes(this.noteContext.ntxId); } @@ -19,26 +24,22 @@ class NoteContextAwareWidget extends BasicWidget { return appContext.tabManager.getActiveContext() === this.noteContext; } - isNote(noteId) { + isNote(noteId: string) { return this.noteId === noteId; } - /** @returns {FNote|undefined} */ get note() { return this.noteContext?.note; } - /** @returns {string|undefined} */ get noteId() { return this.note?.noteId; } - /** @returns {string|undefined} */ get notePath() { return this.noteContext?.notePath; } - /** @returns {string} */ get hoistedNoteId() { return this.noteContext?.hoistedNoteId; } @@ -53,7 +54,7 @@ class NoteContextAwareWidget extends BasicWidget { *
* If the widget is not enabled, it will not receive `refreshWithNote` updates.
*
- * @returns {boolean} true when an active note exists
+ * @returns true when an active note exists
*/
isEnabled() {
return !!this.note;
@@ -80,14 +81,11 @@ class NoteContextAwareWidget extends BasicWidget {
}
/**
- * Override this method to be able to refresh your
- * widget with each note.
- * @param {FNote} note
- * @returns {Promise