Skip to content

Commit

Permalink
fix(android): Fix editors mark is not inserted on insert text in andr…
Browse files Browse the repository at this point in the history
…oid (#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>
  • Loading branch information
imdbsd and surya darma committed Aug 13, 2021
1 parent 220f2d2 commit 834ce34
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/thick-geckos-kick.md
@@ -0,0 +1,5 @@
---
'slate-react': patch
---

Fix editor mark is not inserted on android
@@ -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'

Expand Down Expand Up @@ -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,
})
this.editor.marks = null
} else {
Transforms.insertText(this.editor, text, {
at,
})
}
})
}

Expand Down

0 comments on commit 834ce34

Please sign in to comment.