From f284f64dace774f470cccf2a166f123846e244a5 Mon Sep 17 00:00:00 2001 From: kei kim Date: Mon, 24 Jul 2023 21:42:44 +0900 Subject: [PATCH 1/7] fix: Handling Korean character clearing exceptions --- packages/lexical-rich-text/src/index.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/lexical-rich-text/src/index.ts b/packages/lexical-rich-text/src/index.ts index bf53a8acdd4..82a1a46a403 100644 --- a/packages/lexical-rich-text/src/index.ts +++ b/packages/lexical-rich-text/src/index.ts @@ -860,6 +860,13 @@ export function registerRichText(editor: LexicalEditor): () => void { if (!$isRangeSelection(selection)) { return false; } + + // Exception handling for iOS native behavior instead of Lexical's behavior when using Korean on iOS devices. + // On other devices, if you backspace during composing, you get a keyCode of 229 (composing state), but on iOS, the behavior is different: it outputs a keyCode of 8 and appends the remnants of the composing character to the previous character. + if (event.keyCode === 8 && navigator.language === 'ko-KR' && /iPad|iPhone|iPod/.test(navigator.userAgent)) { + return false + } + event.preventDefault(); const {anchor} = selection; const anchorNode = anchor.getNode(); From c6e9e1bbc281741f8d8ac01c6bc5a6b5d6221634 Mon Sep 17 00:00:00 2001 From: "deadintegral (kei)" Date: Thu, 4 Apr 2024 22:20:50 +0900 Subject: [PATCH 2/7] Update packages/lexical-rich-text/src/index.ts Co-authored-by: wnhlee <40269597+2wheeh@users.noreply.github.com> --- packages/lexical-rich-text/src/index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/lexical-rich-text/src/index.ts b/packages/lexical-rich-text/src/index.ts index 82a1a46a403..6e3a4c78820 100644 --- a/packages/lexical-rich-text/src/index.ts +++ b/packages/lexical-rich-text/src/index.ts @@ -863,8 +863,12 @@ export function registerRichText(editor: LexicalEditor): () => void { // Exception handling for iOS native behavior instead of Lexical's behavior when using Korean on iOS devices. // On other devices, if you backspace during composing, you get a keyCode of 229 (composing state), but on iOS, the behavior is different: it outputs a keyCode of 8 and appends the remnants of the composing character to the previous character. - if (event.keyCode === 8 && navigator.language === 'ko-KR' && /iPad|iPhone|iPod/.test(navigator.userAgent)) { - return false + if ( + event.keyCode === 8 && + navigator.language === 'ko-KR' && + /iPad|iPhone|iPod/.test(navigator.userAgent) + ) { + return false; } event.preventDefault(); From dc23b3303d00cf7822df43b2350af831d2e01857 Mon Sep 17 00:00:00 2001 From: Sherry Wong Date: Mon, 11 Nov 2024 17:52:17 +0800 Subject: [PATCH 3/7] address prettier --- packages/lexical-rich-text/src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/lexical-rich-text/src/index.ts b/packages/lexical-rich-text/src/index.ts index 6e3a4c78820..c4fc2c53d68 100644 --- a/packages/lexical-rich-text/src/index.ts +++ b/packages/lexical-rich-text/src/index.ts @@ -863,14 +863,14 @@ export function registerRichText(editor: LexicalEditor): () => void { // Exception handling for iOS native behavior instead of Lexical's behavior when using Korean on iOS devices. // On other devices, if you backspace during composing, you get a keyCode of 229 (composing state), but on iOS, the behavior is different: it outputs a keyCode of 8 and appends the remnants of the composing character to the previous character. - if ( + if ( event.keyCode === 8 && navigator.language === 'ko-KR' && /iPad|iPhone|iPod/.test(navigator.userAgent) ) { return false; } - + event.preventDefault(); const {anchor} = selection; const anchorNode = anchor.getNode(); From b9e46a75cc1fa7cb5f1a295d387ae4ec4fd58744 Mon Sep 17 00:00:00 2001 From: Wonhee Lee Date: Wed, 13 Nov 2024 00:27:31 +0900 Subject: [PATCH 4/7] fix: move korean handling not to block isCollapsed handling on backspace --- packages/lexical-rich-text/src/index.ts | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/packages/lexical-rich-text/src/index.ts b/packages/lexical-rich-text/src/index.ts index c4fc2c53d68..cd4ef0f03fc 100644 --- a/packages/lexical-rich-text/src/index.ts +++ b/packages/lexical-rich-text/src/index.ts @@ -861,17 +861,6 @@ export function registerRichText(editor: LexicalEditor): () => void { return false; } - // Exception handling for iOS native behavior instead of Lexical's behavior when using Korean on iOS devices. - // On other devices, if you backspace during composing, you get a keyCode of 229 (composing state), but on iOS, the behavior is different: it outputs a keyCode of 8 and appends the remnants of the composing character to the previous character. - if ( - event.keyCode === 8 && - navigator.language === 'ko-KR' && - /iPad|iPhone|iPod/.test(navigator.userAgent) - ) { - return false; - } - - event.preventDefault(); const {anchor} = selection; const anchorNode = anchor.getNode(); @@ -885,6 +874,14 @@ export function registerRichText(editor: LexicalEditor): () => void { return editor.dispatchCommand(OUTDENT_CONTENT_COMMAND, undefined); } } + + // Exception handling for iOS native behavior instead of Lexical's behavior when using Korean on iOS devices. + // more details - https://github.com/facebook/lexical/issues/5841 + if (navigator.language === 'ko-KR' && IS_IOS) { + return false; + } + event.preventDefault(); + return editor.dispatchCommand(DELETE_CHARACTER_COMMAND, true); }, COMMAND_PRIORITY_EDITOR, From e08856c969f0e581675ec680edbdda8374fa7252 Mon Sep 17 00:00:00 2001 From: Wonhee Lee Date: Wed, 13 Nov 2024 00:28:51 +0900 Subject: [PATCH 5/7] fix: add korean handling to plain text plugin as we do in rich text plugin --- packages/lexical-plain-text/src/index.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/lexical-plain-text/src/index.ts b/packages/lexical-plain-text/src/index.ts index 1df4cb1c1ca..3300e8d73c3 100644 --- a/packages/lexical-plain-text/src/index.ts +++ b/packages/lexical-plain-text/src/index.ts @@ -274,6 +274,12 @@ export function registerPlainText(editor: LexicalEditor): () => void { return false; } + // Exception handling for iOS native behavior instead of Lexical's behavior when using Korean on iOS devices. + // more details - https://github.com/facebook/lexical/issues/5841 + if (IS_IOS && navigator.language === 'ko-KR') { + return false; + } + event.preventDefault(); return editor.dispatchCommand(DELETE_CHARACTER_COMMAND, true); }, From e3179741419fa14524cc59997ad24c75d23c5231 Mon Sep 17 00:00:00 2001 From: Wonhee Lee Date: Wed, 13 Nov 2024 00:30:14 +0900 Subject: [PATCH 6/7] fix: add missed prevent default call before propagate --- packages/lexical-rich-text/src/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/lexical-rich-text/src/index.ts b/packages/lexical-rich-text/src/index.ts index cd4ef0f03fc..454f15fb164 100644 --- a/packages/lexical-rich-text/src/index.ts +++ b/packages/lexical-rich-text/src/index.ts @@ -871,6 +871,7 @@ export function registerRichText(editor: LexicalEditor): () => void { ) { const element = $getNearestBlockElementAncestorOrThrow(anchorNode); if (element.getIndent() > 0) { + event.preventDefault(); return editor.dispatchCommand(OUTDENT_CONTENT_COMMAND, undefined); } } From 47db3bd77e3901fb5eaf524b464e3cf6d3719718 Mon Sep 17 00:00:00 2001 From: wnhlee <2wheeh@gmail.com> Date: Wed, 13 Nov 2024 02:13:17 +0900 Subject: [PATCH 7/7] chore: consistent order Co-authored-by: Bob Ippolito --- packages/lexical-rich-text/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/lexical-rich-text/src/index.ts b/packages/lexical-rich-text/src/index.ts index 454f15fb164..cec5da17fa7 100644 --- a/packages/lexical-rich-text/src/index.ts +++ b/packages/lexical-rich-text/src/index.ts @@ -878,7 +878,7 @@ export function registerRichText(editor: LexicalEditor): () => void { // Exception handling for iOS native behavior instead of Lexical's behavior when using Korean on iOS devices. // more details - https://github.com/facebook/lexical/issues/5841 - if (navigator.language === 'ko-KR' && IS_IOS) { + if (IS_IOS && navigator.language === 'ko-KR') { return false; } event.preventDefault();