1
votes

I have a paragraph which I am pasting in tinyMCE:

Here is the paragraph:

<p>1 aaaaaaaaaaaaa<br />bbbbbbbbbbbbbb</p>

I have set p and br as valid elements in the tinyMCE but I am loosing the br and I don't know why.

May be because my br is like <br /> and not <br>?

If I will delete completely the valid elements option, I am then getting also the <br />.

Do you know how can I enable the <br /> as a valid element in tinyMCE?

Thank you very much.

1
I wonder how br becomes XHTML br in your code? Because, usually, the tags are managed by tinyMCE itself, not by user. - raina77ow
Thank you for your answer @raina77ow. In fact, I am pasting a paragraph form pdf, I realy need this. Doing that, The linebreaks become <br />. - Milos Cuculovic
Well, this is really weird. I've created a tinyMCE fiddle just to check the behavior you wrote about - and voila, it happily parses both <br> and <br />. Can you make your own fork on its basis to show your problem in more details? - raina77ow
Ouh, I have found the solution, thanks to you @raina77ow, the problem was that I had a space between p and br like that: valid_elements: "p, br" and it shuld be valid_elements: "p,br". Very stupid misteki from me, I am realy sorry. Can you please answer the question, I can then accept the answer. - Milos Cuculovic

1 Answers

1
votes

tinyMCE valid_elements option allows to specify wide range of rules to 'normalize' the document: it's powerful, but it's quite strict in its syntax. Particularly speaking, one shouldn't use whitespace as additional separator of the rules.

For example, to restrict valid elements to <p> and <br /> only, this line should be used:

...
valid_elements: 'p,br' // not valid_elements: 'p, br'
...