From 65d43a324962ce97c510ef524593cd04f87d2cec Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Wed, 4 Jun 2014 16:31:04 +0200 Subject: [PATCH] Better handling of CMS/HTMLField toolbar selection --- djangocms_text_ckeditor/widgets.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/djangocms_text_ckeditor/widgets.py b/djangocms_text_ckeditor/widgets.py index 5e27973..25974e2 100644 --- a/djangocms_text_ckeditor/widgets.py +++ b/djangocms_text_ckeditor/widgets.py @@ -45,11 +45,17 @@ class TextEditorWidget(Textarea): def render_additions(self, name, value, attrs=None): language = get_language().split('-')[0] configuration = deepcopy(self.configuration) - if not configuration.get('toolbar', False): - if self.placeholder: - configuration['toolbar'] = 'CMS' - else: - configuration['toolbar'] = 'HTMLField' + # We are in a plugin -> we use toolbar_CMS or a custom defined toolbar + if self.placeholder: + configuration['toolbar'] = configuration.get('toolbar', 'CMS') + # We are not in a plugin but toolbar is set to CMS (the default) -> + # we force the use of toolbar_HTMLField + elif configuration.get('toolbar', False) == 'CMS': + configuration['toolbar'] = 'HTMLField' + # Toolbar is not set or set to a custom value -> we use the custom + # value or fallback to HTMLField + else: + configuration['toolbar'] = configuration.get('toolbar', 'HTMLField') context = { 'ckeditor_class': self.ckeditor_class, 'name': name,