mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-25 08:11:53 +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:
committed by
GitHub
parent
d3f88fb922
commit
bf428df4e2
@@ -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.
|
* Check if a path is after another.
|
||||||
*/
|
*/
|
||||||
|
7
packages/slate/test/interfaces/Path/hasPrevious/root.tsx
Normal file
7
packages/slate/test/interfaces/Path/hasPrevious/root.tsx
Normal 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
|
@@ -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
|
Reference in New Issue
Block a user