Skip to content

Commit

Permalink
Merge branch 'master' into coveralls
Browse files Browse the repository at this point in the history
  • Loading branch information
zhujinxuan committed Jul 29, 2018
2 parents 757c23b + 638d3e8 commit e4b8f57
Show file tree
Hide file tree
Showing 176 changed files with 7,489 additions and 5,500 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.md
42 changes: 42 additions & 0 deletions benchmark/slate/changes/add-mark.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/** @jsx h */
/* eslint-disable react/jsx-key */

const h = require('../../helpers/h')

module.exports.default = function(change) {
change
.addMark('bold')
.move(5)
.addMark('bold')
.move(5)
.addMark('bold')
.move(5)
.addMark('bold')
.move(5)
.addMark('bold')
}

const value = (
<value>
<document>
{Array.from(Array(10)).map((v, i) => (
<quote>
<paragraph>
<paragraph>
This is editable {i == 0 ? <anchor /> : ''}rich{i == 0 ? (
<focus />
) : (
''
)}{' '}
text, <i>much</i> better than a textarea! For reals.
</paragraph>
</paragraph>
</quote>
))}
</document>
</value>
)

module.exports.input = function() {
return value.change()
}
7 changes: 6 additions & 1 deletion benchmark/slate/changes/delete-backward.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
const h = require('../../helpers/h')

module.exports.default = function(change) {
change.deleteBackward()
change
.deleteBackward()
.deleteBackward()
.deleteBackward()
.deleteBackward()
.deleteBackward()
}

const value = (
Expand Down
9 changes: 7 additions & 2 deletions benchmark/slate/changes/delete-forward.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
const h = require('../../helpers/h')

module.exports.default = function(change) {
change.deleteForward()
change
.deleteForward()
.deleteForward()
.deleteForward()
.deleteForward()
.deleteForward()
}

const value = (
Expand All @@ -14,9 +19,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>
Expand Down
23 changes: 12 additions & 11 deletions benchmark/slate/changes/insert-node-by-key.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,31 @@

const h = require('../../helpers/h')

module.exports.default = function({ change, block }) {
change.insertNodeByKey(block.key, 0, <paragraph>Hello world</paragraph>)
module.exports.default = function(change) {
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 = (
<value>
<document>
{Array.from(Array(10)).map((v, i) => (
<quote>
<quote key="a">
<paragraph>
<paragraph>
This is editable <b>rich</b> text, <i>much</i> better than a
textarea!
{i == 0 ? <cursor /> : ''}
</paragraph>
This is editable <b>rich</b> text, <i>much</i> better than a
textarea!
{i == 0 ? <cursor /> : ''}
</paragraph>
</quote>
))}
</document>
</value>
)
const block = value.document.getBlocks().last()

module.exports.input = function() {
const change = value.change()
return { change, block }
return value.change()
}
15 changes: 11 additions & 4 deletions benchmark/slate/changes/insert-text-by-key.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand All @@ -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>
Expand Down
13 changes: 11 additions & 2 deletions benchmark/slate/changes/insert-text.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand All @@ -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>
Expand Down
13 changes: 11 additions & 2 deletions benchmark/slate/changes/normalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand All @@ -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>
Expand Down
15 changes: 11 additions & 4 deletions benchmark/slate/changes/remove-node-by-key.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand All @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@

const h = require('../../helpers/h')

module.exports.default = function({ change, keys }) {
for (const key of keys) {
change.insertTextByKey(key, 0, 'a')
}
module.exports.default = function(change) {
change
.setBlocks('quote')
.setBlocks('paragraph')
.setBlocks('aside')
.setBlocks('code')
.setBlocks('heading')
}

const value = (
Expand All @@ -26,12 +29,7 @@ const value = (
</document>
</value>
)
const keys = value.document
.getTexts()
.toArray()
.map(t => t.key)

module.exports.input = function() {
const change = value.change()
return { change, keys }
return value.change()
}
15 changes: 12 additions & 3 deletions benchmark/slate/changes/split-block.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand All @@ -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>
Expand Down
19 changes: 12 additions & 7 deletions benchmark/slate/models/get-ancestors.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,33 @@

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>
))}
</document>
</value>
)
const text = value.document.getLastText()

module.exports.input = function() {
return { value, text }
return value.document
}
10 changes: 7 additions & 3 deletions benchmark/slate/models/get-blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand All @@ -25,5 +29,5 @@ const value = (
)

module.exports.input = function() {
return value
return value.document
}
Loading

0 comments on commit e4b8f57

Please sign in to comment.