更新记录
1.0.2(2025-02-28)
1.去掉组件中对uView ui组件库中u-transition的依赖,内部实现动画效果; 2.优化插件包体积,删除无用文件
1.0.1(2025-02-28)
完善使用文档,插件内部上传图片改成使用临时路径。
1.0.0(2025-02-08)
目前已上线稳定运行,已修复已知的诸多缺陷,请放心下载使用,插件使用文档后续更新
查看更多平台兼容性
Vue2 | Vue3 |
---|---|
√ | × |
App | 快应用 | 微信小程序 | 支付宝小程序 | 百度小程序 | 字节小程序 | QQ小程序 |
---|---|---|---|---|---|---|
app-vue | √ | √ | √ | √ | √ | √ |
钉钉小程序 | 快手小程序 | 飞书小程序 | 京东小程序 | 鸿蒙元服务 |
---|---|---|---|---|
√ | √ | × | × | × |
H5-Safari | Android Browser | 微信浏览器(Android) | QQ浏览器(Android) | Chrome | IE | Edge | Firefox | PC-Safari |
---|---|---|---|---|---|---|---|---|
√ | × | × | × | √ | √ | √ | √ | √ |
这个是基于uni-app官方editor的api封装的组件,专为移动而开发,支持一个页面使用单个或者多个。目前已上线稳定运行,已修复已知的诸多缺陷,请放心下载使用,如果对你有帮助,可以赏杯奶茶,谢谢。
组件名:editor-gx
组件已解决的已知问题
1.解决点击图片弹起键盘没有焦点的问题;
2.解决打开扩展菜单直接关闭、或者连续多次点击部分工具条,激活样式依旧存在的问题;
3.解决自动失去焦点后,工具条菜单有激活样式问题;
4.解决同一个页面使用多个富文本,内容无法输入到对应文本框问题;
5.解决键盘和富文本样式工具栏跟随效果功能;
6.解决当一个页面使用多个富文本时,插入图只能插入最后一个文本框的问题;
7.解决文本框聚焦、失焦、点击工具条,键盘会闪烁问题;
组件目前存在未解决的问题(等待官方修复)
详见:https://ask.dcloud.net.cn/question/203825
注意事项
1.富文本页面需要设置如下,否则工具条将被页面顶起来:
"app-plus": {
"softinputMode": "adjustResize"
}
2.toolIndex目前设置的值是999,这个值可以随意改,需要和组件中watch中判断保持一致即可;
3.组件中使用了iconfont字体,字体包文件在components/editor-gx/richtext目录中
下面是一个基本使用示例
<template>
<view style="padding: 40rpx;">
<view v-for="(item,index) in editorOptionsList" :key="item.id">
<view class="grad">{{item.title}}</view>
<editor-gx @focus='editorFocus'
@editorChange='editorChange'
:content='item.content'
:editorId='item.id'
:toolIndex="item.id == currentId ? 999 : 0"
/>
</view>
</view>
</template>
<script>
import editorGx from '@/components/editor-gx/editor-gx.vue'
export default {
components: {editorGx},
data() {
return {
editorOptionsList: [{
id: "editorId",
title: "本周工作总结",
content: '<p>哈哈。我是本周工作<b>总结</b>内容</p>',
}],
currentId: "", //当前聚焦的编辑器id 默认空 聚焦时自动赋值
}
},
onLoad() {},
methods: {
// 编辑器聚焦时触发
editorFocus(currentId) {
this.currentId = currentId;
uni.hideTabBar()
},
//实时获取当前输入富文本内容 e富文本内容 、 currentId当前聚焦的输入框ID
editorChange(currentId, e) {
const content = e.detail.html;
const currentItem = this.editorOptionsList.find(item => item.id == currentId);
currentItem.content = content;
console.log(this.editorOptionsList)
}
}
}
</script>
<style lang="scss" scoped>
.grad {
background: #eee;
line-height: 35px;
margin: 10px 0;
padding-left: 10px;
border-radius: 8px;
font-size: 28rpx;
}
</style>
使用说明
名称 | 类型 | 默认值 | 描述 |
---|---|---|---|
editorId | String | myEditor | 必填,绑定元素的id,一个页面使用多个时,靠这个id区分 |
toolIndex | Number | 0 | 必填,当前正在操作的工具栏的层级,值只能是999 |
readOnly | Boolean | false | 编辑器是否只读 |
content | Object | {} | 富文本内容,回显数据时使用 |
disabledListIndent | Boolean | true | 是否启用有序/无序列表和左右缩进互斥 |
showImgSize | Boolean | false | 点击图片时显示图片大小控件 |
showImgToolbar | Boolean | false | 点击图片时显示工具栏控件 |
showImgResize | Boolean | false | 击图片时显示修改尺寸控件 |
事件
名称 | 描述 | 返回值 |
---|---|---|
@editorChange | 原生editor的@input事件 当编辑器内容改变时触发 | 当前富文本内容 |
@focus | 编辑器聚焦时触发 | 当前富文本的id、 当前富文本内容 |
@blur | 编辑器失焦时触发 | 当前富文本的id、 当前富文本内容 |
@setContentSuccess | 编辑器初始化,回显富文本内容成功触发 | 无 |
@keyboardHeight | 编辑器聚焦或者失焦都会触发 | 键盘高度 |