79170752

Date: 2024-11-08 16:06:26
Score: 0.5
Natty:
Report link

what worked for my project in tinymce v7+ is adding to the initialization: newline_behavior: 'block', then modifying The editor content to wrap it inside divs ( for the existing messages on the website) :

setup: function (editor) {
        

  function wrapLinesInDivs(content) {
    const lines = content.split(/<br\s*\/?>|\n/);
    return lines.map(line => `<div>${line}</div>`).join('');
  }

  editor.on('init', function () {
    // Get the initial content as HTML
    let content = editor.getContent();
    // Wrap each line in a div
    let wrappedContent = wrapLinesInDivs(content);
    // Set the modified content
    editor.setContent(wrappedContent);
  });

},

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Starts with a question (0.5): what
  • Low reputation (1):
Posted by: Marouane Ao