Configuration / Cleanup problem

Using copy-paste (or the code plugin) users are able to insert content including spans yielding to nested spans even though i thought that my settings forbid nested spans. I do want to have nested spans been filtered out when the "cleanup" action gets performed.

Doing a manual cleanup (command "mceCleanup" which is triggered after pasting text) does not help either.

Reffering to the TinyMCE documentation a user may choose which child elements tinymce discards when performing "cleanup" for defined parent nodes.

Is there a problem with my config? If yes, what is wrong? Any suggestions?

Here's my configuration (the relevant part, i am using the newest tinymce version (3.3.8), occurs in all major browsers):

    cleanup : true,

    encoding: "xml",

    dialog_type : "modal",

    object_resizing: false,
    paste_strip_class_attributes: "all",

    entity_encoding: "raw",

    fix_nesting: true,

    invalid_elements: "strong,ul,ol,li",


    // The valid_elements option defines which elements will remain in the edited text when the editor saves.
    valid_elements: "@[id|class|title|style],"
    + "a[name|href|target|title],"
    + "#p,-ol,-ul,-li,br,img[src],-sub,-sup,-b,-i,"
    + "-span,hr",

    valid_child_elements : "body[p|ol|ul]"  //EDIT: had some ","s instead of "|"s
    + ",p[a|span|b|i|sup|sub|img|hr|#text]"
    + ",span[a|b|i|sup|sub|img|#text]"
    + ",a[span|b|i|sup|sub|img|#text]"
    + ",b[span|a|i|sup|sub|img|#text]"
    + ",i[span|a|b|sup|sub|img|#text]"
    + ",sup[span|a|i|b|sub|img|#text]"
    + ",sub[span|a|i|b|sup|img|#text]"
    + ",li[span|a|b|i|sup|sub|img|ol|ul|#text]"
    + ",ol[li]"
    + ",ul[li]"

Answers


I don't think there is any problem with your config.

The problem is that the TinyMCE code totally ignores the valid_child_elements attribute since version 3.3b1 (25 January 2010). I used Window Grep to examine all files in the 3.3.8 download and the valid_child_elements string is only found twice (and on the same line) in /jscripts/tiny_mce/Classes/Editor.js - this turns out to be a simple assignment statement that is not used anywhere else.

It turns out that in version 3.2.7 (22 September 2009) or below (see http://sourceforge.net/projects/tinymce/files), the valid_child_elements attribute calls a function called addValidChildRules in /jscripts/tiny_mce/Classes/dom/Serializer.js which I believe does what you essentially want. There are bugs in this version mind you. I eventually got the nested tags to be removed after adding a simplified valid_child_elements config parameter to one of the sample files in the download:

valid_child_elements : "span[a|b|i|sup|sub|img|#text]"

Hope this helps.


Need Your Help

Bitmap to Picturebox

c# bitmap

This question is related to This question. At the end, user does something like

iCloud sync keychain

objective-c ios cocoa-touch icloud

In my app, I want to be able to sync a configuration that gets created by the user. I wanted to use iCloud to sync that configuration so that it is always the same on all devices. But, I use the