Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

119
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda