Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
chore(ckeditor/watchdog): fix typecheck issues
Elian Dorancd2716090572
diff --git a/apps/client/src/widgets/dialogs/confirm.tsx b/apps/client/src/widgets/dialogs/confirm.tsxindex 8ccfcd6c2f..79829d4d4d 100644--- a/apps/client/src/widgets/dialogs/confirm.tsx+++ b/apps/client/src/widgets/dialogs/confirm.tsx@@ -4,11 +4,12 @@ import { t } from "../../services/i18n";import { useState } from "preact/hooks";import FormCheckbox from "../react/FormCheckbox";import { useTriliumEvent } from "../react/hooks";-import type { VNode } from "preact";+import { isValidElement, type VNode } from "preact";+import { RawHtmlBlock } from "../react/RawHtml";interface ConfirmDialogProps {title?: string;- message?: string | HTMLElement;+ message?: MessageType;callback?: ConfirmDialogCallback;isConfirmDeleteNoteBox?: boolean;}@@ -21,7 +22,7 @@ export default function ConfirmDialog() {function showDialog(title: string | null, message: MessageType, callback: ConfirmDialogCallback, isConfirmDeleteNoteBox: boolean) {setOpts({title: title ?? undefined,- message: (typeof message === "object" && "length" in message ? message[0] : message),+ message,callback,isConfirmDeleteNoteBox});@@ -58,9 +59,10 @@ export default function ConfirmDialog() {show={shown}stackable>- {!opts?.message || typeof opts?.message === "string"- ? <div>{(opts?.message as string) ?? ""}</div>- : <div dangerouslySetInnerHTML={{ __html: opts?.message.outerHTML ?? "" }} />}+ {isValidElement(opts?.message)+ ? opts?.message+ : <RawHtmlBlock html={opts?.message} />+ }{opts?.isConfirmDeleteNoteBox && (<FormCheckboxdiff --git a/apps/client/src/widgets/dialogs/info.tsx b/apps/client/src/widgets/dialogs/info.tsxindex 03fabbfa3e..e53faa8bdb 100644--- a/apps/client/src/widgets/dialogs/info.tsx+++ b/apps/client/src/widgets/dialogs/info.tsx@@ -67,7 +67,7 @@ export default function InfoDialog() {>{isValidElement(opts?.message)? opts?.message- : <RawHtmlBlock className="info-dialog-content" html={opts?.message ?? ""} />+ : <RawHtmlBlock className="info-dialog-content" html={opts?.message} />}</Modal>);}diff --git a/apps/client/src/widgets/type_widgets/code/Code.tsx b/apps/client/src/widgets/type_widgets/code/Code.tsxindex 02117f19f7..b6cde1c7e5 100644--- a/apps/client/src/widgets/type_widgets/code/Code.tsx+++ b/apps/client/src/widgets/type_widgets/code/Code.tsx@@ -77,7 +77,7 @@ export function EditableCode({ note, ntxId, noteContext, debounceUpdate, parentCconst spacedUpdate = useEditorSpacedUpdate({note,noteContext,- getData: () => ({ content: editorRef.current?.getText() }),+ getData: () => ({ content: editorRef.current?.getText() ?? "" }),onContentChange: (content) => {const codeEditor = editorRef.current;if (!codeEditor) return;diff --git a/apps/client/src/widgets/type_widgets/text/CKEditorWithWatchdog.tsx b/apps/client/src/widgets/type_widgets/text/CKEditorWithWatchdog.tsxindex ac00194e38..bf587b9493 100644--- a/apps/client/src/widgets/type_widgets/text/CKEditorWithWatchdog.tsx+++ b/apps/client/src/widgets/type_widgets/text/CKEditorWithWatchdog.tsx@@ -25,7 +25,7 @@ interface CKEditorWithWatchdogProps extends Pick<HTMLProps<HTMLDivElement>, "clawatchdogRef: RefObject<EditorWatchdog>;watchdogConfig?: WatchdogConfig;onNotificationWarning?: (evt: any, data: any) => void;- onWatchdogStateChange?: (watchdog: EditorWatchdog<any>) => void;+ onWatchdogStateChange?: (watchdog: EditorWatchdog) => void;onChange: () => void;/** Called upon whenever a new CKEditor instance is initialized, whether it's the first initialization, after a crash or after a config change that requires it (e.g. content language). */onEditorInitialized?: (editor: CKTextEditor) => void;@@ -204,7 +204,7 @@ export default function CKEditorWithWatchdog({ containerRef: externalContainerRe);}-function buildWatchdog(isClassicEditor: boolean, watchdogConfig?: WatchdogConfig): EditorWatchdog<CKTextEditor> {+function buildWatchdog(isClassicEditor: boolean, watchdogConfig?: WatchdogConfig): EditorWatchdog {if (isClassicEditor) {return new EditorWatchdog(ClassicEditor, watchdogConfig);} else {