Medium-editor: Possible to break out of the <p> tag?

Created on 31 Aug 2016  路  6Comments  路  Source: yabwe/medium-editor

Is there any way to break out of a <p></p> tag? I'm using the MediumButton extension to automatically insert pre-made components into the editor. However, these components, primarily made with <div> tags, are being nested inside the <p> tag , and therefore breaking everything (since you can't nest a <div> inside a <p>. Thanks in advance! Please let me know if my question was not clear and I will clarify.

bug html cleanup

Most helpful comment

I use ME in a custom-built email template editor, so paragraphs were a big no in my case. What I did to stop ME from wrapping content in <p></p> tags, is to comment out this line:

this.options.ownerDocument.execCommand('formatBlock', false, 'p');

In the unminified source, you find it at lines 6629 and 6644. Either comment them out, or change that logic to suit your needs.

All 6 comments

I use ME in a custom-built email template editor, so paragraphs were a big no in my case. What I did to stop ME from wrapping content in <p></p> tags, is to comment out this line:

this.options.ownerDocument.execCommand('formatBlock', false, 'p');

In the unminified source, you find it at lines 6629 and 6644. Either comment them out, or change that logic to suit your needs.

Thanks! I was looking for this! I want to add a section but I can't add it inside a p tag.

Can we also make this as an option?

Something has changes since this was posted because it does not seem to work. I desperately need to not automatically add the initial <p></p> tags to the editor, or for that matter, any <p> tags would be preferable.

You can disregard my comment, I just needed to read a little more and do some testing. Disabling return does what I need it to do, which is to make the text area emulate a single line input field.

@jorgedavila25 @hellocosmin @ditorahard @atebit would the work that was being done in #997 address your issues?

Commenting both this.options.ownerDocument.execCommand('formatBlock', false, 'p'); still creating the <p> tags. I need to edit the texts without those tags. Anything else I may try?

Was this page helpful?
0 / 5 - 0 ratings