mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-20 14:11:35 +02:00
Add test to joinNodeByKey
This commit is contained in:
@@ -0,0 +1,29 @@
|
|||||||
|
|
||||||
|
import assert from 'assert'
|
||||||
|
|
||||||
|
export default function (state) {
|
||||||
|
const { selection } = state
|
||||||
|
|
||||||
|
const range = selection.merge({
|
||||||
|
anchorKey: 'anchor',
|
||||||
|
anchorOffset: 1,
|
||||||
|
focusKey: 'focus',
|
||||||
|
focusOffset: 2
|
||||||
|
})
|
||||||
|
|
||||||
|
const next = state
|
||||||
|
.transform()
|
||||||
|
.moveTo(range)
|
||||||
|
.joinNodeByKey('key2', 'key1')
|
||||||
|
.apply()
|
||||||
|
|
||||||
|
assert.deepEqual(
|
||||||
|
next.selection.toJS(),
|
||||||
|
range.merge({
|
||||||
|
focusKey: 'anchor',
|
||||||
|
focusOffset: 5
|
||||||
|
}).toJS()
|
||||||
|
)
|
||||||
|
|
||||||
|
return next
|
||||||
|
}
|
@@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
nodes:
|
||||||
|
- kind: block
|
||||||
|
key: 'key1'
|
||||||
|
type: paragraph
|
||||||
|
nodes:
|
||||||
|
- kind: text
|
||||||
|
key: 'anchor'
|
||||||
|
text: The
|
||||||
|
- kind: block
|
||||||
|
key: 'key2'
|
||||||
|
type: paragraph
|
||||||
|
nodes:
|
||||||
|
- kind: text
|
||||||
|
key: 'focus'
|
||||||
|
text: text
|
@@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
nodes:
|
||||||
|
- kind: block
|
||||||
|
key: key1
|
||||||
|
type: paragraph
|
||||||
|
nodes:
|
||||||
|
- kind: text
|
||||||
|
text: Thetext
|
@@ -0,0 +1,29 @@
|
|||||||
|
|
||||||
|
import assert from 'assert'
|
||||||
|
|
||||||
|
export default function (state) {
|
||||||
|
const { selection } = state
|
||||||
|
|
||||||
|
const range = selection.merge({
|
||||||
|
anchorKey: 'anchor',
|
||||||
|
anchorOffset: 1,
|
||||||
|
focusKey: 'focus',
|
||||||
|
focusOffset: 2
|
||||||
|
})
|
||||||
|
|
||||||
|
const next = state
|
||||||
|
.transform()
|
||||||
|
.moveTo(range)
|
||||||
|
.joinNodeByKey('focus', 'anchor')
|
||||||
|
.apply()
|
||||||
|
|
||||||
|
assert.deepEqual(
|
||||||
|
next.selection.toJS(),
|
||||||
|
range.merge({
|
||||||
|
focusKey: 'anchor',
|
||||||
|
focusOffset: 5
|
||||||
|
}).toJS()
|
||||||
|
)
|
||||||
|
|
||||||
|
return next
|
||||||
|
}
|
@@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
nodes:
|
||||||
|
- kind: block
|
||||||
|
type: paragraph
|
||||||
|
nodes:
|
||||||
|
- kind: text
|
||||||
|
key: 'anchor'
|
||||||
|
text: one
|
||||||
|
- kind: inline
|
||||||
|
type: link
|
||||||
|
nodes:
|
||||||
|
- kind: text
|
||||||
|
text: two
|
||||||
|
- kind: text
|
||||||
|
key: 'focus'
|
||||||
|
text: three
|
@@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
nodes:
|
||||||
|
- kind: block
|
||||||
|
type: paragraph
|
||||||
|
nodes:
|
||||||
|
- kind: text
|
||||||
|
key: 'anchor'
|
||||||
|
text: onethree
|
||||||
|
- kind: inline
|
||||||
|
type: link
|
||||||
|
nodes:
|
||||||
|
- kind: text
|
||||||
|
text: two
|
Reference in New Issue
Block a user