Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Aug 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/thick-geckos-kick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'slate-react': patch
---

Fix editor mark is not inserted on android
Original file line number Diff line number Diff line change
@@ -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