mirror of
https://github.com/zadam/trilium.git
synced 2025-12-28 10:14:26 +01:00
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
export default class NoteDetailWidget extends NoteContextAwareWidget {
|
|
|
|
private typeWidgets: Record<string, TypeWidget>;
|
|
private spacedUpdate: SpacedUpdate;
|
|
private type?: ExtendedNoteType;
|
|
private mime?: string;
|
|
|
|
constructor() {
|
|
super();
|
|
|
|
this.typeWidgets = {};
|
|
|
|
appContext.addBeforeUnloadListener(this);
|
|
}
|
|
|
|
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();
|
|
}
|
|
}
|
|
|
|
async runActiveNoteCommand(params: CommandListenerData<"runActiveNote">) {
|
|
if (this.isNoteContext(params.ntxId)) {
|
|
// make sure that script is saved before running it #4028
|
|
await this.spacedUpdate.updateNowIfNecessary();
|
|
}
|
|
|
|
return await this.parent?.triggerCommand("runActiveNote", params);
|
|
}
|
|
|
|
beforeUnloadEvent() {
|
|
return this.spacedUpdate.isAllSavedAndTriggerUpdate();
|
|
}
|
|
|
|
}
|