Skip to content
Browse files

Allow selecting a toolbar type when constructing the ck-editor widget.

ck-editor supplies two configurations, Basic and Full, but it is also possible to write your own configuration, as described in http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Toolbar
  • Loading branch information...
1 parent b587ab3 commit e267a27ceb23dd709714880657511736513181a4 @buchuki committed
Showing with 7 additions and 2 deletions.
  1. +7 −2 ckeditor/widgets.py
View
9 ckeditor/widgets.py
@@ -20,6 +20,11 @@ class Media:
)
except AttributeError:
raise ImproperlyConfigured("django-ckeditor requires CKEDITOR_MEDIA_PREFIX setting.")
+
+ def __init__(self, toolbar="Full", *args, **kwargs):
+ '''You can set the toolbar to Basic or Full.'''
+ self.toolbar = toolbar
+ super(CKEditorWidget, self).__init__(*args, **kwargs)
def render(self, name, value, attrs={}):
if value is None: value = ''
@@ -29,7 +34,7 @@ def render(self, name, value, attrs={}):
CKEDITOR.replace("%s",
{
skin: "v2",
- toolbar : "Full",
+ toolbar : "%s",
height:"291",
width:"618",
filebrowserUploadUrl : "%s",
@@ -38,4 +43,4 @@ def render(self, name, value, attrs={}):
filebrowserWindowHeight : '747'
}
);
- </script>''' % (flatatt(final_attrs), conditional_escape(force_unicode(value)), final_attrs['id'], reverse('ckeditor_upload'), reverse('ckeditor_browse')))
+ </script>''' % (flatatt(final_attrs), conditional_escape(force_unicode(value)), final_attrs['id'], self.toolbar, reverse('ckeditor_upload'), reverse('ckeditor_browse')))

0 comments on commit e267a27

Please sign in to comment.
Something went wrong with that request. Please try again.