1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-02-22 16:17:17 +01:00
slate/examples/embeds/index.js
Ian Storm Taylor ace9f47930 change slate to be a monorepo using lerna (#1106)
* init lerna, move files into ./packages

* move test files into ./packages

* more moving around

* fill out package.json files

* fixing imports

* more fixing of imports, and horribleness

* convert examples, fix linting errors

* add documentation

* update docs

* get tests passing

* update travis.yml

* update travis.yml

* update travis.yml

* update test script

* update travis.yml

* update scripts

* try simplifying travis.yml

* ocd stuff

* remove slate-core-test-helpers package

* add package readmes

* update reference docs structure

* refactor slate-simulator into its own package

* add docs for new packages

* update docs

* separate benchmarks into packages, and refactor them
2017-09-11 18:11:45 -07:00

74 lines
942 B
JavaScript

import { Editor } from 'slate-react'
import { State } from 'slate'
import React from 'react'
import Video from './video'
import initialState from './state.json'
/**
* Define a schema.
*
* @type {Object}
*/
const schema = {
nodes: {
video: Video
}
}
/**
* The images example.
*
* @type {Component}
*/
class Embeds extends React.Component {
/**
* Deserialize the raw initial state.
*
* @type {Object}
*/
state = {
state: State.fromJSON(initialState)
}
/**
* On change.
*
* @param {Change} change
*/
onChange = ({ state }) => {
this.setState({ state })
}
/**
* Render the app.
*
* @return {Element} element
*/
render() {
return (
<div className="editor">
<Editor
schema={schema}
state={this.state.state}
onChange={this.onChange}
/>
</div>
)
}
}
/**
* Export.
*/
export default Embeds