Skip to content

Commit

Permalink
Don't apply author annotations when in composition
Browse files Browse the repository at this point in the history
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 <jonas@freesources.org>
  • Loading branch information
mejo- authored and backportbot-nextcloud[bot] committed Nov 9, 2022
1 parent 51c1a50 commit 4018393
Showing 1 changed file with 10 additions and 2 deletions.
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

0 comments on commit 4018393

Please sign in to comment.