1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-07-31 12:30:11 +02:00

Fix the cursor jump to an unexpected position after deleting in android (#5251)

* Fix the cursor jump to an unexpected position after deleting in android

* Create unlucky-chairs-promise.md

* Update unlucky-chairs-promise.md
This commit is contained in:
kailunyao
2023-02-19 09:41:03 +08:00
committed by GitHub
parent f2607c2a52
commit 6fa4b954a5
2 changed files with 11 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
---
'slate-react': patch
'slate': patch
---
Fix the cursor jump to an unexpected position after deleting in android

View File

@@ -392,6 +392,11 @@ export function createAndroidInputManager({
if (Range.isExpanded(targetRange) && type.startsWith('delete')) { if (Range.isExpanded(targetRange) && type.startsWith('delete')) {
if (Path.equals(targetRange.anchor.path, targetRange.focus.path)) { if (Path.equals(targetRange.anchor.path, targetRange.focus.path)) {
const [start, end] = Range.edges(targetRange) const [start, end] = Range.edges(targetRange)
const point = { path: targetRange.anchor.path, offset: start.offset }
const range = Editor.range(editor, point, point)
handleUserSelect(range)
return storeDiff(targetRange.anchor.path, { return storeDiff(targetRange.anchor.path, {
text: '', text: '',
end: end.offset, end: end.offset,