Skip to content

Build your personal knowledge base with Trilium Notes

fix lost content data after CKEditor crash, closes #3584

zadamc95c5bb4714f
diff --git a/src/public/app/widgets/type_widgets/editable_text.js b/src/public/app/widgets/type_widgets/editable_text.js
index 67003dc689..5fa11e5715 100644
--- a/src/public/app/widgets/type_widgets/editable_text.js
+++ b/src/public/app/widgets/type_widgets/editable_text.js
@@ -154,6 +154,19 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
}
});
+ await this.watchdog.setCreator(async (elementOrData, editorConfig) => {
+ const editor = await BalloonEditor.create(elementOrData, editorConfig);
+
+ editor.model.document.on('change:data', () => this.spacedUpdate.scheduleUpdate());
+
+ if (glob.isDev && ENABLE_INSPECTOR) {
+ await import(/* webpackIgnore: true */'../../../libraries/ckeditor/inspector.js');
+ CKEditorInspector.attach(editor);
+ }
+
+ return editor;
+ });
+
await this.watchdog.create(this.$editor[0], {
placeholder: "Type the content of your note here ...",
mention: mentionSetup,
@@ -168,13 +181,6 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
enablePreview: true // Enable preview view
}
});
-
- this.watchdog.editor.model.document.on('change:data', () => this.spacedUpdate.scheduleUpdate());
-
- if (glob.isDev && ENABLE_INSPECTOR) {
- await import(/* webpackIgnore: true */'../../../libraries/ckeditor/inspector.js');
- CKEditorInspector.attach(this.watchdog.editor);
- }
}
async doRefresh(note) {