TinyMCE 4.2 produces invalid list HTML markup

344
November 22, 2016, at 12:17 PM

Lots of older versions had the broken li markup but I encounter the problem as well in the newest version 4.2. I've tried version 4.0 as well but generates the same wrong HTML

This part:

Generates this:

<div>
    <p>List<br><br>
    </p>
    <br>
    <ul><br>
        <li>List 1</li>
        <br>
        <li>List 2</li>
        <br>
        <li>List 3</li>
        <br>
    </ul>
    <br>
    <p>&nbsp;</p>
    <div></div>
</div>

Whenever the exact same textarea is updated again it will generate this:

<div><p>List</p><br>
    <p><br><br></p><br>
        <ul><br>
        <ul><br>
            <li>List 1</li><br>
        </ul><br>
        </ul><br>
            <p>&nbsp;</p><br>
        <ul><br>
        <ul><br>
            <li>List 2</li><br>
        </ul><br>
        </ul><br>
            <p>&nbsp;</p><br>
        <ul><br>
        <ul><br>
             <li>List 3</li><br>
        </ul><br>
        </ul><br>
             <p><br><br></p><br>
             <p><br><br></p><br>
             <p>&nbsp;</p><br>
             <p>&nbsp;</p>
         <div>
    </div>
</div>

So the whole HTML is one big mess up.

Calling the plugin:

tinymce.init({
    selector: "textarea",
    plugins: [
        "advlist autolink lists link image charmap preview anchor lists",
        "searchreplace visualblocks",
        "insertdatetime media contextmenu paste "
    ],
    toolbar: "styleselect | bold | alignleft aligncenter alignright alignjustify | bullist,numlist"
});

Edit form:

<div class="form-group">
    <label for="content">Inhoud</label>
    <textarea name="content" id="content" class="form-control" cols="30" rows="10">{!! $block[0]->content !!}</textarea>
</div>
Answer 1

The controller seemed to have a nl2br function on content which managed to lose control of the HTML

READ ALSO
modal form popup in angular js

modal form popup in angular js

I want modal form popup but it is not appearing. when I am doing inspect element[nnn] it says that $(.

483
Breaking html pages into sections

Breaking html pages into sections

I'm trying to include sections into a HTML page for example header and footer (like we do in ruby on rails). Header and footer are saved in two different HTML pages.

234
How to Select a Word from a string in textarea on mouse single click on the word

How to Select a Word from a string in textarea on mouse single click on the word

I have a string in a html textarea. Using jquery is it possible to select a word from a string by just single clicking on the word.

329