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