Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

118
Vistas
How to replace p tag with br tag when user clicks enter wiht medium editor js

The library medium editor default behavior is to add a p tag when the user hits enter. This can cause layout and styling issues within the editable tag. Instead I would like to insert a br tag when the user hits enter.

I found this code that works as expected

 editor.subscribe("editableKeydownEnter", (event, element) => {
    //       debugger
    // if (event.shiftKey) {
    //   debugger
        event.preventDefault()
        event.stopPropagation()
        MediumEditor.selection.getSelectionStart(editor.options.ownerDocument)
        MediumEditor.util.insertHTMLCommand(editor.options.ownerDocument, "<br>")
    // }
  })

It inserts the br tag after the string of character within the editable div. However the cursor of the user stays behind the br tag so in the end the cursor doesent really goes to the line.

Is there a solution to this ?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda