1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-22 15:02:51 +02:00

fix(android): Fix editors mark is not inserted on insert text in android (#4342)

* fix(android): Fix mark is not inputed on insert text in android

* add changeset

* null mark only when mark exist

Co-authored-by: surya darma <budi.surya@kumparan.com>
This commit is contained in:
I Made Budi Surya Darma
2021-08-13 18:55:27 +08:00
committed by GitHub
parent 220f2d2ce6
commit 834ce3483d
2 changed files with 22 additions and 5 deletions

View File

@@ -0,0 +1,5 @@
---
'slate-react': patch
---
Fix editor mark is not inserted on android

View File

@@ -1,5 +1,5 @@
import { ReactEditor } from '../../plugin/react-editor' import { ReactEditor } from '../../plugin/react-editor'
import { Editor, Range, Transforms } from 'slate' import { Editor, Range, Transforms, Text } from 'slate'
import { DOMNode } from '../../utils/dom' import { DOMNode } from '../../utils/dom'
@@ -102,13 +102,25 @@ export class AndroidInputManager {
private insertText = (insertedText: TextInsertion[]) => { private insertText = (insertedText: TextInsertion[]) => {
debug('insertText') debug('insertText')
const { selection } = this.editor const { selection, marks } = this.editor
// Insert the batched text diffs // Insert the batched text diffs
insertedText.forEach(insertion => { insertedText.forEach(insertion => {
Transforms.insertText(this.editor, insertion.text.insertText, { const text = insertion.text.insertText
at: normalizeTextInsertionRange(this.editor, selection, insertion), const at = normalizeTextInsertionRange(this.editor, selection, insertion)
if (marks) {
const node = { text, ...marks }
Transforms.insertNodes(this.editor, node, {
match: Text.isText,
at,
select: true,
}) })
this.editor.marks = null
} else {
Transforms.insertText(this.editor, text, {
at,
})
}
}) })
} }