Skip to content

Build your personal knowledge base with Trilium Notes

feat(ckeditor/watchdog): ignore parent check (closes #5776)

Elian Dorana1c5ed9eb58c
diff --git a/packages/ckeditor5/src/custom_watchdog.ts b/packages/ckeditor5/src/custom_watchdog.ts
new file mode 100644
index 0000000000..dd3060cbff
--- /dev/null
+++ b/packages/ckeditor5/src/custom_watchdog.ts
@@ -0,0 +1,20 @@
+import { CKEditorError, EditorWatchdog } from "ckeditor5";
+
+const IGNORED_ERRORS = [
+ // See: https://github.com/TriliumNext/Trilium/issues/5776
+ "TypeError: Cannot read properties of null (reading 'parent')"
+]
+
+export default class CustomWatchdog extends EditorWatchdog {
+
+ _isErrorComingFromThisItem(error: CKEditorError): boolean {
+ for (const ignoredError of IGNORED_ERRORS) {
+ if (error.message.includes(ignoredError)) {
+ return false;
+ }
+ }
+
+ return super._isErrorComingFromThisItem(error);
+ }
+
+}
diff --git a/packages/ckeditor5/src/index.ts b/packages/ckeditor5/src/index.ts
index 17b2c775ee..a6b1934775 100644
--- a/packages/ckeditor5/src/index.ts
+++ b/packages/ckeditor5/src/index.ts
@@ -4,7 +4,7 @@ import "./theme/code_block_toolbar.css";
import { COMMON_PLUGINS, CORE_PLUGINS, POPUP_EDITOR_PLUGINS } from "./plugins.js";
import { BalloonEditor, DecoupledEditor, FindAndReplaceEditing, FindCommand } from "ckeditor5";
import "./translation_overrides.js";
-export { EditorWatchdog } from "ckeditor5";
+export { default as EditorWatchdog } from "./custom_watchdog";
export { PREMIUM_PLUGINS } from "./plugins.js";
export type { EditorConfig, MentionFeed, MentionFeedObjectItem, ModelNode, ModelPosition, ModelElement, WatchdogConfig, WatchdogState } from "ckeditor5";
export type { TemplateDefinition } from "ckeditor5-premium-features";