diff --git a/src/public/app/components/app_context.ts b/src/public/app/components/app_context.ts index e4e94d1a7..ceaef3882 100644 --- a/src/public/app/components/app_context.ts +++ b/src/public/app/components/app_context.ts @@ -208,6 +208,29 @@ type EventMappings = { /** Triggered when the {@link CommandMappings.setActiveScreen} command is invoked. */ activeScreenChanged: { activeScreen: Screen; + }, + activeContextChanged: { + noteContext: NoteContext; + }, + noteSwitched: { + noteContext: NoteContext; + notePath: string; + }, + noteSwitchedAndActivatedEvent: { + noteContext: NoteContext; + notePath: string; + }, + setNoteContext: { + noteContext: NoteContext; + }, + noteTypeMimeChangedEvent: { + noteId: string; + }, + reEvaluateHighlightsListWidgetVisibility: { + noteId: string | undefined; + }, + showHighlightsListWidget: { + noteId: string; } } diff --git a/src/public/app/components/note_context.ts b/src/public/app/components/note_context.ts index 607a54eb0..b18ec7e7a 100644 --- a/src/public/app/components/note_context.ts +++ b/src/public/app/components/note_context.ts @@ -306,7 +306,7 @@ class NoteContext extends Component } async getTextEditor(callback?: GetTextEditorCallback) { - return this.timeout(new Promise(resolve => appContext.triggerCommand('executeWithTextEditor', { + return this.timeout(new Promise(resolve => appContext.triggerCommand('executeWithTextEditor', { callback, resolve, ntxId: this.ntxId @@ -321,7 +321,7 @@ class NoteContext extends Component } async getContentElement() { - return this.timeout(new Promise(resolve => appContext.triggerCommand('executeWithContentElement', { + return this.timeout>(new Promise(resolve => appContext.triggerCommand('executeWithContentElement', { resolve, ntxId: this.ntxId }))); @@ -334,11 +334,11 @@ class NoteContext extends Component }))); } - timeout(promise: Promise) { + timeout(promise: Promise) { return Promise.race([ promise, new Promise(res => setTimeout(() => res(null), 200)) - ]); + ]) as Promise; } resetViewScope() { diff --git a/src/public/app/services/attributes.ts b/src/public/app/services/attributes.ts index bd8c46480..4e3eb1fe2 100644 --- a/src/public/app/services/attributes.ts +++ b/src/public/app/services/attributes.ts @@ -30,7 +30,7 @@ async function removeAttributeById(noteId: string, attributeId: string) { * 2. attribute is owned by the template of the note * 3. attribute is owned by some note's ancestor and is inheritable */ -function isAffecting(attrRow: AttributeRow, affectedNote: FNote) { +function isAffecting(attrRow: AttributeRow, affectedNote: FNote | null | undefined) { if (!affectedNote || !attrRow) { return false; } diff --git a/src/public/app/services/link.ts b/src/public/app/services/link.ts index 752a39e4b..534bc8c4d 100644 --- a/src/public/app/services/link.ts +++ b/src/public/app/services/link.ts @@ -31,6 +31,8 @@ export interface ViewScope { viewMode?: ViewMode; attachmentId?: string; readOnlyTemporarilyDisabled?: boolean; + highlightsListPreviousVisible?: boolean; + highlightsListTemporarilyHidden?: boolean; } interface CreateLinkOptions { diff --git a/src/public/app/services/load_results.ts b/src/public/app/services/load_results.ts index 47efc5fba..12fa2dbd4 100644 --- a/src/public/app/services/load_results.ts +++ b/src/public/app/services/load_results.ts @@ -172,7 +172,7 @@ export default class LoadResults { this.contentNoteIdToComponentId.push({noteId, componentId}); } - isNoteContentReloaded(noteId: string, componentId: string) { + isNoteContentReloaded(noteId: string, componentId?: string) { if (!noteId) { return false; } diff --git a/src/public/app/services/options.ts b/src/public/app/services/options.ts index 138c0402a..b6162ea1d 100644 --- a/src/public/app/services/options.ts +++ b/src/public/app/services/options.ts @@ -16,14 +16,14 @@ class Options { } get(key: string) { - return this.arr?.[key]; + return this.arr?.[key] as string; } getNames() { return Object.keys(this.arr || []); } - getJson(key: string) { + getJson(key: string) { const value = this.arr?.[key]; if (typeof value !== "string") { return null; @@ -76,4 +76,4 @@ class Options { const options = new Options(); -export default options; \ No newline at end of file +export default options; diff --git a/src/public/app/types.d.ts b/src/public/app/types.d.ts index a4765c984..9b41911ca 100644 --- a/src/public/app/types.d.ts +++ b/src/public/app/types.d.ts @@ -176,6 +176,12 @@ declare global { } }; + var katex: { + renderToString(text: string, opts: { + throwOnError: boolean + }); + } + type TextEditorElement = {}; interface Writer { setAttribute(name: string, value: string, el: TextEditorElement); @@ -220,6 +226,13 @@ declare global { }); getRoot(): TextEditorElement }, + domRoots: { + values: () => { + next: () => { + value: string; + } + }; + } change(cb: (writer: Writer) => void) } }, diff --git a/src/public/app/widgets/highlights_list.js b/src/public/app/widgets/highlights_list.ts similarity index 72% rename from src/public/app/widgets/highlights_list.js rename to src/public/app/widgets/highlights_list.ts index ef4a0c2ac..8729f7305 100644 --- a/src/public/app/widgets/highlights_list.js +++ b/src/public/app/widgets/highlights_list.ts @@ -10,22 +10,23 @@ import attributeService from "../services/attributes.js"; import RightPanelWidget from "./right_panel_widget.js"; import options from "../services/options.js"; import OnClickButtonWidget from "./buttons/onclick_button.js"; -import appContext from "../components/app_context.js"; +import appContext, { EventData } from "../components/app_context.js"; import libraryLoader from "../services/library_loader.js"; +import FNote from "../entities/fnote.js"; const TPL = `