This repository has been archived by the owner on Apr 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ppoffice
committed
Jan 2, 2016
1 parent
0c3ad92
commit a7f6332
Showing
5 changed files
with
89 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React, { Component, PropTypes } from 'react'; | ||
import CodeMirror from 'react-codemirror'; | ||
|
||
class Editor extends Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
value: props.value | ||
}; | ||
} | ||
|
||
componentWillUnmount () { | ||
const { uid, onTextShouldUpdate } = this.props; | ||
onTextShouldUpdate && onTextShouldUpdate(uid, this.state.value); | ||
} | ||
|
||
__onChange (value) { | ||
this.setState({ value }); | ||
} | ||
|
||
__onFocusChange (focused) { | ||
if (!focused) { | ||
const { value } = this.state; | ||
const { uid, onTextShouldUpdate } = this.props; | ||
onTextShouldUpdate && onTextShouldUpdate(uid, value); | ||
} | ||
} | ||
|
||
render() { | ||
return (<div> | ||
<CodeMirror | ||
ref="codemirror" | ||
value={ this.state.value } | ||
options={ this.props.options } | ||
onChange={ this.__onChange.bind(this) } | ||
onFocusChange={ this.__onFocusChange.bind(this) } /> | ||
</div>); | ||
} | ||
} | ||
|
||
Editor.propTypes = { | ||
uid: PropTypes.string, | ||
value: PropTypes.string, | ||
options: PropTypes.object, | ||
onTextShouldUpdate: PropTypes.func, | ||
} | ||
|
||
export default Editor; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.