king
2022-09-06 bdfec44c9f3a37dbbe05bf14a252ffec04132a86
src/menu/stylecontroller/index.jsx
@@ -51,11 +51,12 @@
  state = {
    card: null,
    fonts: null,
    comIds: [],
    backgroundImage: '',
    options: [],
    borposition: 'outer'
  }
  callback = null
  shouldComponentUpdate (nextProps, nextState) {
    return !is(fromJS(this.state), fromJS(nextState))
@@ -75,7 +76,7 @@
    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, '')
@@ -95,10 +96,11 @@
      }
    }
    this.callback = callback
    this.setState({
      visible: true,
      fonts: fonts,
      comIds: comIds,
      card: fromJS(style).toJS(),
      options: options,
      borposition: 'outer',
@@ -134,21 +136,21 @@
    }
    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,
@@ -159,7 +161,7 @@
      card: _style,
    })
    MKEmitter.emit('submitStyle', comIds, _style)
    this.callback && this.callback(_style)
  }
  /**
@@ -262,7 +264,7 @@
  }
  changeBackground = (val) => {
    const { comIds, card } = this.state
    const { card } = this.state
    let _style = { ...card }
@@ -280,7 +282,7 @@
    })
    if (!val || /(^linear-gradient|^radial-gradient)\(.*\)$/.test(val)) {
      MKEmitter.emit('submitStyle', comIds, _style)
      this.callback && this.callback(_style)
    }
  }