Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

调用toHTML() 方法, 标签属性丢失 #795

Closed
wenyAlab opened this issue Jun 23, 2020 · 4 comments
Closed

调用toHTML() 方法, 标签属性丢失 #795

wenyAlab opened this issue Jun 23, 2020 · 4 comments

Comments

@wenyAlab
Copy link

wenyAlab commented Jun 23, 2020

背景:项目需求中 添加超链接需要携带 name 属性 (主要用来做锚点),目前改了源码 实现了添加链接携带 name 属性, 如下图:

image

image

问题:
当我调用toHTML(), 将编辑器内容转为html后, name属性丢失, 但是使用toRAW()方法可以看到name属性是存在的, 如下图:

toHTML:
image

toRAW:
image

另:hooks中也可以获取到name属性
const hooks = {
'toggle-link': ({ href, target, name }) => {
href = href.indexOf('http') === 0 ? href : http://${href};
return { href, target, name };
},
};

求助:我如何在调用toHTML()之后,保证name属性不会丢失?

@wenyAlab
Copy link
Author

修改了 braft-convert 的源码, toHTML()方法可以带上name属性了

@chaoningx
Copy link

不是braft-convert这个源码,应该是braft-utils/dist/content.js这个文件里边的toggleSelectionLink方法吧。参数加上name就好。

@Prottoy2938
Copy link

Can you share the code, my editorState.toHtml() doesn't return anything.

Issue raised here.

@marlti7
Copy link

marlti7 commented Dec 1, 2020

修改了 braft-convert 的源码, toHTML()方法可以带上name属性了

该怎么改

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants