From cff9c03d53f4af92141bb30433f56b0377384d9e Mon Sep 17 00:00:00 2001 From: Benjamin Frueh Date: Wed, 19 Nov 2025 15:23:21 +0100 Subject: [PATCH] Fix: initialize undomanager for empty document Signed-off-by: Benjamin Frueh --- src/components/Editor.vue | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/components/Editor.vue b/src/components/Editor.vue index afa472f7db6..f784bb920e3 100644 --- a/src/components/Editor.vue +++ b/src/components/Editor.vue @@ -485,6 +485,28 @@ export default defineComponent({ this.idle = false }, + initUndoManagerForEmptyDocument() { + if ( + this.editor.state.doc.textContent.length > 0 + || !this.editor.isEditable + ) { + return + } + + if (!this.editor.commands.insertContent(' ')) { + return + } + + this.editor.commands.deleteRange({ from: 0, to: 1 }) + + const undoManager = this.editor.state.plugins + .map((p) => p.getState?.(this.editor.state)?.undoManager) + .find((um) => um?.clear) + undoManager?.clear() + + this.dirty = false + }, + onOpened({ document, session, content, documentState, readOnly }) { this.document = document this.readOnly = readOnly @@ -520,6 +542,7 @@ export default defineComponent({ isRichEditor: this.isRichEditor, }) } + this.initUndoManagerForEmptyDocument() }) this.updateUser(session) },