From e9a46ad29e0376a45051c4a8100c5678784b785c Mon Sep 17 00:00:00 2001 From: Alessio Galdy Date: Tue, 4 Jan 2022 14:10:35 +0100 Subject: [PATCH] Fix editor.insertText never gets called inside plugins on Android (#4753) * Call Editor.insertText instead of Transforms.insertText to allow overriding by plugins * Use Editor.insertText in android-input-manager * changeset --- .changeset/breezy-ears-happen.md | 5 +++++ .../slate-react/src/components/android/android-editable.tsx | 4 +--- .../src/components/android/android-input-manager.ts | 4 +--- packages/slate-react/src/components/editable.tsx | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) create mode 100644 .changeset/breezy-ears-happen.md diff --git a/.changeset/breezy-ears-happen.md b/.changeset/breezy-ears-happen.md new file mode 100644 index 0000000000..4b700de027 --- /dev/null +++ b/.changeset/breezy-ears-happen.md @@ -0,0 +1,5 @@ +--- +'slate-react': patch +--- + +Fix "editor.insertText never gets called inside plugins on android" diff --git a/packages/slate-react/src/components/android/android-editable.tsx b/packages/slate-react/src/components/android/android-editable.tsx index e047632c1e..e98798388e 100644 --- a/packages/slate-react/src/components/android/android-editable.tsx +++ b/packages/slate-react/src/components/android/android-editable.tsx @@ -560,9 +560,7 @@ export const AndroidEditable = (props: EditableProps): JSX.Element => { }) editor.marks = null } else { - Transforms.insertText(editor, text, { - at, - }) + Editor.insertText(editor, text) } }) }, RESOLVE_DELAY) diff --git a/packages/slate-react/src/components/android/android-input-manager.ts b/packages/slate-react/src/components/android/android-input-manager.ts index 8b446d00e9..6527fd5615 100644 --- a/packages/slate-react/src/components/android/android-input-manager.ts +++ b/packages/slate-react/src/components/android/android-input-manager.ts @@ -134,9 +134,7 @@ export class AndroidInputManager { }) this.editor.marks = null } else { - Transforms.insertText(this.editor, text, { - at, - }) + Editor.insertText(this.editor, text) } }) } diff --git a/packages/slate-react/src/components/editable.tsx b/packages/slate-react/src/components/editable.tsx index 7cb059b9bf..12d9ccf551 100644 --- a/packages/slate-react/src/components/editable.tsx +++ b/packages/slate-react/src/components/editable.tsx @@ -793,7 +793,7 @@ export const Editable = (props: EditableProps) => { distance: currentTextNode.text.length, reverse: true, }) - Transforms.insertText(editor, text) + Editor.insertText(editor, text) }) } }