TinyMCE - allow text as a direct child of <table> and / or <tr>

I fought for about 3 hours, both testing, and googled as a maniac. I did not find a solution to this particular problem.

Problem: TinyMCE will not allow me to insert text as a direct β€œchild” in:

<table> <tr> <tbody> 

Example: I use TinyMCE Option> Source Code.
Input data:

 <table> <tr></tr> *[generated]* </table> 

When I then click β€œOK” in the source code window, the output will be as follows:

 *[generated]* <table> <tbody> <tr></tr> </tbody> </table> 

What happens is that TinyMCE checks the markup as invalid and adds my "text" ([generated]) outside the table. WHY: I want this solution because the cms engine accepts static HTML and finds special elements for inserting dynamic data data. The data will contain valid HTML, and the tag [generated] will not exist on the generated page later.

What I've done? I have tried:

 extend_valid_elements: "table[#text], table[text], tr[#text],tr[text]", valid_elements: "table[theader|tbody|#text|]", valid_children: "table[theader|tbody|#text]" 

I cannot insert all the different elements with which I tried to resolve. But now I have no ideas. And I do not want to prepare a dirty hack for this.

Is there anyone who can help me? My settings are standard, I just added som plugins.

verify_html: false, cleanup: false,

But no matter what plugin / setting it does, I will remove it.

English is not my mother, but I hope I understand.

+6
source share
1 answer

I have some good news for you. TinyMCE docs show that valid_elements and valid_children allow some special control characters. One of these characters is to allow all options.

However, it should still be an element that begins and ends with the symbol <> and not #. Comment might be even better, therefore

That is, you can set valid_children to '' or '##'. Not sure how he will handle the replacement.

I will also see your cms docs. If he is smart enough to deal with html attributes, you can go along this route or give us html comments as mentioned above.

Finally, you can use the beforeload and beforesave functions as part of MCE or in your own code to convert any # something # to and then back.

http://www.tinymce.com/wiki.php/Configuration:valid_elements http://www.tinymce.com/wiki.php/Configuration:valid_children

0
source

Source: https://habr.com/ru/post/959056/


All Articles