Quill - Make Editor wrap text in Div instead of P tag

断了今生、忘了曾经 提交于 2019-12-20 07:49:26

问题


I have built a Quill text editor in ReactJS with React-Quill. I would like to wrap the generated text in the text editor with a Div tag instead of a P tag. Is this possible?

Overview of my use: When text is generated/edited in the Quill editor it is duplicated in another div on another part of the page. Our use of this editor goes back a few years, and thus was built on an older version of Quill, when the text was generated in Div's. We recently upgraded to Quill 1.0 and when the text is generated in P tags it creates unwanted styles that we can't remove. The simplest and least hacky solution would be to generate div's instead of p tags, but I have no idea if that's even possible.

Does anyone know more about this?

Thank you.


回答1:


You can just change the tagName of the default Block:

var Block = Quill.import('blots/block');
Block.tagName = 'div';
Quill.register(Block);

Working example: https://codepen.io/anon/pen/brgvPR



来源:https://stackoverflow.com/questions/45496023/quill-make-editor-wrap-text-in-div-instead-of-p-tag

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!