-
Notifications
You must be signed in to change notification settings - Fork 14
/
index.js
37 lines (36 loc) · 1018 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { Editor, Mark } from 'slate';
import React, { Component, PropTypes } from 'react';
import { withState, withSidebar, withToolbar, withAutoMarkdown, useBlocks } from '../editor-decorators';
@withState()
@useBlocks()
@withAutoMarkdown()
@withToolbar()
@withSidebar()
export default class SlateEditor extends Component {
static propTypes = {
readOnly: PropTypes.bool,
children: PropTypes.node,
value: PropTypes.object,
onChange: PropTypes.func,
marks: PropTypes.object,
nodes: PropTypes.object,
autoMarkDownKeyDown: PropTypes.func,
plugins: PropTypes.array,
className: PropTypes.string,
}
render = () => {
const { children, value, onChange, readOnly, marks, nodes, plugins, className } = this.props;
return (
<div className={className}>
{children}
<Editor
readOnly={readOnly}
plugins={plugins}
schema={{ marks, nodes }}
state={value}
onChange={onChange}
/>
</div>
);
}
}