mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-18 21:21:21 +02:00
Add test.js for insertTExtByKey
This commit is contained in:
28
test.js
28
test.js
@@ -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)
|
||||||
|
Reference in New Issue
Block a user