chore(ckeditor/watchdog): fix typecheck issues

This commit is contained in:
Elian Doran 2025-12-07 22:09:30 +02:00
parent 9ddf4a1308
commit cd27160905
No known key found for this signature in database
4 changed files with 12 additions and 10 deletions

View File

@ -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 && (
<FormCheckbox

View File

@ -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>);
}

View File

@ -77,7 +77,7 @@ export function EditableCode({ note, ntxId, noteContext, debounceUpdate, parentC
const spacedUpdate = useEditorSpacedUpdate({
note,
noteContext,
getData: () => ({ content: editorRef.current?.getText() }),
getData: () => ({ content: editorRef.current?.getText() ?? "" }),
onContentChange: (content) => {
const codeEditor = editorRef.current;
if (!codeEditor) return;

View File

@ -25,7 +25,7 @@ interface CKEditorWithWatchdogProps extends Pick<HTMLProps<HTMLDivElement>, "cla
watchdogRef: 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 {