ReactMediumTemplate.js
1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import React,{PropTypes} from 'react';
import ReactMediumEditor from './ReactMediumEditor';
import cx from 'classnames';
import s from './reactMediumTemplateLess.les';
class ReactMediumTemplate extends React.Component {
constructor (props, context) {
super(props, context);
this.insertHTMLCommand = this.insertHTMLCommand.bind(this);
this.state={
text:'',
initLoad:false,
contractName:'',
contractType:'',
contractNameErr:'',
showCustomTag:false,
fileds:{
emp_fields:[],
cmpany_fields:[]
}
}
}
static propTypes={
onChange: PropTypes.func,
choices:PropTypes.array,
value:PropTypes.oneOfType([
PropTypes.string,
PropTypes.array,
PropTypes.object
]),
placeholder:PropTypes.string,
name:PropTypes.string,
multi:PropTypes.bool,
error:PropTypes.bool,
disabled:PropTypes.bool,
labelKey:PropTypes.string,
valueKey:PropTypes.string
}
static defaultProps={
labelKey:'label',
valueKey:'value',
choices:[]
}
insertHTMLCommand(item){
const { editor } = this.refs;
editor.insertHTMLCommand(item);
}
render(){
return(
<div className={cx(s.template_editor_wrap)}>
<div className={cx(s.template_editor_body)}>
<ReactMediumEditor ref='editor'
style={{overflow:'auto',padding:'0',wordWrap:'break-word',height:'100%'}}
text={this.props.text}
onChange={this.props.onChange} ></ReactMediumEditor>
</div>
</div>
)
}
}
export default ReactMediumTemplate;