Mangirish
Mangirish

Reputation: 27

Help required in customizing HTML text in tinyMCE

Here is what I am stuck with...

I am formatting a a text with Richtext Editor in TinyMCE. Whenever i mark any text to bold, the html generated puts that text in <strong> tag, and likewise for Underline, a <span> tag with style=text-decoration attributes and for Italics <em> tag. Also if I modify the text size, still it puts a <span> with style=font-size attribute.

Now what i need is I want this text to get converted into basic HTML with <b> <u> <i> for Bold, Underline and Italics, respectively, and also for font size change or coloring etc, i want a <font> tag with standard attrtibutes (color, size etc.)

One way i feel would work is to modify the tiny_mce.js Register default formats.

But, i fear that it might invoke some regression issues with my other code modules.

Is that the solution for the problem, or is there any better way, maybe some configuration option to change this...

Any pointers for this shall be appreciated!

Thanks,

Mangirish

Upvotes: 2

Views: 243

Answers (2)

Thariama
Thariama

Reputation: 50832

In addition to the approch Sascha Galley proposed you will need to activate the legacyoutput plugin in your tinymce init:

plugins: "...,code,save,legacyoutput,...",

Upvotes: 1

Sascha Galley
Sascha Galley

Reputation: 16091

You can set your own formats, have a look at the documentation: TinyMCE formats. In your case it would be something like:

tinyMCE.init({
    ...
    formats : {
        bold : {inline : 'b'},
        italic : {inline : 'i'},
        underline : {inline : 'u'},
    }
});

I have not tested it but this should lead you into the right direction.

Upvotes: 1

Related Questions