/* eslint-disable no-console */
import { Editor } from 'slate-react'
import { Value } from 'slate'
import React from 'react'
import faker from 'faker'
/**
* Create a huge JSON document.
*
* @type {Object}
*/
const HEADINGS = 100
const PARAGRAPHS = 8 // Paragraphs per heading
const nodes = []
const json = {
document: { nodes },
}
for (let h = 0; h < HEADINGS; h++) {
nodes.push({
object: 'block',
type: 'heading',
nodes: [{ object: 'text', leaves: [{ text: faker.lorem.sentence() }] }],
})
for (let p = 0; p < PARAGRAPHS; p++) {
nodes.push({
object: 'block',
type: 'paragraph',
nodes: [{ object: 'text', leaves: [{ text: faker.lorem.paragraph() }] }],
})
}
}
/**
* The huge document example.
*
* @type {Component}
*/
class HugeDocument extends React.Component {
/**
* Deserialize the initial editor value.
*
* @type {Object}
*/
state = { value: Value.fromJSON(json, { normalize: false }) }
/**
* Render the editor.
*
* @return {Component} component
*/
render() {
return (
{children}
case 'italic':
return {children}
case 'underlined':
return {children}
default:
return next()
}
}
/**
* On change.
*
* @param {Editor} editor
*/
onChange = ({ value }) => {
this.setState({ value })
}
}
/**
* Export.
*/
export default HugeDocument