跳到主要内容

api.intercept()

描述

允许拦截并阻止内部事件

用法

api.intercept(
event: string,
callback: function
): void;

参数

  • event - (必填)要触发的事件
  • callback - (必填)要执行的回调函数(回调参数取决于所触发的事件)

事件

信息

RichText 内部事件的完整列表可在此处查看

示例

// 创建 RichText
const editor = new richtext.Richtext("#root", {
// 配置属性
});
// 禁止更改字体大小
editor.api.intercept("set-font-size", (obj) => {
if(obj.fontSize !== "36px" ){
return false;
}
});

变更日志: 该方法在 v2.0 中新增