skip to Main Content

I have a problem like this:

I am using TinyMCE v6. whenever I am using:

tinymce.get("html").getContent()

It always adds a <br> tag after a line break.

So can someone help me disable the auto add <br> tag after line break?

I have tried:

forced_root_block: false,
force_br_newlines: false,
force_p_newlines: false,

But it does not work in v6.

HERE IS MY CODE

tinymce.init({
    selector: 'textarea#html',
    plugins: 'anchor autolink charmap codesample emoticons image media code link lists searchreplace table visualblocks wordcount',
    imagetools_cors_hosts: ['picsum.photos'],
    menubar: 'file edit view insert format tools table help',
    toolbar: 'undo redo | blocks fontfamily fontsize | bold italic underline strikethrough highlight custom | link image media code ruby table mergetags | align lineheight | tinycomments | numlist bullist indent outdent | emoticons charmap removeformat',
    toolbar_sticky: true,
    // toolbar_mode: 'floating',
    toolbar_mode: 'wrap',
    autosave_ask_before_unload: true,
    paste_data_images: true,
    autosave_interval: '30s',
    autosave_retention: '2m',
    height: 800,
    statusbar: false,
    forced_root_block: false,
    force_br_newlines: false,
    force_p_newlines: false,
    extended_valid_elements: 'script[language|type|src]',
    content_css: ['/dist/css/adminlte.min.css'],
    content_css_cors: true,
    importcss_append: true,
    convert_urls: false
});

Really sorry for my bad English!!!

disable auto add <br> tag after linebreak in TinyMCE v6

2

Answers


  1. Chosen as BEST ANSWER

    It seem that i have a missing a point in the question. I have copy code html then paste to tinymce like

    <nav class="main-header navbar navbar-expand navbar-dark navbar-light ml-0">
        <!-- Left navbar links -->
        <ul class="navbar-nav">
            <li class="nav-item ml-sm-5">
                <a href="#" class="brand-link">
                    <img src="/img/test_logo_3.jpg" alt="AdminLTE Logo" class="brand-image img-circle elevation-3" style="opacity: .8">
                </a>
            </li>
        </ul>
        <!-- Right navbar links -->
        <ul class="navbar-nav ml-auto">
            <li class="nav-item">
                <span class="user-name text-white d-block text-truncate"></span>
            </li>
        </ul>
    </nav>
    

    But when i submit form and using getContent it still auto add
    tag into my code. Anyone can help me


  2. Set the newline behavior option to “block” to prevent any new line breaks from appearing in the editor when presssing the enter key:
    you can use this option.enter image description here
    newline_behavior: ‘block’,

    for more help check this documentation help page.
    https://www.tiny.cloud/blog/remove-line-breaks/

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search