What is different about ckeditor 5 compared to ckeditor 4?


django-ckeditor-5 supported plugins



Yüklə 208,53 Kb.
səhifə3/6
tarix26.10.2023
ölçüsü208,53 Kb.
#161566
1   2   3   4   5   6
CKEditor 5

django-ckeditor-5 supported plugins.
django-ckeditor-5 supports the following plugin. You can also add new plugins but we will discuss this upcoming article.
Essentials, UploadAdapter, Autoformat, Bold, Italic, Underline, Strikethrough, Code, Subscript, Superscript, BlockQuote, Heading, Image, ImageCaption, ImageStyle, ImageToolbar, ImageUpload, ImageInsert, ImageResize, Link, List, Paragraph, Alignment, Font, PasteFromOffice, SimpleUploadAdapter, MediaEmbed, RemoveFormat, Table, TableToolbar, TableProperties, TableCellProperties, Indent, IndentBlock, Highlight, TodoList, ListProperties, SourceEditing, GeneralHtmlSupport
CustomStorage in django-ckeditor-5
By default, django-ckeditor-5 saves media files in the media folder but we can override this setting.
# settings.py

# CKEDITOR_5_FILE_STORAGE = "path_to_storage.CustomStorage" # optional

CKEDITOR_5_FILE_STORAGE = "yourapp.storage.CustomStorage"
Create a new file storage.py in your app and add the following code to save media files in the media/uploads/images folder
# storage.py

import os
from urllib.parse import urljoin

from django.conf import settings
from django.core.files.storage import FileSystemStorage


class CustomStorage(FileSystemStorage):
"""Custom storage for django_ckeditor_5 images."""

location = os.path.join(settings.MEDIA_ROOT, "uploads/images/")


base_url = urljoin(settings.MEDIA_URL, "uploads/images/")
Add django-ckeditor-5 in your views and templates.
# forms.py

from django import forms

from django_ckeditor_5.widgets import CKEditor5Widget
from .models import Article

class ArticleForm(forms.ModelForm):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# it is required to set it False,
# otherwise it will throw error in console
self.fields["text"].required = False

class Meta:
model = Article
fields = '__all__'
# you can also use CKEditor5Widget in your forms.
# we don't need it. because we have model form
# widgets = {
# "text": CKEditor5Widget(
# attrs={"class": "django_ckeditor_5"}, config_name="extends"
# )
# }
# views.py


Yüklə 208,53 Kb.

Dostları ilə paylaş:
1   2   3   4   5   6




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©www.azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin