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:
committed by
GitHub
parent
220f2d2ce6
commit
834ce3483d
5
.changeset/thick-geckos-kick.md
Normal file
5
.changeset/thick-geckos-kick.md
Normal file
@@ -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'
|
||||
|
||||
@@ -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,
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user