From 43799dc57ddf82de577990ab72ac02136ad1a96e Mon Sep 17 00:00:00 2001 From: Chasen Stark Date: Thu, 1 Feb 2024 15:16:58 -0500 Subject: [PATCH] Editor.ts: Revert fix for Grammarly bug 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. --- source/Editor.ts | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/source/Editor.ts b/source/Editor.ts index 6be5ec4..e0403bd 100644 --- a/source/Editor.ts +++ b/source/Editor.ts @@ -41,7 +41,7 @@ import { } from './node/MergeSplit'; import { getBlockWalker, getNextBlock, isEmptyBlock } from './node/Block'; import { cleanTree, cleanupBRs, escapeHTML, removeEmptyInlines } from './Clean'; -import { cantFocusEmptyTextNodes, isAndroid, ZWS } from './Constants'; +import { cantFocusEmptyTextNodes, ZWS } from './Constants'; import { expandRangeToBlockBoundaries, getEndBlockOfRange, @@ -256,25 +256,6 @@ class Squire { _beforeInput(event: InputEvent): void { switch (event.inputType) { - case 'insertText': - // Generally we let the browser handle text insertion, as it - // does so fine. However, the Samsung keyboard on Android with - // 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(); - } - break; case 'insertLineBreak': event.preventDefault(); this.splitBlock(true);