Skip to content

Commit 395fe70

Browse files
committed
Update Readme
1 parent c9dfa1a commit 395fe70

File tree

1 file changed

+54
-3
lines changed

1 file changed

+54
-3
lines changed

README.md

+54-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Add code in your model
3131
```python
3232
# models.py
3333
from django.db import models
34-
from django_editorjs_fields import EditorJsJSONField, EditorJsTextField # import
34+
from django_editorjs_fields import EditorJsJSONField, EditorJsTextField
3535

3636

3737
class Post(models.Model):
@@ -46,7 +46,7 @@ Or add custom Editor.js plugins and configs ([List plugins](https://github.com/e
4646
**django-editorjs-fields** includes this list of Editor.js plugins by default:
4747

4848
```python
49-
[
49+
DEFAULT_PLUGINS = [
5050
'@editorjs/paragraph',
5151
'@editorjs/image',
5252
'@editorjs/header',
@@ -63,12 +63,47 @@ Or add custom Editor.js plugins and configs ([List plugins](https://github.com/e
6363
'@editorjs/marker',
6464
'@editorjs/table',
6565
]
66+
67+
DEFAULT_CONFIG_PLUGINS = {
68+
'@editorjs/image': {
69+
'Image': {
70+
'class': 'ImageTool',
71+
'inlineToolbar': True,
72+
"config": {"endpoints": {"byFile": "/editorjs/image_upload/"}},
73+
}
74+
},
75+
'@editorjs/header': {
76+
'Header': {
77+
'class': 'Header',
78+
'inlineToolbar': True,
79+
'config': {
80+
'placeholder': 'Enter a header',
81+
'levels': [2, 3, 4],
82+
'defaultLevel': 2,
83+
},
84+
}
85+
},
86+
'@editorjs/checklist': {'Checklist': {'class': 'Checklist', 'inlineToolbar': True}},
87+
'@editorjs/list': {'List': {'class': 'List', 'inlineToolbar': True}},
88+
'@editorjs/quote': {'Quote': {'class': 'Quote', 'inlineToolbar': True}},
89+
'@editorjs/raw': {'Raw': {'class': 'RawTool'}},
90+
'@editorjs/code': {'Code': {'class': 'CodeTool'}},
91+
'@editorjs/inline-code': {'InlineCode': {'class': 'InlineCode'}},
92+
'@editorjs/embed': {'Embed': {'class': 'Embed'}},
93+
'@editorjs/delimiter': {'Delimiter': {'class': 'Delimiter'}},
94+
'@editorjs/warning': {'Warning': {'class': 'Warning', 'inlineToolbar': True}},
95+
'@editorjs/link': {'LinkTool': {'class': 'LinkTool'}},
96+
'@editorjs/marker': {'Marker': {'class': 'Marker', 'inlineToolbar': True}},
97+
'@editorjs/table': {'Table': {'class': 'Table', 'inlineToolbar': True}},
98+
}
6699
```
67100

101+
Example in models.py
102+
68103
```python
69104
# models.py
70105
from django.db import models
71-
from django_editorjs_fields import EditorJsJSONField, EditorJsTextField
106+
from django_editorjs_fields import EditorJsJSONField
72107

73108

74109
class Post(models.Model):
@@ -98,6 +133,21 @@ class Post(models.Model):
98133

99134
```
100135

136+
`EditorJsJSONField` accepts all the arguments of `JSONField` class.
137+
138+
`EditorJsTextField` accepts all the arguments of `TextField` class.
139+
140+
Additionally, it includes arguments such as:
141+
142+
| Args | Description | Default |
143+
| --------------- | ------------------------------------------------------------------------------------------------- | ------------------------ |
144+
| `plugins` | List plugins Editor.js | `DEFAULT_PLUGINS` |
145+
| `tools` | Set config `tools` for Editor.js [See docs](https://editorjs.io/configuration#passing-saved-data) | `DEFAULT_CONFIG_PLUGINS` |
146+
| `use_editor_js` | Enables or disables the Editor.js plugin for the field | `True` |
147+
148+
149+
### Image uploads
150+
101151
If you want to upload images to the editor then add `django_editorjs_fields.urls` to `urls.py` for your project with `DEBUG=True`:
102152

103153
```python
@@ -141,6 +191,7 @@ file.
141191
| `EDITORJS_IMAGE_NAME_ORIGINAL` | To use the original name of the image file? | `False` |
142192
| `EDITORJS_IMAGE_NAME_POSTFIX` | Image file name postfix. Ignored when `EDITORJS_IMAGE_NAME_ORIGINAL` is `True` | `token_urlsafe(5) # from secrets import token_urlsafe` |
143193
| `EDITORJS_IMAGE_NAME` | Image file name postfix. Ignored when `EDITORJS_IMAGE_NAME_ORIGINAL` is `False` | `token_urlsafe(8) # from secrets import token_urlsafe` |
194+
| `EDITORJS_VERSION` | Version Editor.js | `2.19.0` |
144195

145196
## Support and updates
146197

0 commit comments

Comments
 (0)