mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-30 03:32:26 +08:00
refactor: 💡 add event data and remove redundant code
This commit is contained in:
parent
c4d2c2b8de
commit
d4fe8cf4b9
@ -23,6 +23,7 @@ import type { Attribute } from "../services/attribute_parser.js";
|
|||||||
import type NoteTreeWidget from "../widgets/note_tree.js";
|
import type NoteTreeWidget from "../widgets/note_tree.js";
|
||||||
import type { default as NoteContext, GetTextEditorCallback } from "./note_context.js";
|
import type { default as NoteContext, GetTextEditorCallback } from "./note_context.js";
|
||||||
import type TypeWidget from "../widgets/type_widgets/type_widget.js";
|
import type TypeWidget from "../widgets/type_widgets/type_widget.js";
|
||||||
|
import type EditableTextTypeWidget from "../widgets/type_widgets/editable_text.js";
|
||||||
|
|
||||||
interface Layout {
|
interface Layout {
|
||||||
getRootWidget: (appContext: AppContext) => RootWidget;
|
getRootWidget: (appContext: AppContext) => RootWidget;
|
||||||
@ -131,10 +132,10 @@ export type CommandMappings = {
|
|||||||
protectSubtree: ContextMenuCommandData;
|
protectSubtree: ContextMenuCommandData;
|
||||||
unprotectSubtree: ContextMenuCommandData;
|
unprotectSubtree: ContextMenuCommandData;
|
||||||
openBulkActionsDialog:
|
openBulkActionsDialog:
|
||||||
| ContextMenuCommandData
|
| ContextMenuCommandData
|
||||||
| {
|
| {
|
||||||
selectedOrActiveNoteIds?: string[];
|
selectedOrActiveNoteIds?: string[];
|
||||||
};
|
};
|
||||||
editBranchPrefix: ContextMenuCommandData;
|
editBranchPrefix: ContextMenuCommandData;
|
||||||
convertNoteToAttachment: ContextMenuCommandData;
|
convertNoteToAttachment: ContextMenuCommandData;
|
||||||
duplicateSubtree: ContextMenuCommandData;
|
duplicateSubtree: ContextMenuCommandData;
|
||||||
@ -361,6 +362,10 @@ type EventMappings = {
|
|||||||
relationMapResetZoomIn: { ntxId: string | null | undefined };
|
relationMapResetZoomIn: { ntxId: string | null | undefined };
|
||||||
relationMapResetZoomOut: { ntxId: string | null | undefined };
|
relationMapResetZoomOut: { ntxId: string | null | undefined };
|
||||||
activeNoteChangedEvent: {};
|
activeNoteChangedEvent: {};
|
||||||
|
showAddLinkDialog: {
|
||||||
|
textTypeWidget: EditableTextTypeWidget;
|
||||||
|
text: string;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export type EventListener<T extends EventNames> = {
|
export type EventListener<T extends EventNames> = {
|
||||||
|
@ -83,7 +83,7 @@ export default class AboutDialog extends BasicWidget {
|
|||||||
this.$dataDirectory = this.$widget.find(".data-directory");
|
this.$dataDirectory = this.$widget.find(".data-directory");
|
||||||
}
|
}
|
||||||
|
|
||||||
async refresh(): Promise<void> {
|
async refresh() {
|
||||||
const appInfo = await server.get<AppInfo>("app-info");
|
const appInfo = await server.get<AppInfo>("app-info");
|
||||||
|
|
||||||
this.$appVersion.text(appInfo.appVersion);
|
this.$appVersion.text(appInfo.appVersion);
|
||||||
@ -109,7 +109,7 @@ export default class AboutDialog extends BasicWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async openAboutDialogEvent(): Promise<void> {
|
async openAboutDialogEvent() {
|
||||||
await this.refresh();
|
await this.refresh();
|
||||||
utils.openDialog(this.$widget);
|
utils.openDialog(this.$widget);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import utils from "../../services/utils.js";
|
|||||||
import BasicWidget from "../basic_widget.js";
|
import BasicWidget from "../basic_widget.js";
|
||||||
import type { Suggestion } from "../../services/note_autocomplete.js";
|
import type { Suggestion } from "../../services/note_autocomplete.js";
|
||||||
import type { default as TextTypeWidget } from "../type_widgets/editable_text.js";
|
import type { default as TextTypeWidget } from "../type_widgets/editable_text.js";
|
||||||
|
import type { EventData } from "../../components/app_context.js";
|
||||||
|
|
||||||
const TPL = `
|
const TPL = `
|
||||||
<div class="add-link-dialog modal mx-auto" tabindex="-1" role="dialog">
|
<div class="add-link-dialog modal mx-auto" tabindex="-1" role="dialog">
|
||||||
@ -94,7 +95,7 @@ export default class AddLinkDialog extends BasicWidget {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async showAddLinkDialogEvent({ textTypeWidget, text = "" }: { textTypeWidget: TextTypeWidget; text: string }) {
|
async showAddLinkDialogEvent({ textTypeWidget, text = "" }: EventData<"showAddLinkDialog">) {
|
||||||
this.textTypeWidget = textTypeWidget;
|
this.textTypeWidget = textTypeWidget;
|
||||||
|
|
||||||
this.$addLinkTitleSettings.toggle(!this.textTypeWidget.hasSelection());
|
this.$addLinkTitleSettings.toggle(!this.textTypeWidget.hasSelection());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user