1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-01-17 21:49:20 +01:00

fix: Path.previous() dose not working when path is null (#5029)

* fix: `Path.previous()` dose not working when path is `null`

* feat: changeset add
This commit is contained in:
Taro Shono 2022-07-04 19:05:25 +09:00 committed by GitHub
parent 588a808b2f
commit 736662f808
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 8 deletions

View File

@ -0,0 +1,5 @@
---
'slate': patch
---
fix: `Path.previous()` dose not working when path is `null`

View File

@ -451,16 +451,18 @@ export const TextTransforms: TextTransforms = {
if (!options.at) {
let path
if (ends.length > 0) {
path = Path.previous(endRef.current!)
} else if (middles.length > 0) {
path = Path.previous(middleRef.current!)
} else {
path = Path.previous(startRef.current!)
if (ends.length > 0 && endRef.current) {
path = Path.previous(endRef.current)
} else if (middles.length > 0 && middleRef.current) {
path = Path.previous(middleRef.current)
} else if (startRef.current) {
path = Path.previous(startRef.current)
}
const end = Editor.end(editor, path)
Transforms.select(editor, end)
if (path) {
const end = Editor.end(editor, path)
Transforms.select(editor, end)
}
}
startRef.unref()