From 726797b13d2efde22c5f357b545e81a3f15dafa5 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Wed, 7 May 2025 22:29:11 +0300 Subject: [PATCH] chore(client): fix more type errors --- apps/client/src/services/note_create.ts | 3 ++- .../src/widgets/type_widgets/ckeditor/syntax_highlight.ts | 5 +++-- packages/ckeditor5/src/index.ts | 5 ++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/client/src/services/note_create.ts b/apps/client/src/services/note_create.ts index 14299ba4f..5fa262553 100644 --- a/apps/client/src/services/note_create.ts +++ b/apps/client/src/services/note_create.ts @@ -9,6 +9,7 @@ import { t } from "./i18n.js"; import type FNote from "../entities/fnote.js"; import type FBranch from "../entities/fbranch.js"; import type { ChooseNoteTypeResponse } from "../widgets/dialogs/note_type_chooser.js"; +import type { CKTextEditor } from "@triliumnext/ckeditor5"; interface CreateNoteOpts { isProtected?: boolean; @@ -22,7 +23,7 @@ interface CreateNoteOpts { focus?: "title" | "content"; target?: string; targetBranchId?: string; - textEditor?: TextEditor; + textEditor?: CKTextEditor; } interface Response { diff --git a/apps/client/src/widgets/type_widgets/ckeditor/syntax_highlight.ts b/apps/client/src/widgets/type_widgets/ckeditor/syntax_highlight.ts index efd35969e..2324aab23 100644 --- a/apps/client/src/widgets/type_widgets/ckeditor/syntax_highlight.ts +++ b/apps/client/src/widgets/type_widgets/ckeditor/syntax_highlight.ts @@ -8,11 +8,12 @@ * TODO: Generally this class can be done directly in the CKEditor repository. */ +import type { CKTextEditor } from "@triliumnext/ckeditor5"; import library_loader from "../../../services/library_loader.js"; import mime_types from "../../../services/mime_types.js"; import { isSyntaxHighlightEnabled } from "../../../services/syntax_highlight.js"; -export async function initSyntaxHighlighting(editor: TextEditor) { +export async function initSyntaxHighlighting(editor: CKTextEditor) { if (!isSyntaxHighlightEnabled) { return; } @@ -54,7 +55,7 @@ function assert(e: boolean, msg?: string) { // TODO: Should this be scoped to note? let markerCounter = 0; -function initTextEditor(textEditor: TextEditor) { +function initTextEditor(textEditor: CKTextEditor) { log("initTextEditor"); const document = textEditor.model.document; diff --git a/packages/ckeditor5/src/index.ts b/packages/ckeditor5/src/index.ts index 8c4d887c1..57fd3373f 100644 --- a/packages/ckeditor5/src/index.ts +++ b/packages/ckeditor5/src/index.ts @@ -7,7 +7,10 @@ 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; +export type CKTextEditor = (ClassicEditor | PopupEditor) & { + getSelectedHtml(): string; + removeSelection(): Promise; +}; /** * The text editor that can be used for editing attributes and relations.