import React, {Component} from 'react'
|
import PropTypes from 'prop-types'
|
import { is, fromJS } from 'immutable'
|
import { Modal } from 'antd'
|
import { EditOutlined } from '@ant-design/icons'
|
|
import CodeMirror from '@/templates/zshare/codemirror'
|
import './index.scss'
|
|
class NormalCss extends Component {
|
static propTpyes = {
|
config: PropTypes.object,
|
updateConfig: PropTypes.func
|
}
|
|
state = {
|
visible: false,
|
normalcss: ''
|
}
|
|
shouldComponentUpdate (nextProps, nextState) {
|
return !is(fromJS(this.state), fromJS(nextState))
|
}
|
|
trigger = () => {
|
const { config } = this.props
|
|
this.setState({visible: true, normalcss: config.normalcss || ''})
|
}
|
|
onCssChange = (val) => {
|
this.setState({
|
normalcss: val
|
})
|
}
|
|
submit = () => {
|
const { normalcss } = this.state
|
|
this.setState({
|
visible: false
|
})
|
|
this.props.updateConfig({...this.props.config, normalcss: normalcss})
|
}
|
|
render() {
|
const { visible, normalcss } = this.state
|
|
return (
|
<div className="mk-normal-css">
|
全局样式:<EditOutlined onClick={this.trigger} />
|
<Modal
|
title="全局样式"
|
wrapClassName="normal-css-modal"
|
visible={visible}
|
width={800}
|
maskClosable={false}
|
onOk={this.submit}
|
onCancel={() => { this.setState({ visible: false })}}
|
destroyOnClose
|
>
|
<CodeMirror mode="text/css" theme="cobalt" value={normalcss} onChange={this.onCssChange} />
|
</Modal>
|
</div>
|
)
|
}
|
}
|
|
export default NormalCss
|