1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-18 13:11:17 +02:00

Add test.js for insertTExtByKey

This commit is contained in:
Samy Pessé
2016-10-26 12:19:57 +02:00
parent 36d6d8eb3c
commit 8c9cea2aaa

28
test.js
View File

@@ -27,30 +27,11 @@ const state = Raw.deserialize({
kind: 'block', kind: 'block',
type: 'paragraph', type: 'paragraph',
key: 'container', key: 'container',
nodes: [
{
key: 'in1',
kind: 'inline',
type: 'link',
nodes: [ nodes: [
{ {
key: 'sometext', key: 'sometext',
kind: 'text', kind: 'text',
text: 'Hello' text: 'Hello'
},
{
key: 'in2',
kind: 'inline',
type: 'image',
isVoid: true,
nodes: [
{
kind: 'text',
text: ' '
}
]
}
]
} }
] ]
} }
@@ -60,7 +41,14 @@ const state = Raw.deserialize({
print(state) print(state)
const newState = state.transform() const newState = state.transform()
.moveNodeByKey('in2', 'container') .moveTo({
anchorKey: 'sometext',
focusKey: 'sometext',
anchorOffset: 3,
focusOffset: 3
})
.insertTextByKey('sometext', 1, 'X')
.apply() .apply()
console.log(newState.selection.toJS())
print(newState) print(newState)