mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-28 17:39:57 +02:00
Add tests for collapseToStart/End when selected node is void (#1038)
This commit is contained in:
committed by
Ian Storm Taylor
parent
044ffbf62c
commit
e79ec24f39
@@ -0,0 +1,29 @@
|
||||
|
||||
import assert from 'assert'
|
||||
|
||||
export default function (state) {
|
||||
const { document, selection } = state
|
||||
const texts = document.getTexts()
|
||||
const first = texts.get(0)
|
||||
|
||||
const next = state
|
||||
.transform()
|
||||
.select({
|
||||
anchorKey: first.key,
|
||||
anchorOffset: 0,
|
||||
focusKey: first.key,
|
||||
focusOffset: 1
|
||||
})
|
||||
.collapseToEnd()
|
||||
.apply()
|
||||
|
||||
assert.deepEqual(next.selection.toJS(), {
|
||||
anchorKey: first.key,
|
||||
anchorOffset: 1,
|
||||
focusKey: first.key,
|
||||
focusOffset: 1,
|
||||
isBackward: false,
|
||||
isFocused: false,
|
||||
marks: null,
|
||||
})
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
|
||||
nodes:
|
||||
- kind: block
|
||||
type: image
|
||||
isVoid: true
|
@@ -0,0 +1,29 @@
|
||||
|
||||
import assert from 'assert'
|
||||
|
||||
export default function (state) {
|
||||
const { document, selection } = state
|
||||
const texts = document.getTexts()
|
||||
const first = texts.get(0)
|
||||
|
||||
const next = state
|
||||
.transform()
|
||||
.select({
|
||||
anchorKey: first.key,
|
||||
anchorOffset: 0,
|
||||
focusKey: first.key,
|
||||
focusOffset: 1
|
||||
})
|
||||
.collapseToStart()
|
||||
.apply()
|
||||
|
||||
assert.deepEqual(next.selection.toJS(), {
|
||||
anchorKey: first.key,
|
||||
anchorOffset: 0,
|
||||
focusKey: first.key,
|
||||
focusOffset: 0,
|
||||
isBackward: false,
|
||||
isFocused: false,
|
||||
marks: null,
|
||||
})
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
|
||||
nodes:
|
||||
- kind: block
|
||||
type: image
|
||||
isVoid: true
|
Reference in New Issue
Block a user