From f84098554a3d50ec02255603bb0a145b3aa0c6b2 Mon Sep 17 00:00:00 2001
From: Clemens <cle1000.cb@gmail.com>
Date: Wed, 13 Jul 2016 18:16:31 +0200
Subject: added code editor and file upload

---
 web/src/js/components/common/CodeEditor.jsx | 41 +++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100644 web/src/js/components/common/CodeEditor.jsx

(limited to 'web/src/js/components/common/CodeEditor.jsx')

diff --git a/web/src/js/components/common/CodeEditor.jsx b/web/src/js/components/common/CodeEditor.jsx
new file mode 100644
index 00000000..d7e6aabb
--- /dev/null
+++ b/web/src/js/components/common/CodeEditor.jsx
@@ -0,0 +1,41 @@
+import React, { Component, PropTypes } from 'react'
+import { render } from 'react-dom';
+import brace from 'brace';
+import AceEditor from 'react-ace';
+import Button from './Button'
+
+
+import 'brace/mode/javascript';
+import 'brace/mode/json';
+import 'brace/theme/monokai';
+
+
+
+
+export default class CodeEditor extends Component{
+    constructor( props ) {
+        super(props)
+        this.state = {value: this.props.value}
+    }
+
+    onChange(newValue) {
+        this.setState({value: newValue})
+    }
+
+    render() {
+        return (
+            <div onKeyDown={e => e.stopPropagation()}>
+                <AceEditor
+                    onChange={e => this.onChange(e)}
+                    mode="javascript"
+                    theme="monokai"
+                    value={this.state.value}
+                    width="100%"
+                    name="codeEditor"
+                    editorProps={{$blockScrolling: Infinity}}
+                />
+                <Button onClick={(e) => this.props.onSave(this.state.value)} text="Update"/>
+            </div>
+        )
+    }
+}
-- 
cgit v1.2.3

