@@ -33,21 +33,21 @@ pip install django-editorjs-fields --upgrade
3333python manage.py collectstatic # upgrade js and css files
3434```
3535
36-
3736## Usage
3837
3938Add code in your model
4039
4140``` python
4241# models.py
4342from django.db import models
44- from django_editorjs_fields import EditorJsJSONField, EditorJsTextField
43+ from django_editorjs_fields import EditorJsJSONFiel # Django >= 3.1
44+ from django_editorjs_fields import EditorJsTextField
4545
4646
4747class Post (models .Model ):
4848 body_default = models.TextField()
4949 body_editorjs = EditorJsJSONField() # Django >= 3.1
50- body_editorjs_text = EditorJsTextField() # Django <= 3.0
50+ body_editorjs_text = EditorJsTextField()
5151
5252```
5353
@@ -65,7 +65,7 @@ class Post(models.Model):
6565 <title >Document</title >
6666 </head >
6767 <body >
68- {% load editorjs %}
68+ {% load editorjs %}
6969 {{ post.body_default }}
7070 {{ post.body_editorjs | editorjs}}
7171 {{ post.body_editorjs_text | editorjs}}
@@ -165,7 +165,7 @@ EDITORJS_DEFAULT_CONFIG_TOOLS = {
165165 ' Image' : {
166166 ' class' : ' ImageTool' ,
167167 ' inlineToolbar' : True ,
168- " config" : {" endpoints" : {" byFile" : " /editorjs/image_upload/ " }},
168+ " config" : {" endpoints" : {" byFile" : reverse_lazy( ' editorjs_image_upload ' ) }},
169169 },
170170 ' Header' : {
171171 ' class' : ' Header' ,
@@ -185,7 +185,12 @@ EDITORJS_DEFAULT_CONFIG_TOOLS = {
185185 ' Embed' : {' class' : ' Embed' },
186186 ' Delimiter' : {' class' : ' Delimiter' },
187187 ' Warning' : {' class' : ' Warning' , ' inlineToolbar' : True },
188- ' LinkTool' : {' class' : ' LinkTool' },
188+ ' LinkTool' : {
189+ ' class' : ' LinkTool' ,
190+ ' config' : {
191+ ' endpoint' : reverse_lazy(' editorjs_linktool' ),
192+ }
193+ },
189194 ' Marker' : {' class' : ' Marker' , ' inlineToolbar' : True },
190195 ' Table' : {' class' : ' Table' , ' inlineToolbar' : True },
191196}
@@ -283,15 +288,15 @@ plugin use css property [prefers-color-scheme](https://developer.mozilla.org/en-
283288The application can be configured by editing the project's ` settings.py `
284289file.
285290
286- | Key | Description | Default | Type |
287- | --------------------------------- | ---------------------------------------------------------------------- | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
288- | ` EDITORJS_DEFAULT_PLUGINS ` | List of plugins names Editor.js from npm | [ See above] ( #plugins ) | ` list[str] ` , ` tuple[str] ` |
289- | ` EDITORJS_DEFAULT_CONFIG_TOOLS ` | Map of Tools to use | [ See above] ( #plugins ) | ` dict[str, dict] ` |
290- | ` EDITORJS_IMAGE_UPLOAD_PATH ` | Path uploads images | ` uploads/images/ ` | ` str ` |
291- | ` EDITORJS_IMAGE_UPLOAD_PATH_DATE ` | Subdirectories | ` %Y/%m/ ` | ` str ` |
292- | ` EDITORJS_IMAGE_NAME_ORIGINAL ` | To use the original name of the image file? | ` False ` | ` bool ` |
291+ | Key | Description | Default | Type |
292+ | --------------------------------- | ---------------------------------------------------------------------- | --------------------- | ------------------------------------------------------------------------------------------------------------------------ |
293+ | ` EDITORJS_DEFAULT_PLUGINS ` | List of plugins names Editor.js from npm | [ See above] ( #plugins ) | ` list[str] ` , ` tuple[str] ` |
294+ | ` EDITORJS_DEFAULT_CONFIG_TOOLS ` | Map of Tools to use | [ See above] ( #plugins ) | ` dict[str, dict] ` |
295+ | ` EDITORJS_IMAGE_UPLOAD_PATH ` | Path uploads images | ` uploads/images/ ` | ` str ` |
296+ | ` EDITORJS_IMAGE_UPLOAD_PATH_DATE ` | Subdirectories | ` %Y/%m/ ` | ` str ` |
297+ | ` EDITORJS_IMAGE_NAME_ORIGINAL ` | To use the original name of the image file? | ` False ` | ` bool ` |
293298| ` EDITORJS_IMAGE_NAME ` | Image file name. Ignored when ` EDITORJS_IMAGE_NAME_ORIGINAL ` is ` True ` | ` token_urlsafe(8) ` | ` callable(filename: str, file: InMemoryUploadedFile) ` ([ docs] ( https://docs.djangoproject.com/en/3.0/ref/files/uploads/ ) ) |
294- | ` EDITORJS_VERSION ` | Version Editor.js | ` 2.22.3 ` | ` str ` |
299+ | ` EDITORJS_VERSION ` | Version Editor.js | ` 2.22.3 ` | ` str ` |
295300
296301For ` EDITORJS_IMAGE_NAME ` was used ` from secrets import token_urlsafe `
297302
0 commit comments