Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Editing the raw HTML inside a TinyMCE control

I have a Django website in which I use django-tinymce to edit HTML fields with a TinyMCE control.

TinyMCE practically gives me a WYSIWYG way to edit HTML. My question is, can I get access to edit the underlying HTML directly? I was thinking, maybe there's some button I can enbale which will toggle between "WYSIWYG mode" and "raw html mode" in TinyMCE. Is there one? If not, is there any elegant way to edit the HTML?

like image 475
Ram Rachum Avatar asked Feb 20 '10 12:02

Ram Rachum


2 Answers

Simply add the code button to one of the toolbars, e.g. with this configuration for django-tinymce:

TINYMCE_DEFAULT_CONFIG = {
    # your other configuration
    'theme_advanced_buttons3_add': 'code',
}

Here's a list of buttons that are available with the advanced TinyMCE theme

like image 71
Benjamin Wohlwend Avatar answered Sep 20 '22 00:09

Benjamin Wohlwend


django-tinymce version 3 uses TinyMCE version 5 that requires enabling the code button plugin and adding the code button to toolbar:

TINYMCE_DEFAULT_CONFIG = {
    ...
    'plugins': 'code', # along with other plugins, e.g. 'link lists code'
    'toolbar': 'code', # along with other buttons, e.g. 'bold italic | code'
    ...
}
like image 33
mrts Avatar answered Sep 23 '22 00:09

mrts