vue中使用wangEditor 5富文本自定义扩展新功能,劫持菜单点击操作并重写业务

业务需求:在点击全屏和退出全屏时,做一些业务操作。

wangEditor 5的安装和使用参考官网:https://www.wangeditor.com/v5/for-frame.html

这里只举例劫持编辑器事件和操作(插件)的方法

1、创建with-editor-api.js文件,用来重写wangEditor的API操作

function withEditorApi(editor) {
  const { fullScreen, unFullScreen } = editor // 获取当前 editor API
  const newEditor = editor

	// 重写点击全屏操作
  newEditor.fullScreen = () => {
    console.log('点击全屏fullScreen=====')
    // ... 一些自己的业务
   // 这里是执行编辑器自带的全屏API方法
    fullScreen()
  }
	// 重写点击退出全屏
  newEditor.unFullScreen = () => {
    console.log('点击退出全屏unFullScreen====')
    // ... 一些自己的业务
   // 这里是执行编辑器自带的退出全屏API方法
    unFullScreen()
  }


  // 返回 newEditor ,重要!
  return newEditor
}

export default withEditorApi;

2、在main.js中注册此插件

import { Boot } from '@wangeditor/editor';
// with-editor-api.js文件的路径
import withEditorApi from '@/utils/with-editor-api.js';

Boot.registerPlugin(withEditorApi);
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值