Skip to content

Commit d64c6b3

Browse files
fix(editor): fix swapped parameter order in onNotificationWarning callback and add types
The CKEditor notification warning handler had its parameters reversed (data, evt) instead of (evt, data), causing it to read title/message from EventInfo and call .stop() on NotificationShowEventData. Added proper types (EventInfo, NotificationShowEventData) to prevent future regressions.
1 parent 1b638fd commit d64c6b3

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

apps/client/src/widgets/type_widgets/text/CKEditorWithWatchdog.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CKTextEditor, ClassicEditor, EditorWatchdog, PopupEditor, TemplateDefinition,type WatchdogConfig } from "@triliumnext/ckeditor5";
1+
import { CKTextEditor, ClassicEditor, EditorWatchdog, PopupEditor, TemplateDefinition, type EventInfo, type NotificationShowEventData, type WatchdogConfig } from "@triliumnext/ckeditor5";
22
import { DISPLAYABLE_LOCALE_IDS } from "@triliumnext/commons";
33
import { HTMLProps, RefObject, useEffect, useImperativeHandle, useRef, useState } from "preact/compat";
44

@@ -25,7 +25,7 @@ interface CKEditorWithWatchdogProps extends Pick<HTMLProps<HTMLDivElement>, "cla
2525
isClassicEditor?: boolean;
2626
watchdogRef: RefObject<EditorWatchdog>;
2727
watchdogConfig?: WatchdogConfig;
28-
onNotificationWarning?: (evt: any, data: any) => void;
28+
onNotificationWarning?: (evt: EventInfo, data: NotificationShowEventData) => void;
2929
onWatchdogStateChange?: (watchdog: EditorWatchdog) => void;
3030
onChange: () => void;
3131
/** 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). */

apps/client/src/widgets/type_widgets/text/EditableText.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import "./EditableText.css";
22

3-
import { CKTextEditor, EditorWatchdog, TemplateDefinition } from "@triliumnext/ckeditor5";
3+
import { CKTextEditor, EditorWatchdog, TemplateDefinition, type EventInfo, type NotificationShowEventData } from "@triliumnext/ckeditor5";
44
import { deferred } from "@triliumnext/commons";
55
import { RefObject } from "preact";
66
import { useCallback, useEffect, useRef, useState } from "preact/hooks";
@@ -333,13 +333,13 @@ function useWatchdogCrashHandling() {
333333
return onWatchdogStateChange;
334334
}
335335

336-
function onNotificationWarning(data, evt) {
336+
function onNotificationWarning(evt: EventInfo, data: NotificationShowEventData) {
337337
const title = data.title;
338-
const message = data.message.message;
338+
const message = data.message;
339339

340340
if (title && message) {
341-
toast.showErrorTitleAndMessage(data.title, data.message.message);
342-
} else if (title) {
341+
toast.showErrorTitleAndMessage(title, message);
342+
} else if (title || message) {
343343
toast.showError(title || message);
344344
}
345345

packages/ckeditor5/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { BalloonEditor, DecoupledEditor, FindAndReplaceEditing, FindCommand } fr
77
import "./translation_overrides.js";
88
export { default as EditorWatchdog } from "./custom_watchdog";
99
export { loadPremiumPlugins } from "./plugins.js";
10-
export type { EditorConfig, MentionFeed, MentionFeedObjectItem, ModelNode, ModelPosition, ModelElement, ModelText, WatchdogConfig, WatchdogState } from "ckeditor5";
10+
export type { EditorConfig, EventInfo, MentionFeed, MentionFeedObjectItem, ModelNode, ModelPosition, ModelElement, ModelText, NotificationShowEventData, WatchdogConfig, WatchdogState } from "ckeditor5";
1111
export type { TemplateDefinition } from "ckeditor5-premium-features";
1212
export { default as buildExtraCommands } from "./extra_slash_commands.js";
1313
export { default as getCkLocale } from "./i18n.js";

0 commit comments

Comments
 (0)