streamline raw editor pasting

This commit is contained in:
Shawn Erquhart 2017-07-10 18:26:07 -04:00
parent 51cd8d30a5
commit fe3d04b722

View File

@ -24,6 +24,13 @@ export default class RawEditor extends React.Component {
this.props.onChange(html);
};
handlePaste = (e, data, state) => {
if (data.text) {
const fragment = SlatePlain.deserialize(data.text).document;
return state.transform().insertFragment(fragment).apply();
}
};
handleToggleMode = () => {
this.props.onMode('visual');
};
@ -43,6 +50,7 @@ export default class RawEditor extends React.Component {
state={this.state.editorState}
onChange={this.handleChange}
onDocumentChange={this.handleDocumentChange}
onPaste={this.handlePaste}
/>
</div>
);