mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-02-22 16:17:17 +01:00
72 lines
923 B
JavaScript
72 lines
923 B
JavaScript
|
|
import { Editor, Raw } from '../..'
|
|
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: Raw.deserialize(initialState, { terse: true })
|
|
};
|
|
|
|
/**
|
|
* On change.
|
|
*
|
|
* @param {State} state
|
|
*/
|
|
|
|
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
|