w***@126.com
w***@126.com
  • 发布:2020-06-03 14:19
  • 更新:2020-12-10 14:43
  • 阅读:923

【报Bug】富文本编辑setContents初始化内容,标签内的属性被更改了。

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Mac

PC开发环境操作系统版本号: 10.15.2

HBuilderX类型: 正式

HBuilderX版本号: 2.6.16

手机系统: iOS

手机系统版本号: iOS 13.4

手机厂商: 苹果

手机机型: iphone8

页面类型: vue

打包方式: 云端

项目创建方式: HBuilderX

示例代码:

核心代码:

const userInfo = {nickname: this.commentInfo.fromNickName, userId: this.commentInfo.fromUid};  
                let userInfoHtml = `<a href="toutou://user-detail?${stringify(userInfo)}" data-info="${stringify(userInfo)}" style="text-decoration:none;color:#3077EC">@${userInfo.nickname}: </a>`  
                const initHtml = this.commentInfo.content;  
                const reg = /(<p.*?>)(.*?<\/p>)/g;  
                userInfoHtml = initHtml.replace(reg, '$1'+'//' +userInfoHtml+'$2');  
                console.log('userInfoHtml',userInfoHtml)  
                this.editorCtx.setContents({html:userInfoHtml});  
                this.editorCtx.getContents({  
                    complete(res) {  
                        console.log('初始化转发的内容', res)  
                    }  
                })

操作步骤:

日志打印出显示的html内容不一致了。

预期结果:

属性还在

实际结果:

属性被换掉了

bug描述:

富文本编辑初始化内容是,标签内的属性被更改了。

2020-06-03 14:19 负责人:DCloud_UNI_GSQ 分享
已邀请:
w***@126.com

w***@126.com (作者) - 前端小白菜

害,有没有人康康这bug呀

w***@126.com

w***@126.com (作者) - 前端小白菜

来个人解释下呀。

w***@126.com

w***@126.com (作者) - 前端小白菜

扎心,只能自己通过存储delta对象解决了。。。

DCloud_UNI_GSQ

DCloud_UNI_GSQ

链接会进行过滤,你试试其他平台(比如微信小程序)表现如何

  • w***@126.com (作者)

    只用App....

    2020-06-30 15:50

  • w***@126.com (作者)

    搞不懂,为何要做这层的过滤,开发者自己过滤不就可以了吗。

    2020-08-28 10:46

  • w***@126.com (作者)

    而且你们也没有任何文档说明会过滤链接....开发找bug全靠自己猜。。。

    2020-08-28 10:48

升而无畏

升而无畏

我的回显时候img里面的宽度 和 alt都被过滤掉了 大佬怎么解决的

  • w***@126.com (作者)

    存 delta 字段的数据,用来初始化就不会了。

    2020-12-10 20:22

  • 1***@qq.com

    回复 w***@126.com: 大佬,html怎么转delta

    2021-09-27 16:39

该问题目前已经被锁定, 无法添加新回复