@@ -33,21 +33,21 @@ pip install django-editorjs-fields --upgrade
33
33
python manage.py collectstatic # upgrade js and css files
34
34
```
35
35
36
-
37
36
## Usage
38
37
39
38
Add code in your model
40
39
41
40
``` python
42
41
# models.py
43
42
from 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
45
45
46
46
47
47
class Post (models .Model ):
48
48
body_default = models.TextField()
49
49
body_editorjs = EditorJsJSONField() # Django >= 3.1
50
- body_editorjs_text = EditorJsTextField() # Django <= 3.0
50
+ body_editorjs_text = EditorJsTextField()
51
51
52
52
```
53
53
@@ -65,7 +65,7 @@ class Post(models.Model):
65
65
<title >Document</title >
66
66
</head >
67
67
<body >
68
- {% load editorjs %}
68
+ {% load editorjs %}
69
69
{{ post.body_default }}
70
70
{{ post.body_editorjs | editorjs}}
71
71
{{ post.body_editorjs_text | editorjs}}
@@ -165,7 +165,7 @@ EDITORJS_DEFAULT_CONFIG_TOOLS = {
165
165
' Image' : {
166
166
' class' : ' ImageTool' ,
167
167
' inlineToolbar' : True ,
168
- " config" : {" endpoints" : {" byFile" : " /editorjs/image_upload/ " }},
168
+ " config" : {" endpoints" : {" byFile" : reverse_lazy( ' editorjs_image_upload ' ) }},
169
169
},
170
170
' Header' : {
171
171
' class' : ' Header' ,
@@ -185,7 +185,12 @@ EDITORJS_DEFAULT_CONFIG_TOOLS = {
185
185
' Embed' : {' class' : ' Embed' },
186
186
' Delimiter' : {' class' : ' Delimiter' },
187
187
' Warning' : {' class' : ' Warning' , ' inlineToolbar' : True },
188
- ' LinkTool' : {' class' : ' LinkTool' },
188
+ ' LinkTool' : {
189
+ ' class' : ' LinkTool' ,
190
+ ' config' : {
191
+ ' endpoint' : reverse_lazy(' editorjs_linktool' ),
192
+ }
193
+ },
189
194
' Marker' : {' class' : ' Marker' , ' inlineToolbar' : True },
190
195
' Table' : {' class' : ' Table' , ' inlineToolbar' : True },
191
196
}
@@ -283,15 +288,15 @@ plugin use css property [prefers-color-scheme](https://developer.mozilla.org/en-
283
288
The application can be configured by editing the project's ` settings.py `
284
289
file.
285
290
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 ` |
293
298
| ` 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 ` |
295
300
296
301
For ` EDITORJS_IMAGE_NAME ` was used ` from secrets import token_urlsafe `
297
302
0 commit comments