, {}> {
+ private editorRef: ReactCodeMirror.ReactCodeMirror;
+
+ componentDidMount() {
+ this.editorRef.focus();
+ this.editorRef.getCodeMirror();
+ }
+
+ render() {
+ const options = {
+ lineNumbers: true,
+ readOnly: false,
+ mode: "markdown"
+ };
+ const onChange = (value: any) => console.log(value);
+ const onFocusChange = (focused: boolean) => console.log(focused);
+ const onScroll = (scrollInfo: CodeMirror.ScrollInfo) => console.log(scrollInfo.top);
+ const codeMirrorInstance = CodeMirror(document.body);
+
+ return
+ this.editorRef = r}
+ value="foo bar" />
+
;
+ }
+}
diff --git a/react-codemirror/react-codemirror.d.ts b/react-codemirror/react-codemirror.d.ts
new file mode 100644
index 0000000000..12311a2665
--- /dev/null
+++ b/react-codemirror/react-codemirror.d.ts
@@ -0,0 +1,35 @@
+// Type definitions for React Codemirror v0.2.6
+// Project: https://github.com/JedWatson/react-codemirror
+// Definitions by: Vicky Lai
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+
+///
+///
+
+declare namespace ReactCodeMirror {
+ interface ReactCodeMirrorProps extends __React.Props {
+ onChange?: (newValue: string) => any; // called when a change is made
+ onFocusChange?: (focused: boolean) => any; // called when the editor is focused or loses focus
+ onScroll?: (scrollInfo: CodeMirror.ScrollInfo) => any; // called when the editor is scrolled
+ options?: CodeMirror.EditorConfiguration; // options passed to the CodeMirror instance
+ path?: string; // the identifying name for the textarea
+ value?: string; // the editor value
+ className?: string; // CSS className for the outer element
+ codeMirrorInstance?: CodeMirror.Editor; // the CodeMirror instance
+ }
+
+ interface ReactCodeMirror extends __React.Component {
+ /** Focuses the CodeMirror instance. */
+ focus(): void;
+
+ /** Returns the CodeMirror instance, if available. */
+ getCodeMirror(): CodeMirror.Editor;
+ }
+
+ interface ReactCodeMirrorClass extends __React.ComponentClass { }
+}
+
+declare module "react-codemirror" {
+ const RCM: ReactCodeMirror.ReactCodeMirrorClass;
+ export = RCM;
+}