mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-20 22:21:20 +02:00
Test undo add/remove mark
This commit is contained in:
18
test/transforms/fixtures/on-history/undo/add-mark/index.js
Normal file
18
test/transforms/fixtures/on-history/undo/add-mark/index.js
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
import assert from 'assert'
|
||||||
|
|
||||||
|
export default function (state) {
|
||||||
|
const { selection } = state
|
||||||
|
|
||||||
|
const next = state
|
||||||
|
.transform()
|
||||||
|
.addMarkByKey('key1', 0, 8, 'marktype')
|
||||||
|
.apply()
|
||||||
|
|
||||||
|
.transform()
|
||||||
|
.undo()
|
||||||
|
.apply()
|
||||||
|
|
||||||
|
assert.deepEqual(next.selection.toJS(), selection.toJS())
|
||||||
|
return next
|
||||||
|
}
|
@@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
nodes:
|
||||||
|
- kind: block
|
||||||
|
type: paragraph
|
||||||
|
nodes:
|
||||||
|
- kind: text
|
||||||
|
key: 'key1'
|
||||||
|
text: The text
|
@@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
nodes:
|
||||||
|
- kind: block
|
||||||
|
type: paragraph
|
||||||
|
nodes:
|
||||||
|
- kind: text
|
||||||
|
key: 'key1'
|
||||||
|
text: The text
|
@@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
import assert from 'assert'
|
||||||
|
|
||||||
|
export default function (state) {
|
||||||
|
const { selection } = state
|
||||||
|
|
||||||
|
const next = state
|
||||||
|
.transform()
|
||||||
|
.removeMarkByKey('key1', 0, 8, 'mark')
|
||||||
|
.apply()
|
||||||
|
|
||||||
|
.transform()
|
||||||
|
.undo()
|
||||||
|
.apply()
|
||||||
|
|
||||||
|
assert.deepEqual(next.selection.toJS(), selection.toJS())
|
||||||
|
return next
|
||||||
|
}
|
@@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
nodes:
|
||||||
|
- kind: block
|
||||||
|
type: paragraph
|
||||||
|
nodes:
|
||||||
|
- kind: text
|
||||||
|
key: 'key1'
|
||||||
|
ranges:
|
||||||
|
- text: The text
|
||||||
|
marks:
|
||||||
|
- type: 'mark'
|
@@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
nodes:
|
||||||
|
- kind: block
|
||||||
|
type: paragraph
|
||||||
|
nodes:
|
||||||
|
- kind: text
|
||||||
|
key: 'key1'
|
||||||
|
ranges:
|
||||||
|
- text: The text
|
||||||
|
marks:
|
||||||
|
- type: 'mark'
|
Reference in New Issue
Block a user