mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-10 18:39:22 +08:00
refactor: 💡 Fix ts error
This commit is contained in:
parent
e12be14dc9
commit
b18cfb5d20
@ -411,7 +411,11 @@ async function openInAppHelp($button: JQuery<HTMLElement>) {
|
|||||||
if (inAppHelpPage) {
|
if (inAppHelpPage) {
|
||||||
// Dynamic import to avoid import issues in tests.
|
// Dynamic import to avoid import issues in tests.
|
||||||
const appContext = (await import("../components/app_context.js")).default;
|
const appContext = (await import("../components/app_context.js")).default;
|
||||||
const subContexts = appContext.tabManager.getActiveContext().getSubContexts();
|
const activeContext = appContext.tabManager.getActiveContext();
|
||||||
|
if (!activeContext) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const subContexts = activeContext.getSubContexts();
|
||||||
const targetNote = `_help_${inAppHelpPage}`;
|
const targetNote = `_help_${inAppHelpPage}`;
|
||||||
const helpSubcontext = subContexts.find((s) => s.viewScope?.viewMode === "contextual-help");
|
const helpSubcontext = subContexts.find((s) => s.viewScope?.viewMode === "contextual-help");
|
||||||
const viewScope: ViewScope = {
|
const viewScope: ViewScope = {
|
||||||
|
@ -115,7 +115,10 @@ export default class RecentChangesDialog extends BasicWidget {
|
|||||||
|
|
||||||
await ws.waitForMaxKnownEntityChangeId();
|
await ws.waitForMaxKnownEntityChangeId();
|
||||||
|
|
||||||
appContext.tabManager.getActiveContext().setNote(change.noteId);
|
const activeContext = appContext.tabManager.getActiveContext();
|
||||||
|
if (activeContext) {
|
||||||
|
activeContext.setNote(change.noteId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -141,7 +144,10 @@ export default class RecentChangesDialog extends BasicWidget {
|
|||||||
// Skip clicks on the link or deleted notes
|
// Skip clicks on the link or deleted notes
|
||||||
if (e.target?.nodeName !== "A" && !change.current_isDeleted) {
|
if (e.target?.nodeName !== "A" && !change.current_isDeleted) {
|
||||||
// Open the current note
|
// Open the current note
|
||||||
appContext.tabManager.getActiveContext().setNote(change.noteId);
|
const activeContext = appContext.tabManager.getActiveContext();
|
||||||
|
if (activeContext) {
|
||||||
|
activeContext.setNote(change.noteId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.toggleClass("deleted-note", !!change.current_isDeleted)
|
.toggleClass("deleted-note", !!change.current_isDeleted)
|
||||||
|
@ -140,13 +140,19 @@ export default class QuickSearchWidget extends BasicWidget {
|
|||||||
|
|
||||||
if (!e.target || e.target.nodeName !== "A") {
|
if (!e.target || e.target.nodeName !== "A") {
|
||||||
// click on the link is handled by link handling, but we want the whole item clickable
|
// click on the link is handled by link handling, but we want the whole item clickable
|
||||||
appContext.tabManager.getActiveContext().setNote(note.noteId);
|
const activeContext = appContext.tabManager.getActiveContext();
|
||||||
|
if (activeContext) {
|
||||||
|
activeContext.setNote(note.noteId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
shortcutService.bindElShortcut($link, "return", () => {
|
shortcutService.bindElShortcut($link, "return", () => {
|
||||||
this.dropdown.hide();
|
this.dropdown.hide();
|
||||||
|
|
||||||
appContext.tabManager.getActiveContext().setNote(note.noteId);
|
const activeContext = appContext.tabManager.getActiveContext();
|
||||||
|
if (activeContext) {
|
||||||
|
activeContext.setNote(note.noteId);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.$dropdownMenu.append($link);
|
this.$dropdownMenu.append($link);
|
||||||
|
@ -419,13 +419,13 @@ export default class TabRowWidget extends BasicWidget {
|
|||||||
closeActiveTabCommand({ $el }: CommandListenerData<"closeActiveTab">) {
|
closeActiveTabCommand({ $el }: CommandListenerData<"closeActiveTab">) {
|
||||||
const ntxId = $el.closest(".note-tab").attr("data-ntx-id");
|
const ntxId = $el.closest(".note-tab").attr("data-ntx-id");
|
||||||
|
|
||||||
appContext.tabManager.removeNoteContext(ntxId);
|
appContext.tabManager.removeNoteContext(ntxId ?? null);
|
||||||
}
|
}
|
||||||
|
|
||||||
setTabCloseEvent($tab: JQuery<HTMLElement>) {
|
setTabCloseEvent($tab: JQuery<HTMLElement>) {
|
||||||
$tab.on("mousedown", (e) => {
|
$tab.on("mousedown", (e) => {
|
||||||
if (e.which === 2) {
|
if (e.which === 2) {
|
||||||
appContext.tabManager.removeNoteContext($tab.attr("data-ntx-id"));
|
appContext.tabManager.removeNoteContext($tab.attr("data-ntx-id") ?? null);
|
||||||
|
|
||||||
return true; // event has been handled
|
return true; // event has been handled
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,10 @@ export default class EmptyTypeWidget extends TypeWidget {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
appContext.tabManager.getActiveContext().setNote(suggestion.notePath);
|
const activeContext = appContext.tabManager.getActiveContext();
|
||||||
|
if (activeContext) {
|
||||||
|
activeContext.setNote(suggestion.notePath);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.$workspaceNotes = this.$widget.find(".workspace-notes");
|
this.$workspaceNotes = this.$widget.find(".workspace-notes");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user