From f8f9061b8127ef410d476dcc660c8df0633cadad Mon Sep 17 00:00:00 2001 From: surya darma Date: Sat, 19 Jun 2021 19:05:35 +0800 Subject: [PATCH 1/3] fix(android): Fix mark is not inputed on insert text in android --- .../android/android-input-manager.ts | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) 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 87d81d972e..261324b92f 100644 --- a/packages/slate-react/src/components/android/android-input-manager.ts +++ b/packages/slate-react/src/components/android/android-input-manager.ts @@ -1,5 +1,5 @@ import { ReactEditor } from '../../plugin/react-editor' -import { Editor, Range, Transforms } from 'slate' +import { Editor, Range, Transforms, Text } from 'slate' import { DOMNode } from '../../utils/dom' @@ -102,13 +102,25 @@ export class AndroidInputManager { private insertText = (insertedText: TextInsertion[]) => { debug('insertText') - const { selection } = this.editor + const { selection, marks } = this.editor // Insert the batched text diffs insertedText.forEach(insertion => { - Transforms.insertText(this.editor, insertion.text.insertText, { - at: normalizeTextInsertionRange(this.editor, selection, insertion), - }) + const text = insertion.text.insertText + const at = normalizeTextInsertionRange(this.editor, selection, insertion) + if (marks) { + const node = { text, ...marks } + Transforms.insertNodes(this.editor, node, { + match: Text.isText, + at, + select: true, + }) + } else { + Transforms.insertText(this.editor, text, { + at, + }) + } + this.editor.marks = null }) } From c1af13e070e7c590172c450b1bb88cd6eada915c Mon Sep 17 00:00:00 2001 From: imdbsd Date: Sun, 20 Jun 2021 00:02:46 +0800 Subject: [PATCH 2/3] add changeset --- .changeset/thick-geckos-kick.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/thick-geckos-kick.md diff --git a/.changeset/thick-geckos-kick.md b/.changeset/thick-geckos-kick.md new file mode 100644 index 0000000000..369a13a11a --- /dev/null +++ b/.changeset/thick-geckos-kick.md @@ -0,0 +1,5 @@ +--- +'slate-react': patch +--- + +Fix editor mark is not inserted on android From 8e379793ad20503d1206c416dfcd99409baf46a9 Mon Sep 17 00:00:00 2001 From: surya darma Date: Wed, 30 Jun 2021 10:55:45 +0800 Subject: [PATCH 3/3] null mark only when mark exist --- .../slate-react/src/components/android/android-input-manager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 261324b92f..3e4c751dec 100644 --- a/packages/slate-react/src/components/android/android-input-manager.ts +++ b/packages/slate-react/src/components/android/android-input-manager.ts @@ -115,12 +115,12 @@ export class AndroidInputManager { at, select: true, }) + this.editor.marks = null } else { Transforms.insertText(this.editor, text, { at, }) } - this.editor.marks = null }) }