mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-29 01:50:06 +02:00
Test undo setSelection
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
|
||||
import assert from 'assert'
|
||||
|
||||
export default function (state) {
|
||||
const { selection, document } = state
|
||||
const dest = document.getDescendant('key2')
|
||||
|
||||
let next = state
|
||||
.transform()
|
||||
// Make a dummy change to the doc, so that the selection operation can be undone
|
||||
.setNodeByKey(document.nodes.first().key, { data: { any: 'thing' } })
|
||||
.setSelectionOperation(selection.moveToRangeOf(dest))
|
||||
.apply()
|
||||
|
||||
.transform()
|
||||
.undo()
|
||||
.apply()
|
||||
|
||||
assert.deepEqual(next.selection.toJS(), selection.toJS())
|
||||
return next
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
|
||||
nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
key: 'key1'
|
||||
text: The
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
key: 'key2'
|
||||
text: text
|
@@ -0,0 +1,14 @@
|
||||
|
||||
nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
key: 'key1'
|
||||
text: The
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
key: 'key2'
|
||||
text: text
|
Reference in New Issue
Block a user