swalter88
swalter88

Reputation: 1413

Howto force TinyMCE to create SPAN tag inside of P tags?

i have to customize tinymce and have such problems with that... my problem is, that all default text should be wrapped within a span and p tag.

e.g.: <p><span>My Text</span></p>

if i will add formatting it should be changed to e.g.: <p><span style="font-weight:bold;">My Text</span></p>

tinymce should not remove the span or p tag if i will change the text or save the html output...

is such a scenario possible? has anybody a hint for me, to find the correct places in tinymce?

Upvotes: 2

Views: 2990

Answers (2)

user137263
user137263

Reputation: 747

Jesus this question has gone unanswered for a while. Don't know if you are still looking for an answer but the best approach is to find the config file for tinyMCE and add to the list of accepted tags. I had to do this for frames and it worked fine!

Upvotes: 1

Thariama
Thariama

Reputation: 50832

You will need to set the settings valid_children and valid_elements accordingly

    valid_elements: "@[id|class|title|style|onmouseover]," +
    "a[name|href|target|title|alt]," +
    "#p,blockquote,-ol,-ul,-li,br,img[src|height|width],-sub,-sup,-b,-i,-u," +
    "span,hr",

    valid_children: "body[p|ol|ul]" +
    ",p[a|span|b|i|u|sup|sub|img|hr|#text]" +
    ",span[p|a|b|i|u|sup|sub|img|#text]" +
    ",a[span|b|i|u|sup|sub|img|#text]" +
    ",b[span|a|i|u|sup|sub|img|#text]" +
    ",i[span|a|b|u|sup|sub|img|#text]" +
    ",sup[span|a|i|b|u|sub|img|#text]" +
    ",sub[span|a|i|b|u|sup|img|#text]" +
    ",li[span|a|b|i|u|sup|sub|img|ol|ul|#text]" +
    ",ol[li]" +
    ",ul[li]",

Second you will need to take care of the wrapping in spans yourself using the setup config parameter and a handler. The other option is to write an own plugin and handle this there. Let me know if you are able to make it work. If not come back and ask.

Upvotes: 1

Related Questions