chore: 🤖 fix webpack build error

This commit is contained in:
Jin
2025-03-03 21:02:18 +01:00
parent 2213c500c2
commit 1b76442367
19 changed files with 81 additions and 53 deletions

View File

@@ -457,13 +457,13 @@ function FrontendScriptApi(this: Api, startNote: FNote, currentNote: FNote, orig
this.BasicWidget = BasicWidget;
this.activateNote = async (notePath) => {
await appContext.tabManager.getActiveContext().setNote(notePath);
await appContext.tabManager.getActiveContext()?.setNote(notePath);
};
this.activateNewNote = async (notePath) => {
await ws.waitForMaxKnownEntityChangeId();
await appContext.tabManager.getActiveContext().setNote(notePath);
await appContext.tabManager.getActiveContext()?.setNote(notePath);
await appContext.triggerEvent("focusAndSelectTitle", {});
};
@@ -480,8 +480,8 @@ function FrontendScriptApi(this: Api, startNote: FNote, currentNote: FNote, orig
this.openSplitWithNote = async (notePath, activate) => {
await ws.waitForMaxKnownEntityChangeId();
const subContexts = appContext.tabManager.getActiveContext().getSubContexts();
const { ntxId } = subContexts[subContexts.length - 1];
const subContexts = appContext.tabManager.getActiveContext()?.getSubContexts();
const { ntxId } = subContexts?.[subContexts.length - 1] ?? {};
await appContext.triggerCommand("openNewNoteSplit", { ntxId, notePath });
@@ -591,15 +591,48 @@ function FrontendScriptApi(this: Api, startNote: FNote, currentNote: FNote, orig
this.addTextToActiveContextEditor = (text) => appContext.triggerCommand("addTextToActiveEditor", { text });
this.getActiveContextNote = () => appContext.tabManager.getActiveContextNote();
this.getActiveContext = () => appContext.tabManager.getActiveContext();
this.getActiveMainContext = () => appContext.tabManager.getActiveMainContext();
this.getActiveContextNote = (): FNote => {
const note = appContext.tabManager.getActiveContextNote();
if (!note) {
throw new Error("No active context note found");
}
return note;
};
this.getActiveContext = (): NoteContext => {
const context = appContext.tabManager.getActiveContext();
if (!context) {
throw new Error("No active context found");
}
return context;
};
this.getActiveMainContext = (): NoteContext => {
const context = appContext.tabManager.getActiveMainContext();
if (!context) {
throw new Error("No active main context found");
}
return context;
};
this.getNoteContexts = () => appContext.tabManager.getNoteContexts();
this.getMainNoteContexts = () => appContext.tabManager.getMainNoteContexts();
this.getActiveContextTextEditor = () => appContext.tabManager.getActiveContext()?.getTextEditor();
this.getActiveContextCodeEditor = () => appContext.tabManager.getActiveContext()?.getCodeEditor();
this.getActiveContextTextEditor = () => {
const context = appContext.tabManager.getActiveContext();
if (!context) {
throw new Error("No active context found");
}
return context.getTextEditor();
};
this.getActiveContextCodeEditor = () => {
const context = appContext.tabManager.getActiveContext();
if (!context) {
throw new Error("No active context found");
}
return context.getCodeEditor();
};
this.getActiveNoteDetailWidget = () => new Promise((resolve) => appContext.triggerCommand("executeInActiveNoteDetailWidget", { callback: resolve }));
this.getActiveContextNotePath = () => appContext.tabManager.getActiveContextNotePath();
@@ -665,5 +698,5 @@ function FrontendScriptApi(this: Api, startNote: FNote, currentNote: FNote, orig
}
export default FrontendScriptApi as any as {
new (startNote: FNote, currentNote: FNote, originEntity: Entity | null, $container: JQuery<HTMLElement> | null): Api;
new(startNote: FNote, currentNote: FNote, originEntity: Entity | null, $container: JQuery<HTMLElement> | null): Api;
};