EditorContext
基础库 2.7.0 开始支持,低版本需做兼容处理。
EditorContext 实例,可通过 wx.createSelectorQuery 获取。
EditorContext 通过 id 跟一个 editor 组件绑定,操作对应的 editor 组件。
基础库 2.8.3 开始支持,低版本需做兼容处理。
编辑器失焦,同时收起键盘。
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| success | function | 否 | 接口调用成功的回调函数 | |
| fail | function | 否 | 接口调用失败的回调函数 | |
| complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
基础库 2.7.0 开始支持,低版本需做兼容处理。
清空编辑器内容
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| success | function | 否 | 接口调用成功的回调函数 | |
| fail | function | 否 | 接口调用失败的回调函数 | |
| complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
基础库 2.7.0 开始支持,低版本需做兼容处理。
修改样式
属性
值
| name | value | verson |
|---|---|---|
| bold | 2.7.0 | |
| italic | 2.7.0 | |
| underline | 2.7.0 | |
| strike | 2.7.0 | |
| ins | 2.7.0 | |
| script | sub / super | 2.7.0 |
| header | H1 / H2 / h3 / H4 / h5 / H6 | 2.7.0 |
| align | left / center / right / justify | 2.7.0 |
| direction | rtl | 2.7.0 |
| indent | -1 / +1 | 2.7.0 |
| list | ordered / bullet / check | 2.7.0 |
| color | hex color | 2.7.0 |
| backgroundColor | hex color | 2.7.0 |
| margin/marginTop/marginBottom/marginLeft/marginRight | css style | 2.7.0 |
| padding/paddingTop/paddingBottom/paddingLeft/paddingRight | css style | 2.7.0 |
| font/fontSize/fontStyle/fontVariant/fontWeight/fontFamily | css style | 2.7.0 |
| lineHeight | css style | 2.7.0 |
| letterSpacing | css style | 2.7.0 |
| textDecoration | css style | 2.7.0 |
| textIndent | css style | 2.8.0 |
| wordWrap | css style | 2.10.2 |
| wordBreak | css style | 2.10.2 |
| whiteSpace | css style | 2.10.2 |
对已经应用样式的选区设置会取消样式。css style 表示 css 中规定的允许值。
基础库 2.7.0 开始支持,低版本需做兼容处理。
获取编辑器内容
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| success | function | 否 | 接口调用成功的回调函数 | |
| fail | function | 否 | 接口调用失败的回调函数 | |
| complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
| 属性 | 类型 | 说明 |
|---|---|---|
| html | string | 带标签的HTML内容 |
| text | string | 纯文本内容 |
| delta | Object | 表示内容的delta对象 |
基础库 2.10.2 开始支持,低版本需做兼容处理。
获取编辑器已选区域内的纯文本内容。当编辑器失焦或未选中一段区间时,返回内容为空。
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| success | function | 否 | 接口调用成功的回调函数 | |
| fail | function | 否 | 接口调用失败的回调函数 | |
| complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
| 属性 | 类型 | 说明 |
|---|---|---|
| text | string | 纯文本内容 |
基础库 2.7.0 开始支持,低版本需做兼容处理。
插入分割线
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| success | function | 否 | 接口调用成功的回调函数 | |
| fail | function | 否 | 接口调用失败的回调函数 | |
| complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
基础库 2.7.0 开始支持,低版本需做兼容处理。
插入图片。
地址为临时文件时,获取的编辑器html格式内容中 <img> 标签增加属性 data-local,delta 格式内容中图片 attributes 属性增加 data-local 字段,该值为传入的临时文件地址。
开发者可选择在提交阶段上传图片到服务器,获取到网络地址后进行替换。替换时对于html内容应替换掉 <img> 的 src 值,对于 delta 内容应替换掉 insert { image: abc } 值。
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| src | string | 是 | 图片地址,仅支持 http(s)、base64、云图片(2.8.0)、临时文件(2.8.3)。 | |
| alt | string | 否 | 图像无法显示时的替代文本 | |
| width | string | 否 | 图片宽度(pixels/百分比) | |
| height | string | 否 | 图片高度 (pixels/百分比) | |
| extClass | string | 否 | 添加到图片 img 标签上的类名 | |
| data | Object | 否 | data 被序列化为 name=value;name1=value2 的格式挂在属性 data-custom 上 | |
| success | function | 否 | 接口调用成功的回调函数 | |
| fail | function | 否 | 接口调用失败的回调函数 | |
| complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
this.editorCtx.insertImage({
src: 'xx',
width: '100px',
height: '50px',
extClass: className
}) 基础库 2.7.0 开始支持,低版本需做兼容处理。
覆盖当前选区,设置一段文本
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| text | string | 否 | 文本内容 | |
| success | function | 否 | 接口调用成功的回调函数 | |
| fail | function | 否 | 接口调用失败的回调函数 | |
| complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
基础库 2.7.0 开始支持,低版本需做兼容处理。
恢复
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| success | function | 否 | 接口调用成功的回调函数 | |
| fail | function | 否 | 接口调用失败的回调函数 | |
| complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
基础库 2.7.0 开始支持,低版本需做兼容处理。
清除当前选区的样式
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| success | function | 否 | 接口调用成功的回调函数 | |
| fail | function | 否 | 接口调用失败的回调函数 | |
| complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
基础库 2.8.3 开始支持,低版本需做兼容处理。
使得编辑器光标处滚动到窗口可视区域内。
基础库 2.7.0 开始支持,低版本需做兼容处理。
初始化编辑器内容,html和delta同时存在时仅delta生效
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| html | string | 否 | 带标签的HTML内容 | |
| delta | Object | 否 | 表示内容的delta对象 | |
| success | function | 否 | 接口调用成功的回调函数 | |
| fail | function | 否 | 接口调用失败的回调函数 | |
| complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
基础库 2.7.0 开始支持,低版本需做兼容处理。
撤销
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| success | function | 否 | 接口调用成功的回调函数 | |
| fail | function | 否 | 接口调用失败的回调函数 | |
| complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
备案信息: 粤ICP备15087711号-2
Copyright © 2008-2025 啊嘎哇在线工具箱 All Rights.
本站所有资料来源于网络,版权归原作者所有,仅作学习交流使用,如不慎侵犯了您的权利,请联系我们。