[vue] Use Tinymce rich text editing function to transform records

  1. Tinymce adds Ctrl+Entry key to save

    // 1.组件中定义一个回调事件参数
    subFunc:{ // entry+回车键的确定事件
            type:Function,
            required:false 
    }
    // 2.tinyce组件初始化时
    tinymce.init({
        ..
        setup(editor) {
              editor.on('keydown', function(e) {
                // ctrl+entry回车键,并且回调函数不为空
                if (e.ctrlKey && e.keyCode === 13 && (_this.subFunc && typeof(_this.subFunc))) {
                    e.preventDefault();
                    _this.subFunc();
                }
              });
              editor.on('FullscreenStateChanged', (e) => {
                _this.fullscreen = e.state
              })
            },
        ...
    })
  2.  Switch Tinyce mode

    // 1.组件内定义参数
    model:{// 默认经典模式,webim用到了沉浸模式【DistractionFree】
        type: String,
        default: "default"
    }
    
    // 2. Tinyce初始化时
    tinymce.init({
        ..
        toolbar: this.model == 'DistractionFree' ? false : this.toolbar.length > 0 ? this.toolbar : toolbar,
            menubar: this.model == 'DistractionFree' ? false : this.menubar,
        ...
    })
    
    
  3. Clear Tincye editor content

    this.$refs.MessEditor.setContent("");
  4. more content  

    For more information, check the Chinese website: http://tinymce.ax-z.cn

Guess you like

Origin blog.csdn.net/qq_18316109/article/details/126589463