EditorContext
功能说明:EditorContext 实例,可通过 wx.createSelectorQuery 获取。EditorContext 通过 id 跟一个 editor 组件绑定,操作对应的 editor 组件。
.blur
该 方法 使用方式为 EditorContext.blur()
功能说明:编辑器失焦,同时收起键盘。
参数及说明:Object object
属性 | 类型 | 默认值 | 必填 | 说明 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
.clear
该 方法 使用方式为 EditorContext.clear()
功能说明:清空编辑器内容。
参数及说明:Object object。
属性 | 类型 | 默认值 | 必填 | 说明 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
.format
该 方法 使用方式为 EditorContext.format(string name, string value)
功能说明:修改样式。
参数及说明:Object object。
.getContents
该 方法 使用方式为 EditorContext.getContents()
功能说明:获取编辑器内容。
参数及说明:Object object。
.getSelectionText
该 方法 使用方式为 EditorContext.getSelectionText(Object object)
功能说明:获取编辑器已选区域内的纯文本内容。当编辑器失焦或未选中一段区间时,返回内容为空。
参数及说明:Object object。
.insertDivider
该 方法 使用方式为 EditorContext.insertDivider()
功能说明:插入分割线。
参数及说明:Object object。
属性 | 类型 | 默认值 | 必填 | 说明 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
.insertlmage
该 方法 使用方式为 EditorContext.insertlmage(Object object)
功能说明:插入图片。
地址为临时文件时,获取的编辑器 html 格式内容中标签增加属性 data-local,deta 格式内容中图片 attributes 属性增加 data-local 字段,该值为传入的临时文件地址。
开发者可选择在提交阶段上传图片到服务器,获取到网络地址后进行替换。替换时对于 html 内容应替换掉 的 src 值,对于 delta 内容应替换掉 insert { image: abc } 值。
参数及说明:Object object。
.insertText
该 方法 使用方式为 EditorContext.insertText(Object object)
功能说明:覆盖当前选区,设置一段文本。
参数及说明:Object object。
属性 | 类型 | 默认值 | 必填 | 说明 |
text | string | - | 否 | 文本内容 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
.redo
该 方法 使用方式为 EditorContext.redo(Object object)
功能说明:恢复。
参数及说明:Object object。
属性 | 类型 | 默认值 | 必填 | 说明 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
.removeFormat
该 方法 使用方式为 EditorContext.removeFormat(Object object)
功能说明:清除当前选区的样式。
参数及说明:Object object。
属性 | 类型 | 默认值 | 必填 | 说明 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
.scrolllntoView
该 方法 使用方式为 EditorContext.scrollIntoView()
功能说明:使得编辑器光标处滚动到窗口可视区域内。
.setContents
该 方法 使用方式为 EditorContext.setContents(Object object)
功能说明:初始化编辑器内容,html 和 delta 同时存在时仅 delta 生效。
参数及说明:Object object。
.undo
该 方法 使用方式为 EditorContext.undo()
功能说明:撤销。
参数及说明:Object object。
属性 | 类型 | 默认值 | 必填 | 说明 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |