import { Value } from 'slate' import { Editor } from 'slate-react' import React from 'react' import initialValue from './value.json' /** * Toolbar button component. * * @type {Function} */ const ToolbarButton = props => ( {props.icon} ) /** * The history example. * * @type {Component} */ class History extends React.Component { /** * Deserialize the initial editor value. * * @type {Object} */ state = { value: Value.fromJSON(initialValue) } /** * On change. * * @param {Change} change */ onChange = ({ value }) => { this.setState({ value }) } /** * On redo in history. * */ onClickRedo = (event) => { event.preventDefault() const { value } = this.state const change = value.change().redo() this.onChange(change) } /** * On undo in history. * */ onClickUndo = (event) => { event.preventDefault() const { value } = this.state const change = value.change().undo() this.onChange(change) } /** * Render the editor. * * @return {Component} component */ render() { return (