Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Underline format problem

According to the documentation i would like to overwrite predefined formats using this settings:

formats: {
        bold : {inline : 'b' },  
        italic : {inline : 'i' },
        underline: { inline: 'u' }
    },

I insert "this is a text" into the editor and press the underline-button. This is the result (this gets saved to database too):

<p>thi<span style="text-decoration: underline;">s is a t</span>ext</p>

Why do i get no u-tags, but the predefined span with underlined style? How do i get my lovely u-tags here?

EDIT: I do know that u-tags are deprecated, but i need them for compatibility reasons!

EDIT2: My solution thanks to the accepted answer:

I was able to use some code from the legacyoutput plugin. I used the inline_styles setting

inline_styles: false,

additionally ia dded the following code into one of my plugins onInit

serializer = ed.serializer;

// Force parsing of the serializer rules
serializer._setup();

// Check that deprecated elements are allowed if not add them
tinymce.each('b,i,u'.split(','), function(name) {
  var rule = serializer.rules[name];

  if (!rule) serializer.addRules(name);
});
like image 678
Thariama Avatar asked Mar 07 '11 12:03

Thariama


1 Answers

The real answer here turned out to be:

http://tinymce.moxiecode.com/wiki.php/Plugin:legacyoutput
(see comments)


I don't know whether this is correct, I'm just reiterating what I found here:

Firstly, you're warned that:

<u> is deprecated.

Then:

Disable inline_styles option.
Inline styles converts most attributes into CSS style attributes - so it will use span tags rather than <u>, <strike>, etc. So, disabling this option (which is now enabled by default) gives the behaviour you're looking for.

Alternatively:

This will do it:

tinyMCE.init({
    ...
    formats : {
        underline : {inline : 'u', exact : true}
        }

...

Good luck!

like image 114
thirtydot Avatar answered Oct 08 '22 23:10

thirtydot