Adamo
Adamo

Reputation: 596

TinyMce - it is possible to disable Rich Text?

In my app I have TinyMce plugin. Now I need to at any time switch with richtext to plaintext. In this example I suspect that it can be done.

The only question is how? I saw a solution with the addition selectbox and js functions. Is there no mechanism built-in TinyMCE?

Upvotes: 1

Views: 1528

Answers (2)

Thariama
Thariama

Reputation: 50832

All you have to do is shutdown tinymce and show the tinymce route element (the div for which you have created the tinymce editor). The textarea is editable and shows the full HTML-Contents of the Editor.

To shut down your tinymce use

tinymce.get('your_editor_id').remove();

To make the underlying textarea visisble:

document.getElementById('your_editor_id').setAttribute('style', visibility:visible; display:block;);

or using jQuery

$('#your_editor_id').css('visibility', 'visible').css('display', 'block');

Update:

This works with Tinymce 4. Use the setup parameter

setup: function(ed)
{
  ed.on('click', function(e){
    tinymce.execCommand('mceToggleEditor', false, 'your editor_id');
  });
}

Here is a working tinymce fiddle: http://fiddle.tinymce.com/Fnfaab

Upvotes: 1

Christoffer Bubach
Christoffer Bubach

Reputation: 1686

You can use the tinymce API and call the Formatter class like this:

tinymce.activeEditor.formatter.remove();  // no format name==all formats

Upvotes: 1

Related Questions