Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/components/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,28 @@ export default defineComponent({
this.idle = false
},

initUndoManagerForEmptyDocument() {
if (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this something that gets added to the history and pushing steps to the server? As discussed I'd be fine with this as a workaround but we should file an upstream issue at least.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@juliusknorr I clear the history after deleting the space, and in my test there were no steps added to the database in this process. I agree that an upstream issue for yjs should be created and this workaround should be removed once the issue is fixed or a better workaround is found.

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
Expand Down Expand Up @@ -520,6 +542,7 @@ export default defineComponent({
isRichEditor: this.isRichEditor,
})
}
this.initUndoManagerForEmptyDocument()
})
this.updateUser(session)
},
Expand Down
Loading