typewriter-editor / typewriter

A rich text editor based off of Quill.js and Ultradom, and using Svelte for UI.
MIT License
394 stars 32 forks source link

Adds better support for dealing with IMEs and text composition events. #119

Closed taylorhadden closed 2 years ago

taylorhadden commented 2 years ago

This change fixes several issues present in typewriter when dealing with IMEs and the text composition events in general. The two cases tested were the emoji selector in Windows 10 (Windows+Period) and dictation in MacOS. Prior to this change, users would see duplicate emoji insertion in the best case, and a jumbled mess of text in the worst case with dictation. This was caused by essentially duplicate mutations being handled during compositionupdate and compositionend events.

This change caches mutations while in the midst of composition. This allows the IME or other composition system to have full control over the contents of its target elements until the composition is complete (via compositionend). At that moment, the cached mutations are evaluated and turned into a single Delta for the entire interaction.

jacwright commented 2 years ago

Looks good. 👍 Thank you!

jacwright commented 1 year ago

This change causes issues on Android devices using GBoard keyboard. GBoard is the buggiest software I've encountered in mass use. The worst. We'll try and work on it more over time, but we need to roll this change back or put it under a flag until we can properly work around Gboard. https://discuss.prosemirror.net/t/contenteditable-on-android-is-the-absolute-worst/3810

jacwright commented 1 year ago

In v0.7.14 you can use this functionality by calling:

editor.modules.input.allowComposition()

after creating your editor.