Skip to content

Commit

Permalink
Update CKEditor 5 package, add type annotations, and improve error ha…
Browse files Browse the repository at this point in the history
…ndling
  • Loading branch information
hvlads committed Jan 6, 2024
1 parent aa374b9 commit fcd4202
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 15 deletions.
5 changes: 3 additions & 2 deletions example/blog/articles/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Meta:
fields = ("author", "text")
widgets = {
"text": CKEditor5Widget(
attrs={"class": "django_ckeditor_5"}, config_name="comment"
)
attrs={"class": "django_ckeditor_5"},
config_name="comment",
),
}
4 changes: 3 additions & 1 deletion example/blog/articles/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ class Comment(models.Model):
author = models.CharField(max_length=250)
text = CKEditor5Field("Text")
article = models.ForeignKey(
Article, related_name="comments", on_delete=models.CASCADE
Article,
related_name="comments",
on_delete=models.CASCADE,
)

class Meta:
Expand Down
16 changes: 8 additions & 8 deletions example/blog/blog/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(BASE_DIR, "db.sqlite3"),
}
},
}

# Password validation
Expand Down Expand Up @@ -272,19 +272,19 @@
"title": "Heading 3",
"class": "ck-heading_heading3",
},
]
],
},
"list": {
"properties": {
"styles": True,
"startIndex": True,
"reversed": True,
}
},
},
"htmlSupport": {
"allow": [
{"name": "/.*/", "attributes": True, "classes": True, "styles": True}
]
{"name": "/.*/", "attributes": True, "classes": True, "styles": True},
],
},
"mention": {
"feeds": [
Expand All @@ -299,14 +299,14 @@
"@Ted",
],
"minimumCharacters": 1,
}
]
},
],
},
"style": {
"definitions": [
{"name": "Article category", "element": "h3", "classes": ["category"]},
{"name": "Info box", "element": "p", "classes": ["info-box"]},
]
],
},
},
}
Expand Down
5 changes: 3 additions & 2 deletions example/blog/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ def main():
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
error_msg = (
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
)
raise ImportError(error_msg) from exc
execute_from_command_line(sys.argv)


Expand Down
6 changes: 4 additions & 2 deletions example/blog/tests/test_upload_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
def test_upload_file(admin_client, file):
with file as upload:
response = admin_client.post(
reverse("ck_editor_5_upload_file"), {"upload": upload}
reverse("ck_editor_5_upload_file"),
{"upload": upload},
)
assert response.status_code == 200
assert "url" in response.json()
Expand All @@ -18,7 +19,8 @@ def test_upload_file(admin_client, file):
def test_upload_file_to_google_cloud(admin_client, file, settings):
with file as upload:
response = admin_client.post(
reverse("ck_editor_5_upload_file"), {"upload": upload}
reverse("ck_editor_5_upload_file"),
{"upload": upload},
)
assert response.status_code == 200
assert "url" in response.json()

0 comments on commit fcd4202

Please sign in to comment.