5

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);
});
Thariama
  • 50,002
  • 13
  • 138
  • 166

3 Answers3

15

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!

thirtydot
  • 224,678
  • 48
  • 389
  • 349
  • i do need u-tags for compatibility reasons. Unfortunatly, underline : {inline : 'u', exact : true} does not work – Thariama Mar 07 '11 at 14:11
  • @Thariama: The only other thing mentioned in that thread was this: http://tinymce.moxiecode.com/wiki.php/Plugin:legacyoutput - however, that does more than just ``. If none of this is useful, I will delete my answer. – thirtydot Mar 07 '11 at 14:18
  • +1 thx, this is usefull (works), but i still do not know if there are any other things the legacyoutput plugin does which might affect something else – Thariama Mar 07 '11 at 14:52
  • @Thariama: If the other changes become a problem, it might be worth forking the plugin to only handle `` tags. I imagine it would be relatively easy - just remove stuff to do with other tags from the plugin. – thirtydot Mar 07 '11 at 14:58
  • 1
    found that out too and decided to use the few lines necessary to produce the u-tags only – Thariama Mar 07 '11 at 15:22
10

Thanks for this, I also need the <u> tags for SSRS 2008 reports which do not support the new <span style="text-decoration: underline;"> tag.

This combination worked for me:

inline_styles: false,
formats: {
    underline: { inline: 'u', exact : true }
}
csharpsql
  • 2,190
  • 1
  • 19
  • 24
0

Works here?

http://jsfiddle.net/dFY6r/

Also u tags are deprecated, along with b and i that is why we use CSS now:

.className {
    text-decoration: underline;
    font-weight: bold;
    font-style: italic;
}
Myles Gray
  • 8,711
  • 7
  • 48
  • 70
  • 1
    I think he just wants the `` tag because it's shorter (and he doesn't care [or know?] that it's deprecated). – thirtydot Mar 07 '11 at 12:53
  • @thirtydot - Well that is true, but doesn't hurt to educate right? I try and make sure all of my answers are standards compliant (unless its some ridiculous XHTML Strict caveat... – Myles Gray Mar 07 '11 at 12:56
  • i do not want any span tags at all, i want a u-tag (this is crucial) – Thariama Mar 07 '11 at 14:13