通过 跟一个 组件绑定,操作对应的 组件。

平台差异说明

editorContext.format(name, value)

修改样式

参数类型说明
nameString属性
valueString

支持设置的样式列表

namevalue
bold
italic
underline
strike
ins
scriptsub / super
headerH1 / H2 / h3 / H4 / h5 / H6
alignleft / center / right / justify
directionrtl
indent-1 / +1
listordered / bullet / check
colorhex color
backgroundColorhex color
margin/marginTop/marginBottom/marginLeft/marginRightcss style
padding/paddingTop/paddingBottom/paddingLeft/paddingRightcss style
font/fontSize/fontStyle/fontVariant/fontWeight/fontFamilycss style
lineHeightcss style
letterSpacingcss style
textDecorationcss style

对已经应用样式的选区设置会取消样式。css style 表示 css 中规定的允许值。

editorContext.insertDivider(OBJECT)

插入分割线

OBJECT 参数说明

属性类型默认值必填说明
successFunction接口调用成功的回调函数
failFunction接口调用失败的回调函数
completeFunction接口调用结束的回调函数(调用成功、失败都会执行)

OBJECT 参数说明

editorContext.insertText(OBJECT)

覆盖当前选区,设置一段文本

OBJECT 参数说明

属性类型默认值必填说明
textString文本内容
successFunction接口调用成功的回调函数
failFunction接口调用失败的回调函数
completeFunction接口调用结束的回调函数(调用成功、失败都会执行)

editorContext.setContents(OBJECT)

初始化编辑器内容,hmlt和delta同时存在时仅delta生效

OBJECT 参数说明

属性类型默认值必填说明
htmlString带标签的HTML内容
deltaObject表示内容的delta对象
successFunction接口调用成功的回调函数
failFunction接口调用失败的回调函数
completeFunction接口调用结束的回调函数(调用成功、失败都会执行)

editorContext.getContents(OBJECT)

获取编辑器内容

OBJECT 参数说明

属性类型默认值必填说明
successFunction接口调用成功的回调函数
failFunction接口调用失败的回调函数
completeFunction接口调用结束的回调函数(调用成功、失败都会执行)

OBJECT 参数说明

editorContext.removeFormat(OBJECT)

清除当前选区的样式

OBJECT 参数说明

属性类型默认值必填说明
successFunction接口调用成功的回调函数
failFunction接口调用失败的回调函数
completeFunction接口调用结束的回调函数(调用成功、失败都会执行)

editorContext.undo(OBJECT)

撤销

OBJECT 参数说明

属性类型默认值必填说明
successFunction接口调用成功的回调函数
failFunction接口调用失败的回调函数
completeFunction接口调用结束的回调函数(调用成功、失败都会执行)

恢复

OBJECT 参数说明

属性类型默认值必填说明
successFunction接口调用成功的回调函数
failFunction接口调用失败的回调函数
completeFunction接口调用结束的回调函数(调用成功、失败都会执行)