Editing the raw HTML inside a TinyMCE control
Asked Answered
P

2

9

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?

Pewee answered 20/2, 2010 at 12:31 Comment(0)
P
13

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

Pontianak answered 20/2, 2010 at 12:59 Comment(0)
A
4

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'
    ...
}
Alabama answered 8/12, 2020 at 21:33 Comment(2)
Nothing like waking up in the morning to see an answer to a question you asked over a decade ago :)Pewee
The question is still relevant and the answer may help others :). I spent half an hour digging this up, thought it might save that effort for the next guy/gal!Alabama

© 2022 - 2024 — McMap. All rights reserved.