quill icon indicating copy to clipboard operation
quill copied to clipboard

Using <br> instead of using <p>

Open conthub opened this issue 4 years ago • 10 comments

Hello, Is there any way to configure quilljs to make use of BR instead of using P upon every time I hit ENTER key? In other words, not to use paragraphs, but BR instead. Thanks for your help

conthub avatar Jun 15 '20 14:06 conthub

I'm only about to try this editor, hovever I stumbled across your question. Did you try pressing Shift + Enter to create a BR instead of P? That usually creates a break instead of a new paragraph in these kind of editors..

IcyFoxe avatar Jun 15 '20 15:06 IcyFoxe

Yeah, but what I need is a forced replace. I need a quilljs instance only meant to create html for email sending, and for this purpose I need NOT to use paragraphs but to use BR exclusively. I need that every time I hit ENTER it creates a BR and not a P.

conthub avatar Jun 15 '20 15:06 conthub

I see, well I can't help you with that. It will most likely require changing the source code.

IcyFoxe avatar Jun 15 '20 15:06 IcyFoxe

I see that quilljs used to use DIV for blocks, instead of P. Then they switched to use P. As mentioned here: https://github.com/quilljs/quill/issues/159#issuecomment-49682445

@jhchen Is there a way to config quilljs instance to use DIVs instead of Ps as an optional feature?

Thank you

conthub avatar Jun 15 '20 15:06 conthub

Is there a way to config quilljs instance to use DIVs instead of Ps as an optional feature?

yes, you can configure block blot and register it:

const Block = Quill.import('blots/block');
class DivBlock extends Block {} 

DivBlock.tagName = 'DIV';

// true means we overwrite  
Quill.register('blots/block', DivBlock, true); 

working example: https://jsfiddle.net/n4efwxd9/

ttypic avatar Jun 18 '20 23:06 ttypic

@ttypic Thank you for this. Forced P tags in rich editors are for monsters. And unfortunately, unlike many other rich editors, Quill doesn't support shift+enter to insert a BR tag.

ffxsam avatar Oct 29 '20 04:10 ffxsam

i still got an issue with p tag I would like to use br instead

phongnguyenmaster avatar Jan 04 '23 08:01 phongnguyenmaster

Does anyone have a solution for this yet? It seems to be an important issue.

NikolaDojic avatar Aug 24 '23 09:08 NikolaDojic

Managed to use
following this example. Found it through this post

muimota avatar Dec 21 '23 01:12 muimota

Is there any good&simple solution for the functionality SHIFT+ENTER --> <br>.

In my opinion, this should be a standard functionality of a rich text editor!

kozi avatar Feb 12 '24 15:02 kozi

Quill 2.0 has been released (announcement post) with many changes and fixes. If this is still an issue please create a new issue after reviewing our updated Contributing guide :pray:

quill-bot avatar Apr 17 '24 11:04 quill-bot

I created a new issue here: https://github.com/quilljs/quill/issues/4194

CharlieGreenman avatar May 10 '24 04:05 CharlieGreenman