Skip to content

Build your personal knowledge base with Trilium Notes

fix(editor): data loss if updating while editor crashed

Elian Dorand7f26fa27c7f
diff --git a/apps/client/src/widgets/type_widgets/editable_text.ts b/apps/client/src/widgets/type_widgets/editable_text.ts
index 9331cde170..005ac1ad40 100644
--- a/apps/client/src/widgets/type_widgets/editable_text.ts
+++ b/apps/client/src/widgets/type_widgets/editable_text.ts
@@ -336,6 +336,11 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
}
getData() {
+ if (!this.watchdog.editor) {
+ // There is nothing to save, most likely a result of the editor crashing and reinitializing.
+ return;
+ }
+
const content = this.watchdog.editor?.getData() ?? "";
// if content is only tags/whitespace (typically <p>&nbsp;</p>), then just make it empty,