4

I would like my tinymce editor to allow all the html elements, include some nested kind.

I read the documents at tinymce: http://www.tinymce.com/wiki.php/Configuration:valid_elements

And also confirmed by this post on Stackoverflow: TinyMce Allow all Html tag

I use valid_elements :"*[*]", in my tinymce options:

$('.page-tinymce-editor').tinymce({ 
    theme: 'advanced',
    theme_advanced_buttons1: "fontsizeselect,bold,italic,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,undo,redo,link,unlink,code,image,uploadimage,uploadattachment",
    theme_advanced_buttons2: "",
    theme_advanced_buttons3: "",
    theme_advanced_toolbar_location: "top",
    theme_advanced_toolbar_align: "left",

    width : "660px",
    height: "1200",
    body_id :"article",
    valid_elements :"*[*]",
    skin: "wp_theme",
    relative_urls: false,
    content_css: "http://" + location.host + "/assets/screen.css",
    plugins: 'uploadimage,uploadattachment'
})

But there's a nest condition in my html is still remove by tinymce. I have a piece of html like the following:

<span class="text">
<p> Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum  </p>
</span>

which becomes this :

<p> Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum  </p>

Tinymce removes the span outside the p tag. Other span tag are all fine. I studied the tinymce over and over, but didn't come out any idea to fix this.

Is there way to fix it?

Thanks a lot

Community
  • 1
  • 1
larryzhao
  • 3,173
  • 2
  • 40
  • 62

3 Answers3

0

You will need to adjust the valid_children setting! I guess p-tags are not defined/allowed al child noddes of spans by default.

Thariama
  • 50,002
  • 13
  • 138
  • 166
  • 1
    Hi, Thariama thanks a lot! I would simply like to make tinymce allow all the combinations, I added: `valid_children : "*[*]",` still, the `span` tag is omitted. Am I doing it right? – larryzhao Feb 08 '12 at 06:02
  • 1
    is there a way to turn off this functionality of tinymce? – larryzhao Feb 08 '12 at 06:25
  • hmmm, you may try to switch the cleanup functionality off. in this case you will need to use the cleanup paramter: cleanup: false, – Thariama Feb 08 '12 at 07:29
  • I hate to say that it's still not working. I add `cleanup: false,` to my call, still doesn't work... – larryzhao Feb 08 '12 at 11:39
  • add this: validate_children: false, – Thariama Feb 08 '12 at 13:53
  • now I have these two: `valid_elements: "*[*]", validate_children: false,`, still not working, the `` tag outside the `

    ` tag is still being striped...it's killing me...

    – larryzhao Feb 09 '12 at 03:10
  • 4
    I tried all three alternatives we've been talking about, in http://fiddle.tinymce.com/ none of them worked.. I just reported a bug to tinymce, I don't it's a bug or now.. – larryzhao Feb 09 '12 at 03:23
  • you may also ask a question in the tinymce forum, there are many people around who are focused on tinymce – Thariama Feb 09 '12 at 12:19
0

I think this could not be done on tinymce side. Here is the post talking about it at Tinymce forum: http://www.tinymce.com/forum/viewtopic.php?pid=98807#p98807

larryzhao
  • 3,173
  • 2
  • 40
  • 62
-1

Try something like extended_valid_elements : '+span[p]', in addition to the valid_children setting discussed above. And make sure to clear your cache entirely to make sure its not serving your old config file.

This should allow p to be a child of span

More information on that topic:
Alan Storm on Magento TinyMCE
Pixafy - Overcoming Magento's TinyMCE

I know this is an old topic but it still ranks high in the search results so hopefully it will help someone.