1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-22 15:02:51 +02:00

Add hasPrevious method to Path (#3963)

* Add hasPrevious method to Path API.

Co-authored-by: Mitchell Donaldson <mitch@nod.money>
This commit is contained in:
Mitchell Donaldson
2020-11-03 08:28:43 +11:00
committed by GitHub
parent d3f88fb922
commit bf428df4e2
3 changed files with 22 additions and 0 deletions

View File

@@ -118,6 +118,14 @@ export const Path = {
)
},
/**
* Check if the path of previous sibling node exists
*/
hasPrevious(path: Path): boolean {
return path[path.length - 1] > 0
},
/**
* Check if a path is after another.
*/

View File

@@ -0,0 +1,7 @@
import { Path } from 'slate'
export const input = [0, 0]
export const test = path => {
return Path.hasPrevious(path)
}
export const output = false

View File

@@ -0,0 +1,7 @@
import { Path } from 'slate'
export const input = [0, 1]
export const test = path => {
return Path.hasPrevious(path)
}
export const output = true