From 1cc44fe0c759ff78264ea5850d7301c71af8f18e Mon Sep 17 00:00:00 2001 From: bkfox Date: Tue, 22 Sep 2020 02:14:51 +0200 Subject: [PATCH] ckeditor --- aircox/models/page.py | 4 ++-- instance/sample_settings.py | 42 ++++++++++++++++++++++++++++--------- instance/urls.py | 1 + 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/aircox/models/page.py b/aircox/models/page.py index ab2f32a..6a51195 100644 --- a/aircox/models/page.py +++ b/aircox/models/page.py @@ -11,7 +11,7 @@ from django.utils.translation import gettext_lazy as _ from django.utils.functional import cached_property import bleach -from ckeditor.fields import RichTextField +from ckeditor_uploader.fields import RichTextUploadingField from filer.fields.image import FilerImageField from model_utils.managers import InheritanceQuerySet @@ -76,7 +76,7 @@ class BasePage(models.Model): on_delete=models.SET_NULL, verbose_name=_('cover'), null=True, blank=True, ) - content = RichTextField( + content = RichTextUploadingField( _('content'), blank=True, null=True, ) diff --git a/instance/sample_settings.py b/instance/sample_settings.py index 9a64aa7..1141b39 100755 --- a/instance/sample_settings.py +++ b/instance/sample_settings.py @@ -122,19 +122,40 @@ except: #-- django-CKEditor CKEDITOR_CONFIGS = { "default": { - "toolbar": "Custom", "format_tags": "h1;h2;h3;p;pre", - "toolbar_Custom": [[ - "Format", "RemoveFormat", "-", - "Bold", "Italic", "Subscript", "Superscript", "-", - "NumberedList", "BulletedList", "-", - "Anchor", "Link", "Unlink", "-", - "HorizontalRule", "SpecialChar", "-", - "Source", - ]], + # 'skin': 'office2013', + "toolbar_Custom": [ + {'name': 'editing', 'items': ['Undo', 'Redo', '-', 'Find', 'Replace', '-', 'Source']}, + {'name': 'basicstyles', + 'items': ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat']}, + {'name': 'paragraph', + 'items': ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-', + 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-']}, + '/', + {'name': 'links', 'items': ['Link', 'Unlink', 'Anchor']}, + {'name': 'insert', + 'items': ['Image', 'Table', 'HorizontalRule', 'SpecialChar', 'PageBreak', 'Iframe']}, + {'name': 'styles', 'items': ['Styles', 'Format', 'Font', 'FontSize']}, + {'name': 'colors', 'items': ['TextColor', 'BGColor']}, + '/', # put this to force next toolbar on new line + ], + 'toolbar': 'Custom', + 'extraPlugins': ','.join([ + 'uploadimage', + 'div', + 'autolink', + 'autoembed', 'embedsemantic', 'embed', + 'iframe', 'iframedialog', + 'autogrow', + 'widget', + 'lineutils', + 'dialog', + 'dialogui', + 'elementspath' + ]), }, } -CKEDITOR_CONFIGS["richtext-plugin"] = CKEDITOR_CONFIGS["default"] +CKEDITOR_UPLOAD_PATH = 'uploads/' #-- easy_thumbnails @@ -158,6 +179,7 @@ INSTALLED_APPS = ( 'django_filters', "content_editor", "ckeditor", + "ckeditor_uploader", 'easy_thumbnails', 'filer', 'taggit', diff --git a/instance/urls.py b/instance/urls.py index 2bbddd9..806e88d 100755 --- a/instance/urls.py +++ b/instance/urls.py @@ -26,6 +26,7 @@ import aircox_streamer.urls try: urlpatterns = aircox.urls.urls + [ path('admin/', admin.site.urls), + path('ckeditor/', include('ckeditor_uploader.urls')), path('filer/', include('filer.urls')), ]