Skip to content
Closed
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.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, would be fine with me then.

However tests seem to fail quite heavily. Maybe it has some unexpected side effects?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some failing tests, such as the ones counting characters seem to be timing-related and caused by this change. Making the tests even more flaky with this workaround doesn't seem ideal. Maybe we should discuss and explore an alternative less invasive workaround for this.

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