From f49ef4bec8070164117a3081dcdbe72a5cdd1d17 Mon Sep 17 00:00:00 2001 From: Jonatan Heyman Date: Tue, 29 Oct 2024 14:12:18 +0100 Subject: [PATCH] Show error message if failing to unserialize note data (e.g. if a note's format has a major version that is unsupported) --- src/editor/editor.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/editor/editor.js b/src/editor/editor.js index fb23d9c..3d4d77d 100644 --- a/src/editor/editor.js +++ b/src/editor/editor.js @@ -23,6 +23,7 @@ import { todoCheckboxPlugin} from "./todo-checkbox.ts" import { links } from "./links.js" import { NoteFormat } from "../common/note-format.js" import { useNotesStore } from "../stores/notes-store.js"; +import { useErrorStore } from "../stores/error-store.js"; function getKeymapExtensions(editor, keymap) { @@ -66,6 +67,7 @@ export class HeynoteEditor { this.setDefaultBlockLanguage(defaultBlockToken, defaultBlockAutoDetect) this.contentLoaded = false this.notesStore = useNotesStore() + this.errorStore = useErrorStore() this.name = "" @@ -178,6 +180,7 @@ export class HeynoteEditor { this.setReadOnly(false) } catch (e) { this.setReadOnly(true) + this.errorStore.addError(`Failed to load note: ${e.message}`) throw new Error(`Failed to load note: ${e.message}`) } this.name = this.note.metadata?.name || this.path