set-text-style
描述
在设置文本样式时触发
用法
"set-text-style": ({ tag: TBlockType }) => boolean | void;
type TBlockType = "p" | "blockquote" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
参数
set-text-style 事件的回调函数可接收一个包含以下参数的对象:
tag- 文本样式
信息
如需处理内部事件,您可以使用 Event Bus 方法
示例
// 初始化 RichText
const editor = new richtext.Richtext("#root", {
// 配置属性
});
// 订阅 "set-text-style" 事件
editor.api.on("set-text-style", (obj) => {
console.log(obj.tag);
console.log("The text style was changed");
});
// 应用新的文本样式
editor.api.exec("set-text-style", {
tag: "blockquote"
});
变更日志: 该事件在 v2.0 中添加