mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-04-15 10:52:34 +02:00
Android merge Editor.insertText
logic. (#4788)
* fix: Android merge Editor.insertText logic * feat: add changeset
This commit is contained in:
parent
67aa1f1010
commit
a8c08a4e01
5
.changeset/witty-moose-join.md
Normal file
5
.changeset/witty-moose-join.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
'slate-react': patch
|
||||
---
|
||||
|
||||
Android merge `Editor.insertText` logic.
|
@ -542,7 +542,7 @@ export const AndroidEditable = (props: EditableProps): JSX.Element => {
|
||||
|
||||
EDITOR_ON_COMPOSITION_TEXT.set(editor, [])
|
||||
|
||||
const { selection, marks } = editor
|
||||
const { selection } = editor
|
||||
|
||||
insertedText.forEach(insertion => {
|
||||
const text = insertion.text.insertText
|
||||
@ -551,18 +551,8 @@ export const AndroidEditable = (props: EditableProps): JSX.Element => {
|
||||
selection,
|
||||
insertion
|
||||
)
|
||||
if (marks) {
|
||||
const node = { text, ...marks }
|
||||
Transforms.insertNodes(editor, node, {
|
||||
match: Text.isText,
|
||||
at,
|
||||
select: true,
|
||||
})
|
||||
editor.marks = null
|
||||
} else {
|
||||
Transforms.setSelection(editor, at)
|
||||
Editor.insertText(editor, text)
|
||||
}
|
||||
Transforms.setSelection(editor, at)
|
||||
Editor.insertText(editor, text)
|
||||
})
|
||||
}, RESOLVE_DELAY)
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ export class AndroidInputManager {
|
||||
private insertText = (insertedText: TextInsertion[]) => {
|
||||
debug('insertText')
|
||||
|
||||
const { selection, marks } = this.editor
|
||||
const { selection } = this.editor
|
||||
|
||||
// If it is in composing or after `onCompositionend`, set `EDITOR_ON_COMPOSITION_TEXT` and return.
|
||||
// Text will be inserted on compositionend event.
|
||||
@ -125,18 +125,8 @@ export class AndroidInputManager {
|
||||
insertedText.forEach(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.setSelection(this.editor, at)
|
||||
Editor.insertText(this.editor, text)
|
||||
}
|
||||
Transforms.setSelection(this.editor, at)
|
||||
Editor.insertText(this.editor, text)
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user