Skip to content
Merged
Changes from 1 commit
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
Next Next commit
Don't apply author annotations when in composition
When typing dead keys (like diacritics), the browser is in composition
mode[1] until the accompanioning character is typed. This breaks author
annotations.

We have to hold back the transaction when in composition and only apply
it afterwards, as suggested at [2]. So check for `view.composing` before
applying the transaction.

Fixes: #2871

[1] https://w3c.github.io/uievents/#events-compositionevents
[2] https://discuss.prosemirror.net/t/plugins-and-characters-with-a-diacritic/2674/3

Signed-off-by: Jonas <[email protected]>
  • Loading branch information
mejo- authored and backportbot-nextcloud[bot] committed Nov 9, 2022
commit c28473387d224130debeec6b78226133e4beaa99
12 changes: 10 additions & 2 deletions src/extensions/UserColor.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,16 @@ const UserColor = Extension.create({
},

addProseMirrorPlugins() {
let viewReference = null
return [
new Plugin({
clientID: this.options.clientID,
color: this.options.color,
name: this.options.name,
view: (editorView) => {
viewReference = editorView
return {}
},
state: {
init(_, instance) {
return {
Expand All @@ -63,8 +68,11 @@ const UserColor = Extension.create({
// we have an undefined client id for own transactions
tr.setMeta('clientID', tr.steps.map(i => this.spec.clientID))
}
tracked = tracked.applyTransform(tr)
tState = tracked
// Don't apply transaction when in composition (Github issue #2871)
if (!viewReference.composing) {
tracked = tracked.applyTransform(tr)
tState = tracked
}
}
decos = tState.blameMap
.map(span => {
Expand Down