mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	chore(client/ts): port some more files
This commit is contained in:
		| @@ -25,6 +25,7 @@ import type { default as NoteContext, GetTextEditorCallback } from "./note_conte | |||||||
| import type { ContextMenuEvent } from "../menus/context_menu.js"; | import type { ContextMenuEvent } from "../menus/context_menu.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"; | import type EditableTextTypeWidget from "../widgets/type_widgets/editable_text.js"; | ||||||
|  | import type FAttribute from "../entities/fattribute.js"; | ||||||
|  |  | ||||||
| interface Layout { | interface Layout { | ||||||
|     getRootWidget: (appContext: AppContext) => RootWidget; |     getRootWidget: (appContext: AppContext) => RootWidget; | ||||||
| @@ -245,7 +246,7 @@ export type CommandMappings = { | |||||||
|  |  | ||||||
|     toggleZenMode: CommandData; |     toggleZenMode: CommandData; | ||||||
|  |  | ||||||
|     updateAttributeList: CommandData & { attributes: Attribute[] }; |     updateAttributeList: CommandData & { attributes: FAttribute[] }; | ||||||
|     saveAttributes: CommandData; |     saveAttributes: CommandData; | ||||||
|     reloadAttributes: CommandData; |     reloadAttributes: CommandData; | ||||||
|     refreshNoteList: CommandData & { noteId: string }; |     refreshNoteList: CommandData & { noteId: string }; | ||||||
|   | |||||||
| @@ -28,7 +28,7 @@ const TPL = ` | |||||||
|     </div> |     </div> | ||||||
| </div>`; | </div>`; | ||||||
|  |  | ||||||
| type ConfirmDialogCallback = (val: false | ConfirmDialogOptions) => void; | export type ConfirmDialogCallback = (val?: false | ConfirmDialogOptions) => void; | ||||||
|  |  | ||||||
| export interface ConfirmDialogOptions { | export interface ConfirmDialogOptions { | ||||||
|     confirmed: boolean; |     confirmed: boolean; | ||||||
|   | |||||||
| @@ -1,7 +1,9 @@ | |||||||
|  | import type { EventData } from "../../components/app_context.js"; | ||||||
| import { t } from "../../services/i18n.js"; | import { t } from "../../services/i18n.js"; | ||||||
| import utils from "../../services/utils.js"; | import utils from "../../services/utils.js"; | ||||||
| import BasicWidget from "../basic_widget.js"; | import BasicWidget from "../basic_widget.js"; | ||||||
| import { Modal } from "bootstrap"; | import { Modal } from "bootstrap"; | ||||||
|  | import type { ConfirmDialogCallback } from "./confirm.js"; | ||||||
| 
 | 
 | ||||||
| const TPL = ` | const TPL = ` | ||||||
| <div class="info-dialog modal mx-auto" tabindex="-1" role="dialog" style="z-index: 2000;"> | <div class="info-dialog modal mx-auto" tabindex="-1" role="dialog" style="z-index: 2000;"> | ||||||
| @@ -22,6 +24,13 @@ const TPL = ` | |||||||
| </div>`;
 | </div>`;
 | ||||||
| 
 | 
 | ||||||
| export default class InfoDialog extends BasicWidget { | export default class InfoDialog extends BasicWidget { | ||||||
|  | 
 | ||||||
|  |     private resolve: ConfirmDialogCallback | null; | ||||||
|  |     private modal!: bootstrap.Modal; | ||||||
|  |     private $originallyFocused!: JQuery<HTMLElement> | null; | ||||||
|  |     private $infoContent!: JQuery<HTMLElement>; | ||||||
|  |     private $okButton!: JQuery<HTMLElement>; | ||||||
|  | 
 | ||||||
|     constructor() { |     constructor() { | ||||||
|         super(); |         super(); | ||||||
| 
 | 
 | ||||||
| @@ -31,7 +40,7 @@ export default class InfoDialog extends BasicWidget { | |||||||
| 
 | 
 | ||||||
|     doRender() { |     doRender() { | ||||||
|         this.$widget = $(TPL); |         this.$widget = $(TPL); | ||||||
|         this.modal = Modal.getOrCreateInstance(this.$widget); |         this.modal = Modal.getOrCreateInstance(this.$widget[0]); | ||||||
|         this.$infoContent = this.$widget.find(".info-dialog-content"); |         this.$infoContent = this.$widget.find(".info-dialog-content"); | ||||||
|         this.$okButton = this.$widget.find(".info-dialog-ok-button"); |         this.$okButton = this.$widget.find(".info-dialog-ok-button"); | ||||||
| 
 | 
 | ||||||
| @@ -51,10 +60,17 @@ export default class InfoDialog extends BasicWidget { | |||||||
|         this.$okButton.on("click", () => this.modal.hide()); |         this.$okButton.on("click", () => this.modal.hide()); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     showInfoDialogEvent({ message, callback }) { |     showInfoDialogEvent({ message, callback }: EventData<"showInfoDialog">) { | ||||||
|         this.$originallyFocused = $(":focus"); |         this.$originallyFocused = $(":focus"); | ||||||
| 
 | 
 | ||||||
|  |         if (typeof message === "string") { | ||||||
|             this.$infoContent.text(message); |             this.$infoContent.text(message); | ||||||
|  |         } else if (Array.isArray(message)) { | ||||||
|  |             this.$infoContent.html(message[0]); | ||||||
|  |         } else { | ||||||
|  |             this.$infoContent.html(message as HTMLElement); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
|         utils.openDialog(this.$widget); |         utils.openDialog(this.$widget); | ||||||
| 
 | 
 | ||||||
| @@ -2,6 +2,7 @@ import { t } from "../../services/i18n.js"; | |||||||
| import NoteContextAwareWidget from "../note_context_aware_widget.js"; | import NoteContextAwareWidget from "../note_context_aware_widget.js"; | ||||||
| import AttributeDetailWidget from "../attribute_widgets/attribute_detail.js"; | import AttributeDetailWidget from "../attribute_widgets/attribute_detail.js"; | ||||||
| import AttributeEditorWidget from "../attribute_widgets/attribute_editor.js"; | import AttributeEditorWidget from "../attribute_widgets/attribute_editor.js"; | ||||||
|  | import type { CommandListenerData } from "../../components/app_context.js"; | ||||||
| 
 | 
 | ||||||
| const TPL = ` | const TPL = ` | ||||||
| <div class="attribute-list"> | <div class="attribute-list"> | ||||||
| @@ -24,6 +25,11 @@ const TPL = ` | |||||||
| `;
 | `;
 | ||||||
| 
 | 
 | ||||||
| export default class OwnedAttributeListWidget extends NoteContextAwareWidget { | export default class OwnedAttributeListWidget extends NoteContextAwareWidget { | ||||||
|  | 
 | ||||||
|  |     private attributeDetailWidget: AttributeDetailWidget; | ||||||
|  |     private attributeEditorWidget: AttributeEditorWidget; | ||||||
|  |     private $title!: JQuery<HTMLElement>; | ||||||
|  | 
 | ||||||
|     get name() { |     get name() { | ||||||
|         return "ownedAttributes"; |         return "ownedAttributes"; | ||||||
|     } |     } | ||||||
| @@ -44,7 +50,7 @@ export default class OwnedAttributeListWidget extends NoteContextAwareWidget { | |||||||
| 
 | 
 | ||||||
|     getTitle() { |     getTitle() { | ||||||
|         return { |         return { | ||||||
|             show: !this.note.isLaunchBarConfig(), |             show: !this.note?.isLaunchBarConfig(), | ||||||
|             title: t("owned_attribute_list.owned_attributes"), |             title: t("owned_attribute_list.owned_attributes"), | ||||||
|             icon: "bx bx-list-check" |             icon: "bx bx-list-check" | ||||||
|         }; |         }; | ||||||
| @@ -68,7 +74,7 @@ export default class OwnedAttributeListWidget extends NoteContextAwareWidget { | |||||||
|         await this.attributeEditorWidget.refresh(); |         await this.attributeEditorWidget.refresh(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async updateAttributeListCommand({ attributes }) { |     async updateAttributeListCommand({ attributes }: CommandListenerData<"updateAttributeList">) { | ||||||
|         await this.attributeEditorWidget.updateAttributeList(attributes); |         await this.attributeEditorWidget.updateAttributeList(attributes); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @@ -1,6 +1,7 @@ | |||||||
| import NoteContextAwareWidget from "../note_context_aware_widget.js"; | import NoteContextAwareWidget from "../note_context_aware_widget.js"; | ||||||
| import keyboardActionService from "../../services/keyboard_actions.js"; | import keyboardActionService from "../../services/keyboard_actions.js"; | ||||||
| import { t } from "../../services/i18n.js"; | import { t } from "../../services/i18n.js"; | ||||||
|  | import type FNote from "../../entities/fnote.js"; | ||||||
| 
 | 
 | ||||||
| const TPL = ` | const TPL = ` | ||||||
| <div class="script-runner-widget"> | <div class="script-runner-widget"> | ||||||
| @@ -23,6 +24,10 @@ const TPL = ` | |||||||
| </div>`;
 | </div>`;
 | ||||||
| 
 | 
 | ||||||
| export default class ScriptExecutorWidget extends NoteContextAwareWidget { | export default class ScriptExecutorWidget extends NoteContextAwareWidget { | ||||||
|  | 
 | ||||||
|  |     private $executeButton!: JQuery<HTMLElement>; | ||||||
|  |     private $executeDescription!: JQuery<HTMLElement>; | ||||||
|  | 
 | ||||||
|     isEnabled() { |     isEnabled() { | ||||||
|         return ( |         return ( | ||||||
|             super.isEnabled() && |             super.isEnabled() && | ||||||
| @@ -33,7 +38,7 @@ export default class ScriptExecutorWidget extends NoteContextAwareWidget { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     isTriliumSqlite() { |     isTriliumSqlite() { | ||||||
|         return this.note.mime === "text/x-sqlite;schema=trilium"; |         return this.note?.mime === "text/x-sqlite;schema=trilium"; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     getTitle() { |     getTitle() { | ||||||
| @@ -53,7 +58,7 @@ export default class ScriptExecutorWidget extends NoteContextAwareWidget { | |||||||
|         this.$executeDescription = this.$widget.find(".execute-description"); |         this.$executeDescription = this.$widget.find(".execute-description"); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async refreshWithNote(note) { |     async refreshWithNote(note: FNote) { | ||||||
|         const executeTitle = note.getLabelValue("executeButton") || (this.isTriliumSqlite() ? t("script_executor.execute_query") : t("script_executor.execute_script")); |         const executeTitle = note.getLabelValue("executeButton") || (this.isTriliumSqlite() ? t("script_executor.execute_query") : t("script_executor.execute_script")); | ||||||
| 
 | 
 | ||||||
|         this.$executeButton.text(executeTitle); |         this.$executeButton.text(executeTitle); | ||||||
		Reference in New Issue
	
	Block a user