Skip to content

Commit

Permalink
[lexical-rich-text][lexical-plain-text] workaround for Korean IME iss…
Browse files Browse the repository at this point in the history
…ue on iOS (#6819)

Co-authored-by: kei kim <[email protected]>
Co-authored-by: deadintegral (kei) <[email protected]>
Co-authored-by: Sherry Wong <[email protected]>
Co-authored-by: Bob Ippolito <[email protected]>
  • Loading branch information
5 people authored Nov 13, 2024
1 parent 3acfed5 commit f198ba7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions packages/lexical-plain-text/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
Expand Down
11 changes: 10 additions & 1 deletion packages/lexical-rich-text/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ export function registerRichText(editor: LexicalEditor): () => void {
if (!$isRangeSelection(selection)) {
return false;
}
event.preventDefault();

const {anchor} = selection;
const anchorNode = anchor.getNode();

Expand All @@ -871,9 +871,18 @@ export function registerRichText(editor: LexicalEditor): () => void {
) {
const element = $getNearestBlockElementAncestorOrThrow(anchorNode);
if (element.getIndent() > 0) {
event.preventDefault();
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 (IS_IOS && navigator.language === 'ko-KR') {
return false;
}
event.preventDefault();

return editor.dispatchCommand(DELETE_CHARACTER_COMMAND, true);
},
COMMAND_PRIORITY_EDITOR,
Expand Down

0 comments on commit f198ba7

Please sign in to comment.