| | |
| | | value: PropTypes.string, // 内容 |
| | | mode: PropTypes.any, // 可选,语言模式,默认为sql |
| | | theme: PropTypes.any, // 可选,主题样式 |
| | | func: PropTypes.any, // 编辑存储过程 |
| | | onChange: PropTypes.func // 内容变化时回调 |
| | | } |
| | | |
| | |
| | | editor = null |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { func } = this.props |
| | | |
| | | let options = { |
| | | lineNumbers: true, |
| | | lineWrapping: true, |
| | |
| | | } |
| | | |
| | | this.setState({ |
| | | style: func ? {fontSize: '14px', lineHeight: '25px'} : {fontSize: '18px', lineHeight: '32px'}, |
| | | value: this.props.value || '', |
| | | defaultVal: this.props.value || '', |
| | | options |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { mode } = this.props |
| | | const { mode, func } = this.props |
| | | const { defaultVal, options, fullScreen, style, display } = this.state |
| | | const menu = ( |
| | | <Menu> |
| | |
| | | ) |
| | | |
| | | return ( |
| | | <div className="code-mirror-wrap" style={fullScreen ? style : null}> |
| | | <div className="code-mirror-wrap" style={fullScreen || func ? style : null}> |
| | | {!mode && !fullScreen ? <FormatPainterOutlined onClick={this.handleFormat}/> : null} |
| | | {!fullScreen ? <FullscreenOutlined onClick={this.fullScreenChange}/> : null} |
| | | {fullScreen ? <FullscreenExitOutlined onClick={this.fullScreenChange}/> : null} |
| | | {fullScreen ? <Dropdown overlay={menu} placement="bottomRight"> |
| | | {fullScreen || func ? <Dropdown overlayClassName="mk-mirror-font" overlay={menu} placement="bottomRight"> |
| | | <FontSizeOutlined /> |
| | | </Dropdown> : null} |
| | | {display ? <CodeMirror |