0
votes

I am using TinyMCE for capturing table row data on its row click. I am setting different values for color, font-styles such as bold, and italics for each of the table row contents through its configuration UI screen. On row-click, I want to set TinyMCE contents with the text with that particular color and font-style. However, it puts the deprecated font-styles in span tag and I do not want this. I want it to preserve the HTML text as it is received by the editor as later on I have to process it. I have tried:

tinymce.init(
  {
    selector:'textarea',
    theme:"advanced",                   
    theme_advanced_statusbar_location : "none",
    theme_advanced_menubar_location : "none",
    theme_advanced_toolbar_location : "none",
    convert_fonts_to_spans : "false",
    extended_valid_elements : "span[!class]",
    valid_elements : "*[*]",
    valid_children : "*[*]",
    cleanup_on_startup : false,
    cleanup : false,
  }
);

even though the main developer of TinyMCE has advised against setting cleanup =false on their forum page. Also, in spite of setting valid_elements : "*[*]", the deprecated tags like <b> and <u> are put into the style attribute of span tag.

2

2 Answers

2
votes

Here's the way I did it for font color, font size. You can apply this technique to anything else. This is for TinyMCE 4

    convert_fonts_to_spans : false,
    formats: {
        forecolor : {inline : 'font', attributes: { color: "%value" }},
        fontsize: {inline : 'font', attributes: { size: "%value" }}
    },

Note: You can't just do convert_fonts_to_spans : false, you need formats too.

1
votes

I found the solution..All i had to do was

tinymce.init({

    selector:'textarea',
    theme:"advanced",                   
    theme_advanced_statusbar_location : "none",
    theme_advanced_menubar_location : "none",
    theme_advanced_toolbar_location : "none",
    convert_fonts_to_spans : false,
    valid_elements : "b,u,i,font[color|size]",
    valid_children : "b,u,i,font[color|size}",
    cleanup_on_startup : false,
    cleanup : false,
});