mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-02-01 05:16:10 +01:00
update benchmarks
This commit is contained in:
parent
014e37b319
commit
05b8b8ce7e
@ -4,7 +4,16 @@
|
||||
const h = require('../../helpers/h')
|
||||
|
||||
module.exports.default = function(change) {
|
||||
change.addMark('bold')
|
||||
change
|
||||
.addMark('bold')
|
||||
.move(5)
|
||||
.addMark('bold')
|
||||
.move(5)
|
||||
.addMark('bold')
|
||||
.move(5)
|
||||
.addMark('bold')
|
||||
.move(5)
|
||||
.addMark('bold')
|
||||
}
|
||||
|
||||
const value = (
|
||||
@ -19,7 +28,7 @@ const value = (
|
||||
) : (
|
||||
''
|
||||
)}{' '}
|
||||
text, <i>much</i> better than a textarea!
|
||||
text, <i>much</i> better than a textarea! For reals.
|
||||
</paragraph>
|
||||
</paragraph>
|
||||
</quote>
|
||||
|
@ -4,7 +4,12 @@
|
||||
const h = require('../../helpers/h')
|
||||
|
||||
module.exports.default = function(change) {
|
||||
change.deleteBackward()
|
||||
change
|
||||
.deleteBackward()
|
||||
.deleteBackward()
|
||||
.deleteBackward()
|
||||
.deleteBackward()
|
||||
.deleteBackward()
|
||||
}
|
||||
|
||||
const value = (
|
||||
|
@ -4,7 +4,12 @@
|
||||
const h = require('../../helpers/h')
|
||||
|
||||
module.exports.default = function(change) {
|
||||
change.deleteForward()
|
||||
change
|
||||
.deleteForward()
|
||||
.deleteForward()
|
||||
.deleteForward()
|
||||
.deleteForward()
|
||||
.deleteForward()
|
||||
}
|
||||
|
||||
const value = (
|
||||
|
@ -4,7 +4,12 @@
|
||||
const h = require('../../helpers/h')
|
||||
|
||||
module.exports.default = function(change) {
|
||||
change.insertNodeByKey('a', 0, <paragraph>Hello world</paragraph>)
|
||||
change
|
||||
.insertNodeByKey('a', 0, <paragraph>Hello world</paragraph>)
|
||||
.insertNodeByKey('a', 1, <paragraph>Hello world</paragraph>)
|
||||
.insertNodeByKey('a', 2, <paragraph>Hello world</paragraph>)
|
||||
.insertNodeByKey('a', 3, <paragraph>Hello world</paragraph>)
|
||||
.insertNodeByKey('a', 4, <paragraph>Hello world</paragraph>)
|
||||
}
|
||||
|
||||
const value = (
|
||||
|
@ -1,37 +0,0 @@
|
||||
/** @jsx h */
|
||||
/* eslint-disable react/jsx-key */
|
||||
|
||||
const h = require('../../helpers/h')
|
||||
|
||||
module.exports.default = function({ change, keys }) {
|
||||
for (const key of keys) {
|
||||
change.insertTextByKey(key, 0, 'a')
|
||||
}
|
||||
}
|
||||
|
||||
const value = (
|
||||
<value>
|
||||
<document>
|
||||
{Array.from(Array(10)).map((v, i) => (
|
||||
<quote>
|
||||
<paragraph>
|
||||
<paragraph>
|
||||
This is editable <b>rich</b> text, <i>much</i> better than a
|
||||
textarea!
|
||||
{i == 0 ? <cursor /> : ''}
|
||||
</paragraph>
|
||||
</paragraph>
|
||||
</quote>
|
||||
))}
|
||||
</document>
|
||||
</value>
|
||||
)
|
||||
const keys = value.document
|
||||
.getTexts()
|
||||
.toArray()
|
||||
.map(t => t.key)
|
||||
|
||||
module.exports.input = function() {
|
||||
const change = value.change()
|
||||
return { change, keys }
|
||||
}
|
@ -4,7 +4,12 @@
|
||||
const h = require('../../helpers/h')
|
||||
|
||||
module.exports.default = function({ change, text }) {
|
||||
change.insertTextByKey(text.key, 0, 'a')
|
||||
change
|
||||
.insertTextByKey('T1', 0, 'one')
|
||||
.insertTextByKey('T2', 5, 'two')
|
||||
.insertTextByKey('T3', 10, 'three')
|
||||
.insertTextByKey('T4', 15, 'four')
|
||||
.insertTextByKey('T5', 20, 'five')
|
||||
}
|
||||
|
||||
const value = (
|
||||
@ -14,9 +19,11 @@ const value = (
|
||||
<quote>
|
||||
<paragraph>
|
||||
<paragraph>
|
||||
This is editable <b>rich</b> text, <i>much</i> better than a
|
||||
textarea!
|
||||
{i == 0 ? <cursor /> : ''}
|
||||
<text key={`T${i}`}>
|
||||
This is editable <b>rich</b> text, <i>much</i> better than a
|
||||
textarea!
|
||||
{i == 0 ? <cursor /> : ''}
|
||||
</text>
|
||||
</paragraph>
|
||||
</paragraph>
|
||||
</quote>
|
||||
|
@ -4,7 +4,16 @@
|
||||
const h = require('../../helpers/h')
|
||||
|
||||
module.exports.default = function(change) {
|
||||
change.insertText('a')
|
||||
change
|
||||
.insertText('one')
|
||||
.move(5)
|
||||
.insertText('two')
|
||||
.move(5)
|
||||
.insertText('three')
|
||||
.move(5)
|
||||
.insertText('four')
|
||||
.move(5)
|
||||
.insertText('five')
|
||||
}
|
||||
|
||||
const value = (
|
||||
@ -14,9 +23,9 @@ const value = (
|
||||
<quote>
|
||||
<paragraph>
|
||||
<paragraph>
|
||||
{i == 0 ? <cursor /> : ''}
|
||||
This is editable <b>rich</b> text, <i>much</i> better than a
|
||||
textarea!
|
||||
{i == 0 ? <cursor /> : ''}
|
||||
</paragraph>
|
||||
</paragraph>
|
||||
</quote>
|
||||
|
@ -4,7 +4,16 @@
|
||||
const h = require('../../helpers/h')
|
||||
|
||||
module.exports.default = function(change) {
|
||||
change.normalize()
|
||||
change
|
||||
.normalize()
|
||||
.move(5)
|
||||
.normalize()
|
||||
.move(5)
|
||||
.normalize()
|
||||
.move(5)
|
||||
.normalize()
|
||||
.move(5)
|
||||
.normalize()
|
||||
}
|
||||
|
||||
const value = (
|
||||
@ -14,9 +23,9 @@ const value = (
|
||||
<quote>
|
||||
<paragraph>
|
||||
<paragraph>
|
||||
{i == 0 ? <cursor /> : ''}
|
||||
This is editable <b>rich</b> text, <i>much</i> better than a
|
||||
textarea!
|
||||
{i == 0 ? <cursor /> : ''}
|
||||
</paragraph>
|
||||
</paragraph>
|
||||
</quote>
|
||||
|
@ -4,7 +4,12 @@
|
||||
const h = require('../../helpers/h')
|
||||
|
||||
module.exports.default = function({ change, text }) {
|
||||
change.removeNodeByKey(text.key)
|
||||
change
|
||||
.removeNodeByKey('T1')
|
||||
.removeNodeByKey('T2')
|
||||
.removeNodeByKey('T3')
|
||||
.removeNodeByKey('T4')
|
||||
.removeNodeByKey('T5')
|
||||
}
|
||||
|
||||
const value = (
|
||||
@ -14,9 +19,11 @@ const value = (
|
||||
<quote>
|
||||
<paragraph>
|
||||
<paragraph>
|
||||
This is editable <b>rich</b> text, <i>much</i> better than a
|
||||
textarea!
|
||||
{i == 0 ? <cursor /> : ''}
|
||||
<text key={`T${i}`}>
|
||||
{i == 0 ? <cursor /> : ''}
|
||||
This is editable <b>rich</b> text, <i>much</i> better than a
|
||||
textarea!
|
||||
</text>
|
||||
</paragraph>
|
||||
</paragraph>
|
||||
</quote>
|
||||
|
@ -4,7 +4,12 @@
|
||||
const h = require('../../helpers/h')
|
||||
|
||||
module.exports.default = function(change) {
|
||||
change.setBlocks('quote')
|
||||
change
|
||||
.setBlocks('quote')
|
||||
.setBlocks('paragraph')
|
||||
.setBlocks('aside')
|
||||
.setBlocks('code')
|
||||
.setBlocks('heading')
|
||||
}
|
||||
|
||||
const value = (
|
||||
|
@ -4,7 +4,16 @@
|
||||
const h = require('../../helpers/h')
|
||||
|
||||
module.exports.default = function(change) {
|
||||
change.splitBlock()
|
||||
change
|
||||
.splitBlock()
|
||||
.move(5)
|
||||
.splitBlock()
|
||||
.move(5)
|
||||
.splitBlock()
|
||||
.move(5)
|
||||
.splitBlock()
|
||||
.move(5)
|
||||
.splitBlock()
|
||||
}
|
||||
|
||||
const value = (
|
||||
@ -14,9 +23,9 @@ const value = (
|
||||
<quote>
|
||||
<paragraph>
|
||||
<paragraph>
|
||||
This is editable <b>rich</b> text, <i>much</i> better than a
|
||||
textarea!
|
||||
This
|
||||
{i == 0 ? <cursor /> : ''}
|
||||
is editable <b>rich</b> text, <i>much</i> better than a textarea!
|
||||
</paragraph>
|
||||
</paragraph>
|
||||
</quote>
|
||||
|
@ -3,19 +3,25 @@
|
||||
|
||||
const h = require('../../helpers/h')
|
||||
|
||||
module.exports.default = function({ value, text }) {
|
||||
value.document.getAncestors(text.key)
|
||||
module.exports.default = function(document) {
|
||||
document.getAncestors('T1')
|
||||
document.getAncestors('T2')
|
||||
document.getAncestors('T3')
|
||||
document.getAncestors('T4')
|
||||
document.getAncestors('T5')
|
||||
}
|
||||
|
||||
const value = (
|
||||
<value>
|
||||
<document>
|
||||
{Array.from(Array(10)).map(() => (
|
||||
{Array.from(Array(10)).map((_, i) => (
|
||||
<quote>
|
||||
<paragraph>
|
||||
<paragraph>
|
||||
This is editable <b>rich</b> text, <i>much</i> better than a
|
||||
textarea!
|
||||
<text key={`T${i}`}>
|
||||
This is editable <b>rich</b> text, <i>much</i> better than a
|
||||
textarea!
|
||||
</text>
|
||||
</paragraph>
|
||||
</paragraph>
|
||||
</quote>
|
||||
@ -23,8 +29,7 @@ const value = (
|
||||
</document>
|
||||
</value>
|
||||
)
|
||||
const text = value.document.getLastText()
|
||||
|
||||
module.exports.input = function() {
|
||||
return { value, text }
|
||||
return value.document
|
||||
}
|
||||
|
@ -3,8 +3,12 @@
|
||||
|
||||
const h = require('../../helpers/h')
|
||||
|
||||
module.exports.default = function(value) {
|
||||
value.document.getBlocks()
|
||||
module.exports.default = function(document) {
|
||||
document.getBlocks()
|
||||
document.getBlocks()
|
||||
document.getBlocks()
|
||||
document.getBlocks()
|
||||
document.getBlocks()
|
||||
}
|
||||
|
||||
const value = (
|
||||
@ -25,5 +29,5 @@ const value = (
|
||||
)
|
||||
|
||||
module.exports.input = function() {
|
||||
return value
|
||||
return value.document
|
||||
}
|
||||
|
@ -3,19 +3,25 @@
|
||||
|
||||
const h = require('../../helpers/h')
|
||||
|
||||
module.exports.default = function({ value, first, last }) {
|
||||
value.document.getCommonAncestor(first.key, last.key)
|
||||
module.exports.default = function(document) {
|
||||
document.getCommonAncestor('T1', 'T2')
|
||||
document.getCommonAncestor('T2', 'T3')
|
||||
document.getCommonAncestor('T3', 'T4')
|
||||
document.getCommonAncestor('T4', 'T5')
|
||||
document.getCommonAncestor('T5', 'T6')
|
||||
}
|
||||
|
||||
const value = (
|
||||
<value>
|
||||
<document>
|
||||
{Array.from(Array(10)).map(() => (
|
||||
{Array.from(Array(10)).map((_, i) => (
|
||||
<quote>
|
||||
<paragraph>
|
||||
<paragraph>
|
||||
This is editable <b>rich</b> text, <i>much</i> better than a
|
||||
textarea!
|
||||
<text key={`T${i}`}>
|
||||
This is editable <b>rich</b> text, <i>much</i> better than a
|
||||
textarea!
|
||||
</text>
|
||||
</paragraph>
|
||||
</paragraph>
|
||||
</quote>
|
||||
@ -24,9 +30,6 @@ const value = (
|
||||
</value>
|
||||
)
|
||||
|
||||
const first = value.document.getFirstText()
|
||||
const last = value.document.getLastText()
|
||||
|
||||
module.exports.input = function() {
|
||||
return { value, first, last }
|
||||
return value.document
|
||||
}
|
||||
|
@ -3,19 +3,25 @@
|
||||
|
||||
const h = require('../../helpers/h')
|
||||
|
||||
module.exports.default = function({ value, text }) {
|
||||
value.document.getDescendant(text.key)
|
||||
module.exports.default = function(document) {
|
||||
document.getDescendant('T1')
|
||||
document.getDescendant('T2')
|
||||
document.getDescendant('T3')
|
||||
document.getDescendant('T4')
|
||||
document.getDescendant('T5')
|
||||
}
|
||||
|
||||
const value = (
|
||||
<value>
|
||||
<document>
|
||||
{Array.from(Array(10)).map(() => (
|
||||
{Array.from(Array(10)).map((_, i) => (
|
||||
<quote>
|
||||
<paragraph>
|
||||
<paragraph>
|
||||
This is editable <b>rich</b> text, <i>much</i> better than a
|
||||
textarea!
|
||||
<text key={`T${i}`}>
|
||||
This is editable <b>rich</b> text, <i>much</i> better than a
|
||||
textarea!
|
||||
</text>
|
||||
</paragraph>
|
||||
</paragraph>
|
||||
</quote>
|
||||
@ -23,8 +29,7 @@ const value = (
|
||||
</document>
|
||||
</value>
|
||||
)
|
||||
const text = value.document.getLastText()
|
||||
|
||||
module.exports.input = function() {
|
||||
return { value, text }
|
||||
return value.document
|
||||
}
|
||||
|
@ -3,19 +3,25 @@
|
||||
|
||||
const h = require('../../helpers/h')
|
||||
|
||||
module.exports.default = function({ value, text }) {
|
||||
value.document.getFurthestAncestor(text.key)
|
||||
module.exports.default = function(document) {
|
||||
document.getFurthestAncestor('T1')
|
||||
document.getFurthestAncestor('T2')
|
||||
document.getFurthestAncestor('T3')
|
||||
document.getFurthestAncestor('T4')
|
||||
document.getFurthestAncestor('T5')
|
||||
}
|
||||
|
||||
const value = (
|
||||
<value>
|
||||
<document>
|
||||
{Array.from(Array(10)).map(() => (
|
||||
{Array.from(Array(10)).map((_, i) => (
|
||||
<quote>
|
||||
<paragraph>
|
||||
<paragraph>
|
||||
This is editable <b>rich</b> text, <i>much</i> better than a
|
||||
textarea!
|
||||
<text key={`T${i}`}>
|
||||
This is editable <b>rich</b> text, <i>much</i> better than a
|
||||
textarea!
|
||||
</text>
|
||||
</paragraph>
|
||||
</paragraph>
|
||||
</quote>
|
||||
@ -23,8 +29,7 @@ const value = (
|
||||
</document>
|
||||
</value>
|
||||
)
|
||||
const text = value.document.getLastText()
|
||||
|
||||
module.exports.input = function() {
|
||||
return { value, text }
|
||||
return value.document
|
||||
}
|
||||
|
@ -3,19 +3,25 @@
|
||||
|
||||
const h = require('../../helpers/h')
|
||||
|
||||
module.exports.default = function({ value, text }) {
|
||||
value.document.getParent(text.key)
|
||||
module.exports.default = function(document) {
|
||||
document.getParent('T1')
|
||||
document.getParent('T2')
|
||||
document.getParent('T3')
|
||||
document.getParent('T4')
|
||||
document.getParent('T5')
|
||||
}
|
||||
|
||||
const value = (
|
||||
<value>
|
||||
<document>
|
||||
{Array.from(Array(10)).map(() => (
|
||||
{Array.from(Array(10)).map((_, i) => (
|
||||
<quote>
|
||||
<paragraph>
|
||||
<paragraph>
|
||||
This is editable <b>rich</b> text, <i>much</i> better than a
|
||||
textarea!
|
||||
<text key={`T${i}`}>
|
||||
This is editable <b>rich</b> text, <i>much</i> better than a
|
||||
textarea!
|
||||
</text>
|
||||
</paragraph>
|
||||
</paragraph>
|
||||
</quote>
|
||||
@ -23,8 +29,7 @@ const value = (
|
||||
</document>
|
||||
</value>
|
||||
)
|
||||
const text = value.document.getLastText()
|
||||
|
||||
module.exports.input = () => {
|
||||
return { value, text }
|
||||
module.exports.input = function() {
|
||||
return value.document
|
||||
}
|
||||
|
@ -3,19 +3,25 @@
|
||||
|
||||
const h = require('../../helpers/h')
|
||||
|
||||
module.exports.default = function({ value, text }) {
|
||||
value.document.getPath(text.key)
|
||||
module.exports.default = function(document) {
|
||||
document.getPath('T1')
|
||||
document.getPath('T2')
|
||||
document.getPath('T3')
|
||||
document.getPath('T4')
|
||||
document.getPath('T5')
|
||||
}
|
||||
|
||||
const value = (
|
||||
<value>
|
||||
<document>
|
||||
{Array.from(Array(10)).map(() => (
|
||||
{Array.from(Array(10)).map((_, i) => (
|
||||
<quote>
|
||||
<paragraph>
|
||||
<paragraph>
|
||||
This is editable <b>rich</b> text, <i>much</i> better than a
|
||||
textarea!
|
||||
<text key={`T${i}`}>
|
||||
This is editable <b>rich</b> text, <i>much</i> better than a
|
||||
textarea!
|
||||
</text>
|
||||
</paragraph>
|
||||
</paragraph>
|
||||
</quote>
|
||||
@ -23,8 +29,7 @@ const value = (
|
||||
</document>
|
||||
</value>
|
||||
)
|
||||
const text = value.document.getLastText()
|
||||
|
||||
module.exports.input = () => {
|
||||
return { value, text }
|
||||
module.exports.input = function() {
|
||||
return value.document
|
||||
}
|
||||
|
@ -3,19 +3,25 @@
|
||||
|
||||
const h = require('../../helpers/h')
|
||||
|
||||
module.exports.default = function({ value, text }) {
|
||||
value.document.hasNode(text.key)
|
||||
module.exports.default = function(document) {
|
||||
document.hasNode('T1')
|
||||
document.hasNode('T2')
|
||||
document.hasNode('T3')
|
||||
document.hasNode('T4')
|
||||
document.hasNode('T5')
|
||||
}
|
||||
|
||||
const value = (
|
||||
<value>
|
||||
<document>
|
||||
{Array.from(Array(10)).map(() => (
|
||||
{Array.from(Array(10)).map((_, i) => (
|
||||
<quote>
|
||||
<paragraph>
|
||||
<paragraph>
|
||||
This is editable <b>rich</b> text, <i>much</i> better than a
|
||||
textarea!
|
||||
<text key={`T${i}`}>
|
||||
This is editable <b>rich</b> text, <i>much</i> better than a
|
||||
textarea!
|
||||
</text>
|
||||
</paragraph>
|
||||
</paragraph>
|
||||
</quote>
|
||||
@ -23,8 +29,7 @@ const value = (
|
||||
</document>
|
||||
</value>
|
||||
)
|
||||
const text = value.document.getLastText()
|
||||
|
||||
module.exports.input = function() {
|
||||
return { value, text }
|
||||
return value.document
|
||||
}
|
||||
|
@ -1,34 +0,0 @@
|
||||
/** @jsx h */
|
||||
/* eslint-disable react/jsx-key */
|
||||
|
||||
const h = require('../../helpers/h')
|
||||
|
||||
module.exports.default = function({ value, next }) {
|
||||
value.document.updateNode(next)
|
||||
}
|
||||
|
||||
const value = (
|
||||
<value>
|
||||
<document>
|
||||
{Array.from(Array(10)).map(() => (
|
||||
<quote>
|
||||
<paragraph>
|
||||
<paragraph>
|
||||
This is editable <b>rich</b> text, <i>much</i> better than a
|
||||
textarea!
|
||||
</paragraph>
|
||||
</paragraph>
|
||||
</quote>
|
||||
))}
|
||||
</document>
|
||||
</value>
|
||||
)
|
||||
|
||||
const texts = value.document.getTexts()
|
||||
const { size } = texts
|
||||
const text = texts.get(Math.round(size / 2))
|
||||
const next = text.insertText(0, 'some text')
|
||||
|
||||
module.exports.input = function() {
|
||||
return { value, next }
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user