0
Fork 0
mirror of https://github.com/fastmail/Squire.git synced 2024-12-21 23:03:11 -05:00

Editor.ts: Update insertText comment to address keyboard 'paste' bug

This commit is contained in:
Chasen Stark 2023-11-30 13:09:40 -05:00
parent 8bee51683b
commit 949b5b227e

View file

@ -259,12 +259,18 @@ class Squire {
case 'insertText':
// Generally we let the browser handle text insertion, as it
// does so fine. However, the Samsung keyboard on Android with
// the Grammerly extension goes batshit crazy for some reason
// the Grammarly extension goes batshit crazy for some reason
// and will try to disastrously rewrite the whole data, without
// the user even doing anything (it can happen on first load
// before the user types anything). Fortunately we can detect
// this by looking for a new line in the data and if we see it,
// stop it by preventing default.
// 30-11-2023 Update: The fix for Grammarly bug prevents pasting
// text directly from the keyboard on Android if the text to be
// inserted contains \n, as pasting from the keyboard does not
// fire a true paste event. The Grammarly bug seems to have been
// fixed in Samsung keyboard as of v5.6.10.4, but leaving the
// fix in place for now, as the bug is particularly destructive.
if (isAndroid && event.data && event.data.includes('\n')) {
event.preventDefault();
}