| | |
| | | state = { |
| | | card: null, |
| | | fonts: null, |
| | | comIds: [], |
| | | backgroundImage: '', |
| | | options: [], |
| | | borposition: 'outer' |
| | | } |
| | | |
| | | callback = null |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.state), fromJS(nextState)) |
| | |
| | | MKEmitter.removeListener('changeStyle', this.initStyle) |
| | | } |
| | | |
| | | initStyle = (comIds, options, style = {}) => { |
| | | initStyle = (options, style = {}, callback) => { |
| | | let backgroundImage = '' |
| | | if (style.backgroundImage && /^url/ig.test(style.backgroundImage)) { |
| | | backgroundImage = style.backgroundImage.replace(/^url\(/ig, '').replace(/\)$/ig, '') |
| | |
| | | } |
| | | } |
| | | |
| | | this.callback = callback |
| | | |
| | | this.setState({ |
| | | visible: true, |
| | | fonts: fonts, |
| | | comIds: comIds, |
| | | card: fromJS(style).toJS(), |
| | | options: options, |
| | | borposition: 'outer', |
| | |
| | | } |
| | | |
| | | if (check) { |
| | | MKEmitter.emit('submitStyle', this.state.comIds, card) |
| | | this.callback && this.callback(card) |
| | | } |
| | | |
| | | this.setState({ |
| | | visible: false, |
| | | comIds: [], |
| | | card: null, |
| | | options: [], |
| | | backgroundImage: '' |
| | | }) |
| | | window.GLOB.styling = false |
| | | this.callback = null |
| | | } |
| | | |
| | | updateStyle = (style) => { |
| | | const { comIds, card } = this.state |
| | | const { card } = this.state |
| | | |
| | | let _style = { |
| | | ...card, |
| | |
| | | card: _style, |
| | | }) |
| | | |
| | | MKEmitter.emit('submitStyle', comIds, _style) |
| | | this.callback && this.callback(_style) |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | changeBackground = (val) => { |
| | | const { comIds, card } = this.state |
| | | const { card } = this.state |
| | | |
| | | let _style = { ...card } |
| | | |
| | |
| | | }) |
| | | |
| | | if (!val || /(^linear-gradient|^radial-gradient)\(.*\)$/.test(val)) { |
| | | MKEmitter.emit('submitStyle', comIds, _style) |
| | | this.callback && this.callback(_style) |
| | | } |
| | | } |
| | | |