Configurable block tag (div, paragraph)
Whilst div tags are quite acceptable for most cases, there are some uses where paragraph tags are necessary over div's.
As an example: I work on an application that allows authors to write content for ePubs. For both logical structure and ePub rendering reasons we like to use paragraph tags.
From a very shallow inspection of the source it would appear this would involve changing references to the dom.DEFAULT_BLOCK_TAG variable with an option defined at initialisation.
- Is there enough reason to warrant this change?
- Are there any unintended consequences of implementing a change like this? @jhchen
- How should configuration be handled? Define in the constructor options hash as
block_tag: 'p'?
I've had a crack at implementing a configurable block tag and along the way picking up on how Quill works.
Whilst most of the changes are straight forward the Formatter and Normalizer have some logic that may conflict and require some attention. With my current limited depth of knowledge on all the moving parts in Quill I am not sure if there is any unintended consequences (tests aside) of making a change like this.
@jhchen is there any "here be dragons" you can point me in the direction of to make sure that I can sort it out? The Normalizer class feels like one of them since it sits outside the scope of an editor instance making configs unavailable.
I'll push my forked branch soon once I have gotten it a little further along.
Right I think the major challenge is that the normalizer is not configurable. There are many benefits to turning it into a class and this needs to happen for a couple other bugs to be fixed such as #191. I'm hoping to get to this soon so it might work best for this feature to be added after the normalizer changes.
+1 looking forward to this landing.
:+1:
@jhchen what's the normalizer looking like? Are @alexeckermann or you working on the change to make this configurable? If not, perhaps I can help lift. We have Quill configured, but absolutely need content wrapped in <p> tags for it to meet requirements.
I'd much rather help contribute than just hack this into a fork. Just don't want to double up on work. (And I have no context into this project/source so it would take me a while to get ramped up).
Thanks!
:pear:
This may be irrelevant for most, but I am using this editor in a CMS, and I have the following running before the content is saved to my database:
// swap div tags with p
$value = str_replace('div>', 'p>', $value);
// remove the empty sections now
$value = str_replace('<p><br></p>', '', $value);
This just runs each time I save my page. It works nicely at the moment. I am sure for more complicated code, this would not be as helpful.
+1 for being able to use paragraphs instead of divs.
By the way, thanks for a great editor!
:+1:
:+1:
I can't understand how this work: http://codepen.io/SaraVieira/pen/eaAcu
It use p instead of div. How?
They seem to either have their own fork or build that probably changed the DEFAULT_BLOCK_TAG constant (and got rid of the browser default padding on paragraph tags).
Tnx!
:+1:
Has no progress been made to make this a customizable option? Surely there should be some mapping for ALL tags to allow customization.
I currently need to use paragraph tags instead of divs, in addition to some other changes. Its a bit discouraging to see that this hasn't been resolved yet.
I'd also like to have this. I'm going to use something similar to @james2doyle 's solution for the time being, but I'd love to be able to have <p> tags instead.
@jhchen I'm open to help get this working if you can point me in the right direction.
:+1: we're strongly considering using Quill in Simpla but non-standard content elements (eg: divs instead of ps) are a dealbreaker for inline editing.
:+1: need this changes too
The default block tag in the 1.0 beta release is <p>, with no bottom margin. If you want the bottom margin you can add it with css. If you want the default block tag to be <div> like it was before, you can configure with Parchment:
var Parchment = Quill.import('parchment');
var Block = Parchment.query('block');
Block.tagName = 'DIV';
// or class NewBlock extends Block {}; NewBlock.tagName = 'DIV';
Quill.register(Block /* or NewBlock */, true);
// Create your Quill editor like before
var quill = new Quill('#editor');
Hurray --- thanks!
Thank you =)