1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-03 13:57:25 +02:00

update insertText logic when selection is not collapsed (#4804)

* update insertText logic when selection is not collapsed

* add changeset

* fix bug when end of range is void

Co-authored-by: zhangpengcheng15 <zhangpengcheng15@jd.com>
This commit is contained in:
V_Lute
2022-01-29 00:33:57 +08:00
committed by GitHub
parent 01dc0c57b2
commit 03861afc62
2 changed files with 7 additions and 3 deletions

View File

@@ -0,0 +1,5 @@
---
'slate': patch
---
update insertText logic when selection is not collapsed

View File

@@ -484,12 +484,11 @@ export const TextTransforms: TextTransforms = {
at = at.anchor
} else {
const end = Range.end(at)
if (!voids && Editor.void(editor, { at: end })) {
return
}
const pointRef = Editor.pointRef(editor, end)
const start = Range.start(at)
const pointRef = Editor.pointRef(editor, start)
Transforms.delete(editor, { at, voids })
at = pointRef.unref()!
Transforms.setSelection(editor, { anchor: at, focus: at })