king
2023-03-04 52faefc67ffef29e3d208d2233c2547fc0ee47d3
src/templates/zshare/codemirror/index.jsx
@@ -23,6 +23,7 @@
    value: PropTypes.string, // 内容
    mode: PropTypes.any,     // 可选,语言模式,默认为sql
    theme: PropTypes.any,    // 可选,主题样式
    func: PropTypes.any,     // 编辑存储过程
    onChange: PropTypes.func // 内容变化时回调
  }
@@ -38,6 +39,8 @@
  editor = null
  UNSAFE_componentWillMount () {
    const { func } = this.props
    let options = {
      lineNumbers: true,
      lineWrapping: true,
@@ -50,6 +53,7 @@
    }
    this.setState({
      style: func ? {fontSize: '14px', lineHeight: '25px'} : {fontSize: '18px', lineHeight: '32px'},
      value: this.props.value || '',
      defaultVal: this.props.value || '',
      options
@@ -146,7 +150,7 @@
  }
  render() {
    const { mode } = this.props
    const { mode, func } = this.props
    const { defaultVal, options, fullScreen, style, display } = this.state
    const menu = (
      <Menu>
@@ -190,11 +194,11 @@
    )
    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