Medium-editor: Use <br> instead of new <p>

Created on 26 Jun 2017  路  6Comments  路  Source: yabwe/medium-editor

Description

Everytime the user press the "Enter" key, a new <p> tag is created. Is there any way to avoid that new tag and use a <br> (or <br/>) instead? I need just one <p></p> per textarea.

Steps to reproduce

  1. Use MediumEditor with textarea.
  2. Press Enter. A new <p> tag will be created.

Expected behavior: New <br> tag for the new line.

Actual behavior: A new <p> tag is created.

Versions

  • medium-editor: 5.23.0
  • browser: Chrome (not relevant)
  • OS: Mac OS X

Most helpful comment

The default behaviour is what makes sense to me, but I suppose it's a matter of personal taste. I expect it to create a <p> tag when I press Enter and a <br> tag when I press Shift+Enter.

All 6 comments

@jimmyadaro Hey Dude) I thought about it too! I solved my problem like this:
let html = editor.api.getContent().replace(/\<p\>/ig,'<br>').replace(/\<\/p\>/ig,'');

The default behaviour is what makes sense to me, but I suppose it's a matter of personal taste. I expect it to create a <p> tag when I press Enter and a <br> tag when I press Shift+Enter.

What part of code controls the behaviour of Enter or Shift+Enter? Can we change that behaviour?

Edit: this is a duplicate of https://github.com/yabwe/medium-editor/issues/70

Just a suggestion, this could be a behavior tied to the setting disableDoubleReturn if this is true then enter/return could insert <br> instead of <p>.

Having the same request :) to have <br> instead of <p> disableDoubleReturn doesnt seem to add br but adds <p> instead

right now, if disabeReturn is false and disableDoubleReturn is true then you get a break when you hit Shift+Enter and just using Enter does nothing. This is something that would need to be changed in medium editor to use Enter for a single return in double return is disabled.

As @keligijus said above. This is being discussed in #70, you might want to check out that one.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thatdoorsajar picture thatdoorsajar  路  7Comments

keligijus picture keligijus  路  4Comments

DylanPiercey picture DylanPiercey  路  5Comments

tyler-johnson picture tyler-johnson  路  5Comments

subatomicglue picture subatomicglue  路  4Comments