diff --git a/apps/client/src/components/app_context.ts b/apps/client/src/components/app_context.ts index a0ebd6a6a..1855876d3 100644 --- a/apps/client/src/components/app_context.ts +++ b/apps/client/src/components/app_context.ts @@ -26,7 +26,7 @@ import type TypeWidget from "../widgets/type_widgets/type_widget.js"; import type EditableTextTypeWidget from "../widgets/type_widgets/editable_text.js"; import type { NativeImage, TouchBar } from "electron"; import TouchBarComponent from "./touch_bar.js"; -import type { ClassicEditor, PopupEditor } from "@triliumnext/ckeditor5"; +import type { CKTextEditor } from "@triliumnext/ckeditor5"; interface Layout { getRootWidget: (appContext: AppContext) => RootWidget; @@ -188,7 +188,7 @@ export type CommandMappings = { callback: (value: NoteDetailWidget | PromiseLike) => void; }; executeWithTextEditor: CommandData & - ExecuteCommandData & { + ExecuteCommandData & { callback?: GetTextEditorCallback; }; executeWithCodeEditor: CommandData & ExecuteCommandData; diff --git a/apps/client/src/components/note_context.ts b/apps/client/src/components/note_context.ts index f1500ee42..81eae41e1 100644 --- a/apps/client/src/components/note_context.ts +++ b/apps/client/src/components/note_context.ts @@ -10,14 +10,14 @@ import options from "../services/options.js"; import type { ViewScope } from "../services/link.js"; import type FNote from "../entities/fnote.js"; import type TypeWidget from "../widgets/type_widgets/type_widget.js"; -import type { ClassicEditor, PopupEditor } from "@triliumnext/ckeditor5"; +import type { CKTextEditor } from "@triliumnext/ckeditor5"; export interface SetNoteOpts { triggerSwitchEvent?: unknown; viewScope?: ViewScope; } -export type GetTextEditorCallback = (editor: ClassicEditor | PopupEditor) => void; +export type GetTextEditorCallback = (editor: CKTextEditor) => void; class NoteContext extends Component implements EventListener<"entitiesReloaded"> { ntxId: string | null; @@ -299,7 +299,7 @@ class NoteContext extends Component implements EventListener<"entitiesReloaded"> } async getTextEditor(callback?: GetTextEditorCallback) { - return this.timeout( + return this.timeout( new Promise((resolve) => appContext.triggerCommand("executeWithTextEditor", { callback, diff --git a/apps/client/src/widgets/type_widgets/editable_text.ts b/apps/client/src/widgets/type_widgets/editable_text.ts index 3e8163f98..e3caf18b3 100644 --- a/apps/client/src/widgets/type_widgets/editable_text.ts +++ b/apps/client/src/widgets/type_widgets/editable_text.ts @@ -18,7 +18,7 @@ import { buildSelectedBackgroundColor } from "../../components/touch_bar.js"; import { buildConfig, buildToolbarConfig } from "./ckeditor/config.js"; import type FNote from "../../entities/fnote.js"; import { getMermaidConfig } from "../../services/mermaid.js"; -import { PopupEditor, ClassicEditor, EditorWatchdog } from "@triliumnext/ckeditor5"; +import { PopupEditor, ClassicEditor, EditorWatchdog, type CKTextEditor } from "@triliumnext/ckeditor5"; const ENABLE_INSPECTOR = false; @@ -128,7 +128,7 @@ function buildListOfLanguages() { export default class EditableTextTypeWidget extends AbstractTextTypeWidget { private contentLanguage?: string | null; - private watchdog!: EditorWatchdog; + private watchdog!: EditorWatchdog; private $editor!: JQuery; @@ -158,7 +158,7 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget { // display of $widget in both branches. this.$widget.show(); - this.watchdog = new EditorWatchdog(editorClass, { + this.watchdog = new EditorWatchdog(editorClass, { // An average number of milliseconds between the last editor errors (defaults to 5000). // When the period of time between errors is lower than that and the crashNumberLimit // is also reached, the watchdog changes its state to crashedPermanently, and it stops diff --git a/packages/ckeditor5/src/index.ts b/packages/ckeditor5/src/index.ts index 7ce7f501b..2edbae35a 100644 --- a/packages/ckeditor5/src/index.ts +++ b/packages/ckeditor5/src/index.ts @@ -3,18 +3,33 @@ import { COMMON_PLUGINS, POPUP_EDITOR_PLUGINS } from "./plugins"; import { BalloonEditor, DecoupledEditor } from "ckeditor5"; export { EditorWatchdog } from "ckeditor5"; +/** + * Short-hand for the CKEditor classes supported by Trilium for text editing. + * Specialized editors such as the {@link AttributeEditor} are not included. + */ +export type CKTextEditor = ClassicEditor | PopupEditor; + +/** + * The text editor that can be used for editing attributes and relations. + */ export class AttributeEditor extends BalloonEditor { static override get builtinPlugins() { return []; } } +/** + * A text editor configured as a {@link DecoupledEditor} (fixed toolbar mode), as well as its preconfigured plugins. + */ export class ClassicEditor extends DecoupledEditor { static override get builtinPlugins() { return COMMON_PLUGINS; } } +/** + * A text editor configured as a {@link BalloonEditor} (floating toolbar mode), as well as its preconfigured plugins. + */ export class PopupEditor extends BalloonEditor { static override get builtinPlugins() { return POPUP_EDITOR_PLUGINS;