DefinitelyTyped/types/slate-react/slate-react-tests.tsx
2018-06-25 11:46:26 -06:00

29 lines
634 B
TypeScript

import { Editor, Plugin, EditorProps } from "slate-react";
import { Slate } from "slate";
import * as React from "react";
class MyPlugin implements Plugin {
onChange(change: Slate.Change): void {
change.blur();
}
}
const myPlugin = new MyPlugin();
interface MyEditorState {
value: Slate.Value;
}
class MyEditor extends React.Component<EditorProps, MyEditorState> {
constructor(props: EditorProps) {
super(props);
this.state = {
value: Slate.Value.create()
};
}
render() {
return <Editor value={this.state.value} onChange={myPlugin.onChange} />;
}
}