1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-27 09:04:31 +02:00

Add benchmark for text insertion

This commit is contained in:
Soreine
2016-10-25 10:49:45 +02:00
parent f1a5d6f3b4
commit 400d49ccb3
2 changed files with 55 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
module.exports = {
setup(state) {
// Move cursor
return state.transform()
.collapseToStartOf({ key: '_cursor_' })
.moveForward(10) // Move inside the text
.apply()
},
run(state) {
return state.transform().insertText('a').apply()
}
}

View File

@@ -0,0 +1,41 @@
nodes:
- kind: block
type: paragraph
nodes:
- kind: text
ranges:
- text: 'This is editable '
- text: 'rich'
marks:
- type: bold
- text: ' text, '
- text: 'much'
marks:
- type: italic
- text: ' better than a '
- text: '<textarea>'
marks:
- type: code
- text: '!'
- kind: block
key: _cursor_
type: paragraph
nodes:
- kind: text
ranges:
- text: 'Since it''s rich text, you can do things like turn a selection of text '
- text: 'bold'
marks:
- type: bold
- text: ', or add a semantically rendered block quote in the middle of the page,
like this:'
- kind: block
type: block-quote
nodes:
- kind: text
text: 'A wise quote.'
- kind: block
type: paragraph
nodes:
- kind: text
text: 'Try it out for yourself!'