/*
 * @Author: your name
 * @Date: 2021-10-30 15:54:44
 * @LastEditTime: 2021-12-04 14:48:16
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \background-front-end\src\utils\loadTinymce.js
 */
import loadScript from './loadScript'
import ELEMENT from 'element-ui'

let tinymceObj

export default function loadTinymce(cb) {
    if (tinymceObj) {
        cb(tinymceObj)
        return
    }

    const loading = ELEMENT.Loading.service({
        fullscreen: true,
        lock: true,
        text: '富文本资源加载中...',
        spinner: 'el-icon-loading',
        background: 'rgba(255, 255, 255, 0.5)'
    })

    loadScript('https://lib.baomitu.com/tinymce/latest/tinymce.min.js', () => {
        loading.close()
        // eslint-disable-next-line no-undef
        tinymceObj = tinymce
        cb(tinymceObj)
    })
}
