added new btn, changed to codemirror

This commit is contained in:
Clemens 2016-07-15 14:41:30 +02:00
parent 5f3782dd5f
commit 87797d7ac0
7 changed files with 51 additions and 40 deletions

View File

@ -29,7 +29,7 @@
"redux-logger": "^2.6.1", "redux-logger": "^2.6.1",
"redux-thunk": "^2.1.0", "redux-thunk": "^2.1.0",
"shallowequal": "^0.2.2", "shallowequal": "^0.2.2",
"react-ace": "^3.5.0" "react-codemirror" : "^0.2.6"
}, },
"devDependencies": { "devDependencies": {
"babel-core": "^6.7.7", "babel-core": "^6.7.7",

View File

@ -17,3 +17,4 @@ html {
@import (less) "prompt.less"; @import (less) "prompt.less";
@import (less) "eventlog.less"; @import (less) "eventlog.less";
@import (less) "footer.less"; @import (less) "footer.less";
@import (less) "codemirror.less";

View File

@ -0,0 +1,5 @@
.ReactCodeMirror {
border: 1px solid #ccc;
}
@import (inline) "../../node_modules/codemirror/lib/codemirror.css";

View File

@ -7,3 +7,27 @@
max-height: 100%; max-height: 100%;
} }
} }
.edit-flow {
position: absolute;
right: 25px;
top: 140px;
height: 40px;
width: 40px;
border-radius: 20px;
background-color: white;
border: solid 2px rgba(248, 145, 59, 0.7);
text-align: center;
font-size: 22px;
line-height: 37px;
transition: all 100ms ease-in-out;
}
.edit-flow:hover {
background-color: rgba(239, 108, 0, 0.7);
color: rgba(0,0,0,0.8);
border: solid 2px transparent;
}

View File

@ -67,20 +67,14 @@ export default class ContentView extends Component {
return ( return (
<div> <div>
<div className="row">
<div className="col-sm-12">
<ContentLoader flow={flow} message={message}> <ContentLoader flow={flow} message={message}>
<ContentEditor <ContentEditor
onSave={this.props.onContentChange} onSave={content => {this.props.onContentChange(content);this.setState({contentEditorClosed : true});}}
onClose={() => this.setState({contentEditorClosed : true})}
onOpen={() => this.setState({contentEditorClosed : false})} onOpen={() => this.setState({contentEditorClosed : false})}
isClosed={this.state.contentEditorClosed} isClosed={this.state.contentEditorClosed}
content="" content=""
/> />
</ContentLoader> </ContentLoader>
</div>
</div>
{this.state.contentEditorClosed && (<div> {this.state.contentEditorClosed && (<div>
{View.textView ? ( {View.textView ? (
<ContentLoader flow={flow} message={message}> <ContentLoader flow={flow} message={message}>

View File

@ -6,7 +6,6 @@ export default class ContentEditor extends Component {
static propTypes = { static propTypes = {
content: PropTypes.string.isRequired, content: PropTypes.string.isRequired,
onSave: PropTypes.func.isRequired, onSave: PropTypes.func.isRequired,
onClose: PropTypes.func.isRequired,
onOpen: PropTypes.func.isRequired, onOpen: PropTypes.func.isRequired,
isClosed: PropTypes.bool.isRequired isClosed: PropTypes.bool.isRequired
} }
@ -20,17 +19,12 @@ export default class ContentEditor extends Component {
return ( return (
<div> <div>
{this.props.isClosed ? {this.props.isClosed ?
<a className="btn btn-default btn-xs pull-right" onClick={this.props.onOpen}> <a className="edit-flow" onClick={this.props.onOpen}>
<i className="fa fa-pencil-square-o"/> <i className="fa fa-pencil"/>
</a> : </a> :
<span> <a className="edit-flow" onClick={() => this.props.onSave(this.state.content)}>
<a className="btn btn-default btn-xs pull-right" onClick={this.props.onClose}> <i className="fa fa-check"/>
<i className="fa fa-times"/>
</a> </a>
<a className="btn btn-default btn-xs pull-right" onClick={() => this.props.onSave(this.state.content)}>
<i className="fa fa-floppy-o"/>
</a>
</span>
} }
{!this.props.isClosed && {!this.props.isClosed &&
<CodeEditor value={this.state.content} onChange={content => this.setState({content: content})}/> <CodeEditor value={this.state.content} onChange={content => this.setState({content: content})}/>

View File

@ -1,9 +1,7 @@
import React, { Component, PropTypes } from 'react' import React, { Component, PropTypes } from 'react'
import { render } from 'react-dom'; import { render } from 'react-dom';
import AceEditor from 'react-ace'; import Codemirror from 'react-codemirror';
import 'brace/mode/javascript';
import 'brace/theme/kuroir';
export default class CodeEditor extends Component{ export default class CodeEditor extends Component{
static propTypes = { static propTypes = {
@ -12,17 +10,12 @@ export default class CodeEditor extends Component{
} }
render() { render() {
let options = {
lineNumbers: true
};
return ( return (
<div onKeyDown={e => e.stopPropagation()}> <div onKeyDown={e => e.stopPropagation()}>
<AceEditor <Codemirror value={this.props.value} onChange={this.props.onChange} options={options}/>
mode="javascript"
theme="kuroir"
onChange={this.props.onChange}
name="rea"
value={this.props.value}
width="100%"
editorProps={{$blockScrolling: Infinity}}
/>
</div> </div>
) )
} }