wangeditor-team / wangEditor

wangEditor —— 开源 Web 富文本编辑器
http://www.wangeditor.com/
MIT License
17.37k stars 3.31k forks source link

setnodes修改图片的alt无效 #5902

Open the-lemonboy opened 1 month ago

the-lemonboy commented 1 month ago

问题描述

setnodes修改图片的alt无效

wangEditor 版本

5.1.0

是否查阅了文档 ?

(文档链接 www.wangeditor.com

最小成本的复现步骤

for (let i = 0; i < allImgArr.length; i++) { const imgDom = document.querySelector(#${allImgArr[i].id} img) const node = DomEditor.toSlateNode(this.editor, imgDom) const location = DomEditor.findPath(this.editor, node) const itemClone = { ...allImgArr[i] } itemClone.alt = 'test' SlateTransforms.setNodes( this.editor, { itemClone }, { at: location } ) setTimeout(() => { console.log(this.editor.getHtml()) }, 3000) }

image
cycleccc commented 1 month ago

使用 官方文档的沙盒 demo 做个最小复现? 或是 用 wangeditor-next 里对应的沙盒做个最小复现也行,不然不方便debug。问题很多,时间不多。

cycleccc commented 1 month ago

需要 最小沙盒 demo 复现,没有具体的代码没发 debug,只是想批量改 alt的话处理 html 然后再set就行。是做了自定义扩展吗?

the-lemonboy commented 1 month ago

主要是想在img的style没有宽高属性自定义添加默认宽高。涉及到图片上传,没有可以使用的后端接口用在复现demo中,https://github.com/wangeditor-team/server我用这个做demo给您可以吗

cycleccc commented 1 month ago

wangeidtor可以直接在 style 里设置图片宽高的呀,从后端获取前端筛一遍,直接修改 html 字符串再 sethtml 就可以了吧

https://github.com/user-attachments/assets/fef16dbf-92a0-4cbd-ac66-4814cc4e458b

the-lemonboy commented 1 month ago

wangeidtor可以直接在 style 里设置图片宽高的呀,从后端获取前端筛一遍,直接修改 html 字符串再 sethtml 就可以了吧

20240715_171228.mp4 感谢!我等下试一下。