quill icon indicating copy to clipboard operation
quill copied to clipboard

Need to use span instead of p tag

Open Ashritha-12 opened this issue 1 year ago • 1 comments

<div id="editor">
  <p>Hello World!</p>
  <p>Some initial <strong>bold</strong> text</p>
  <p><br></p>
</div>

want my output like this:

< div id="editor">
  <span>Hello World!</p>
  <span>Some initial <strong>bold</strong> text</p>
  <span><br></span>
< /div>

Ashritha-12 avatar Jul 07 '24 18:07 Ashritha-12

HI ^^, you can redifine the block blots to use span instead of p tag

import Quill from 'quill'

const Block = Quill.import('blots/block')
Block.tagName = 'SPAN'

export default Block

You then need to register your new blot to quill so he use yours and not the default one.

Quill.register(Block, true)

And now you have span instead of p

AltiorPetitM avatar Jul 10 '24 10:07 AltiorPetitM

As I needed the <span> along with the<p> I did the following edit, hope it helps who needs it. in the quill.js or quill.min.js (which ever you include) find the "h6" and add "span" after it, then the 2nd "H6"and add "SPAN" after it, case sensitive.

then in quill.snow.css find 'Heading 6' and add the following after the end of the block "}" .ql-snow .ql-picker.ql-header .ql-picker-label[data-value="7"]::before,.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="7"]::before{content:'Span'}

last step, in your js code where you call for new Quill be sure to set the header as the following { "header": [false, 1, 2, 3, 4, 5, 6, 7] }

now you have <span> as additional format in the header where it will replace the <p> when needed

abgrxenda avatar Dec 18 '24 08:12 abgrxenda