dj-editor-js 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. dj_editor_js-0.1.0/LICENSE +21 -0
  2. dj_editor_js-0.1.0/MANIFEST.in +4 -0
  3. dj_editor_js-0.1.0/PKG-INFO +294 -0
  4. dj_editor_js-0.1.0/README.md +246 -0
  5. dj_editor_js-0.1.0/dj_editor_js.egg-info/PKG-INFO +294 -0
  6. dj_editor_js-0.1.0/dj_editor_js.egg-info/SOURCES.txt +34 -0
  7. dj_editor_js-0.1.0/dj_editor_js.egg-info/dependency_links.txt +1 -0
  8. dj_editor_js-0.1.0/dj_editor_js.egg-info/requires.txt +1 -0
  9. dj_editor_js-0.1.0/dj_editor_js.egg-info/top_level.txt +4 -0
  10. dj_editor_js-0.1.0/editor_js/__init__.py +0 -0
  11. dj_editor_js-0.1.0/editor_js/apps.py +6 -0
  12. dj_editor_js-0.1.0/editor_js/config.py +89 -0
  13. dj_editor_js-0.1.0/editor_js/fields.py +125 -0
  14. dj_editor_js-0.1.0/editor_js/migrations/__init__.py +0 -0
  15. dj_editor_js-0.1.0/editor_js/models.py +3 -0
  16. dj_editor_js-0.1.0/editor_js/renderers.py +140 -0
  17. dj_editor_js-0.1.0/editor_js/static/editor_js/css/editor_js_admin.css +266 -0
  18. dj_editor_js-0.1.0/editor_js/static/editor_js/js/editor_js_iframe.js +164 -0
  19. dj_editor_js-0.1.0/editor_js/static/editor_js/js/editor_js_widget.js +125 -0
  20. dj_editor_js-0.1.0/editor_js/static/editor_js/js/plugins/button-tool.js +168 -0
  21. dj_editor_js-0.1.0/editor_js/static/editor_js/js/plugins/divider-tool.js +19 -0
  22. dj_editor_js-0.1.0/editor_js/templates/editor_js/admin/widgets/editor_js_widget.html +43 -0
  23. dj_editor_js-0.1.0/editor_js/templates/editor_js/editor_js_iframe.html +42 -0
  24. dj_editor_js-0.1.0/editor_js/templatetags/editor_js_filters.py +37 -0
  25. dj_editor_js-0.1.0/editor_js/urls.py +7 -0
  26. dj_editor_js-0.1.0/editor_js/views.py +53 -0
  27. dj_editor_js-0.1.0/editor_js/widgets.py +22 -0
  28. dj_editor_js-0.1.0/pyproject.toml +43 -0
  29. dj_editor_js-0.1.0/setup.cfg +4 -0
  30. dj_editor_js-0.1.0/tests/test_config.py +46 -0
  31. dj_editor_js-0.1.0/tests/test_fields.py +343 -0
  32. dj_editor_js-0.1.0/tests/test_filters.py +70 -0
  33. dj_editor_js-0.1.0/tests/test_renderers.py +210 -0
  34. dj_editor_js-0.1.0/tests/test_settings.py +31 -0
  35. dj_editor_js-0.1.0/tests/test_views.py +76 -0
  36. dj_editor_js-0.1.0/tests/test_widgets.py +56 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Otto.srl
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,4 @@
1
+ graft editor_js/templates
2
+ graft editor_js/static
3
+ include LICENSE
4
+ include README.md
@@ -0,0 +1,294 @@
1
+ Metadata-Version: 2.4
2
+ Name: dj-editor-js
3
+ Version: 0.1.0
4
+ Summary: A Django library to integrate the Editor.js editor with image handling and custom tools.
5
+ Author-email: Otto <opensource@otto.srl>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2025 Otto.srl
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+ Project-URL: Homepage, https://github.com/otto-torino/django-editor-js
28
+ Project-URL: Repository, https://github.com/otto-torino/django-editor-js
29
+ Project-URL: Bug Tracker, https://github.com/otto-torino/django-editor-js/issues
30
+ Classifier: Environment :: Web Environment
31
+ Classifier: Framework :: Django
32
+ Classifier: Framework :: Django :: 4.2
33
+ Classifier: Framework :: Django :: 5.0
34
+ Classifier: Intended Audience :: Developers
35
+ Classifier: License :: OSI Approved :: MIT License
36
+ Classifier: Operating System :: OS Independent
37
+ Classifier: Programming Language :: Python
38
+ Classifier: Programming Language :: Python :: 3
39
+ Classifier: Programming Language :: Python :: 3.8
40
+ Classifier: Programming Language :: Python :: 3.9
41
+ Classifier: Programming Language :: Python :: 3.10
42
+ Classifier: Programming Language :: Python :: 3.11
43
+ Requires-Python: >=3.8
44
+ Description-Content-Type: text/markdown
45
+ License-File: LICENSE
46
+ Requires-Dist: Django>=3.2
47
+ Dynamic: license-file
48
+
49
+ # Django Editor.js
50
+
51
+ [![PyPI version](https://badge.fury.io/py/django-editor-js.svg)](https://badge.fury.io/py/django-editor-js)
52
+ [![Build Status](https://github.com/otto-torino/django-editor-js/actions/workflows/ci.yml/badge.svg)](https://github.com/otto-torino/django-editor-js/actions/workflows/ci.yml)
53
+ [![Coverage Status](https://codecov.io/gh/otto-torino/django-editor-js/graph/badge.svg)](https://codecov.io/gh/otto-torino/django-editor-js)
54
+
55
+ A modern, extensible, and self-contained Django app for integrating the block-style [Editor.js](https://editorjs.io/) into your projects.
56
+
57
+ This library provides a custom `EditorJSField` for your models and a sandboxed iframe widget for the Django admin, ensuring a clean, conflict-free editing experience. It comes with powerful features like automatic image management, dynamic tool configuration, and a customizable HTML renderer.
58
+
59
+ ## Key Features
60
+
61
+ - **Iframe Sandboxing**: The editor is rendered within an `iframe` to prevent CSS and JavaScript conflicts with the Django admin or your site's styles.
62
+ - **Dynamic Tool Configuration**: Configure all Editor.js tools directly from your project's `settings.py`. Add, remove, or override the default toolset, including your own custom-built plugins.
63
+ - **Automatic Image Management**: Integrated image upload endpoint with configurable storage. Automatically deletes unused images from storage when a model instance is updated or deleted.
64
+ - **Extensible HTML Renderer**: A server-side Python class converts the saved JSON data into clean HTML, with methods for each block type that can be easily extended or overridden.
65
+ - **Built-in Template Filter**: Render your content with a simple `{% load ... %}` and filter call, no need to write your own rendering logic.
66
+ - **Sensible Defaults**: Works out-of-the-box with a rich set of common Editor.js tools.
67
+ - **Admin-Friendly UI**: Features include automatic iframe resizing and a fullscreen editing mode for a better user experience.
68
+
69
+ ---
70
+
71
+ ## Installation
72
+
73
+ 1. Install the package from PyPI:
74
+ ```bash
75
+ pip install django-editor-js
76
+ ```
77
+
78
+ 2. Add `'editor_js'` to your `INSTALLED_APPS` in `settings.py`:
79
+ ```python
80
+ # settings.py
81
+ INSTALLED_APPS = [
82
+ # ...
83
+ 'django.contrib.admin',
84
+ 'django.contrib.auth',
85
+ # ...
86
+ 'editor_js',
87
+ ]
88
+ ```
89
+
90
+ ---
91
+
92
+ ## Configuration
93
+
94
+ 1. **Include the URLs**: Add the library's URLs to your project's `urls.py`. These are required for the iframe and the image upload endpoint.
95
+
96
+ ```python
97
+ # your_project/urls.py
98
+ from django.urls import path, include
99
+
100
+ urlpatterns = [
101
+ path('admin/', admin.site.urls),
102
+ path('editor-js/', include('editor_js.urls')),
103
+ # ... your other urls
104
+ ]
105
+ ```
106
+
107
+ 2. **Configure Settings (Optional)**: You can customize the library by adding an `EDITOR_JS` dictionary to your `settings.py`. If you don't provide this, the library will use its sensible defaults.
108
+
109
+ ```python
110
+ # settings.py
111
+ EDITOR_JS = {
112
+ # Define a custom storage backend for uploaded images.
113
+ "STORAGE_BACKEND": "app.storage.PrivateMediaStorage",
114
+
115
+ # Specify the custom CSS files to be loaded inside the editor's iframe.
116
+ "CSS_FILES": ["my_app/css/style.css", "other_app/css/style.css"],
117
+
118
+ # Specify a custom Python class to render the JSON data to HTML.
119
+ "RENDERER_CLASS": "my_app.renderers.MyCustomRenderer",
120
+
121
+ # Configure the tools available to the editor.
122
+ "TOOLS": {
123
+ # Add a new custom tool
124
+ 'my_custom_tool': {
125
+ 'class': 'MyCustomTool',
126
+ 'script': 'my_app/js/my-custom-tool.js',
127
+ 'static': True, # True if the script is a local static file
128
+ 'config': {
129
+ 'placeholder': 'Enter your custom text...'
130
+ }
131
+ },
132
+ # Remove a default tool
133
+ 'quote': None,
134
+ }
135
+ }
136
+ ```
137
+
138
+ ---
139
+
140
+ ## Usage
141
+
142
+ ### In Your Models
143
+
144
+ Use the `EditorJSField` in your models as you would any other Django model field. It stores the editor's content as JSON.
145
+
146
+ - **To use a custom set of Editor.js tools for a field**, pass a `tools` dictionary to the field.
147
+ - **To use the global (default) tool configuration**, define the field without the `tools` argument.
148
+
149
+ Since EditorJSField inherits from Django's models.JSONField, you can also pass any of its standard attributes, such as `blank=True` or `null=True`.
150
+
151
+ Example:
152
+ ```python
153
+ # my_app/models.py
154
+ from django.db import models
155
+ from editor_js.fields import EditorJSField
156
+
157
+ class Post(models.Model):
158
+ title = models.CharField(max_length=200)
159
+
160
+ # This field will only have Header and List tools
161
+ summary = EditorJSField(tools={
162
+ 'header': {
163
+ 'class': 'Header',
164
+ 'script': 'https://cdn.jsdelivr.net/npm/@editorjs/header@latest',
165
+ },
166
+ 'list': {
167
+ 'class': 'EditorjsList',
168
+ 'script': 'https://cdn.jsdelivr.net/npm/@editorjs/list@latest',
169
+ }
170
+ })
171
+
172
+ # This field will use the default or global tool configuration
173
+ body = EditorJSField()
174
+ # ...
175
+ ```
176
+
177
+ The field will automatically render the iframe widget in the Django admin.
178
+
179
+ ### Rendering Content in Templates
180
+
181
+ The library includes a built-in template filter to easily render your `EditorJSField` data as HTML.
182
+
183
+ 1. **Load the filter** in your template:
184
+ ```django
185
+ {% load editor_js_filters %}
186
+ ```
187
+
188
+ 2. **Apply the filter** to your field's data:
189
+ ```django
190
+ <!-- post_detail.html -->
191
+ {% load editor_js_filters %}
192
+
193
+ <article>
194
+ <h1>{{ post.title }}</h1>
195
+ <div class="content">
196
+ {{ post.body|render_editor_js }}
197
+ </div>
198
+ </article>
199
+ ```
200
+
201
+ The filter will automatically use your custom renderer class if you have specified one in your settings.
202
+
203
+ ---
204
+
205
+ ## Demo Application
206
+
207
+ A fully functional demo application is included to showcase the features of this library. To try it out:
208
+
209
+ **1. Clone the repository:**
210
+ ```bash
211
+ git clone https://github.com/otto-torino/django-editor-js.git
212
+ cd django-editor-js
213
+ ```
214
+
215
+ **2. Run the demo:**
216
+
217
+ - **On Windows:**
218
+ ```cmd
219
+ run_demo.bat
220
+ ```
221
+
222
+ - **On macOS / Linux:**
223
+ ```bash
224
+ ./run_demo.sh
225
+ ```
226
+
227
+ This will set up a minimal Django project, create a database, and start the development server so you can explore the editor in action.
228
+
229
+ ---
230
+
231
+ ## Customization
232
+
233
+ This library is designed to be highly extensible.
234
+
235
+ ### Adding & Removing Tools
236
+
237
+ You can fully control the tools available in the editor via the `EDITOR_JS['TOOLS']` dictionary in `settings.py`.
238
+
239
+ - **To remove a default tool**, set its key to `None`:
240
+ ```python
241
+ "TOOLS": { 'raw': None, 'table': None }
242
+ ```
243
+
244
+ - **To add a new tool**, add a new key with its configuration:
245
+ ```python
246
+ "TOOLS": {
247
+ 'my_checklist': {
248
+ 'class': 'Checklist', # The JS class name
249
+ 'script': '[https://cdn.jsdelivr.net/npm/@editorjs/checklist@latest](https://cdn.jsdelivr.net/npm/@editorjs/checklist@latest)', # URL or static path
250
+ 'static': False, # Is it a local static file?
251
+ }
252
+ }
253
+ ```
254
+
255
+ The library comes with the following default tools: **Header**, **List**, **Quote**, **Table**, **Raw HTML**, **Embed**, **Image**, **Button**, and **Divider**.
256
+
257
+ ### Custom HTML Rendering
258
+
259
+ If you add a custom tool, you'll need to tell Django how to render it.
260
+
261
+ 1. Subclass the provided `EditorJsRenderer` and add a `render_my_tool_name` method.
262
+ 2. Update `settings.py` to point to your new class.
263
+
264
+ ```python
265
+ # my_app/renderers.py
266
+ from editor_js.renderers import EditorJsRenderer
267
+
268
+ class MyCustomRenderer(EditorJsRenderer):
269
+ def render_my_custom_tool(self, data):
270
+ # Logic to convert the tool's data to HTML
271
+ items = data.get('items', [])
272
+ html = "<ul>"
273
+ for item in items:
274
+ checked = 'checked' if item.get('checked') else ''
275
+ text = self.escape(item.get('text', ''))
276
+ html += f'<li><input type="checkbox" {checked} disabled> {text}</li>'
277
+ html += "</ul>"
278
+ return html
279
+
280
+ # settings.py
281
+ EDITOR_JS = {
282
+ "RENDERER_CLASS": "my_app.renderers.MyCustomRenderer",
283
+ # ...
284
+ }
285
+ ```
286
+
287
+ ### Custom Storage & Styling
288
+
289
+ - **Storage**: To use a different storage system (like Amazon S3), set the `STORAGE_BACKEND` setting to the dotted path of your storage class (e.g., `'storages.backends.s3boto3.S3Boto3Storage'`).
290
+ - **Styling**: To match the editor's appearance with your frontend, provide a path to a custom CSS file in the `CSS_FILE` setting. This file will be loaded inside the editor's iframe.
291
+
292
+ ## License
293
+
294
+ This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
@@ -0,0 +1,246 @@
1
+ # Django Editor.js
2
+
3
+ [![PyPI version](https://badge.fury.io/py/django-editor-js.svg)](https://badge.fury.io/py/django-editor-js)
4
+ [![Build Status](https://github.com/otto-torino/django-editor-js/actions/workflows/ci.yml/badge.svg)](https://github.com/otto-torino/django-editor-js/actions/workflows/ci.yml)
5
+ [![Coverage Status](https://codecov.io/gh/otto-torino/django-editor-js/graph/badge.svg)](https://codecov.io/gh/otto-torino/django-editor-js)
6
+
7
+ A modern, extensible, and self-contained Django app for integrating the block-style [Editor.js](https://editorjs.io/) into your projects.
8
+
9
+ This library provides a custom `EditorJSField` for your models and a sandboxed iframe widget for the Django admin, ensuring a clean, conflict-free editing experience. It comes with powerful features like automatic image management, dynamic tool configuration, and a customizable HTML renderer.
10
+
11
+ ## Key Features
12
+
13
+ - **Iframe Sandboxing**: The editor is rendered within an `iframe` to prevent CSS and JavaScript conflicts with the Django admin or your site's styles.
14
+ - **Dynamic Tool Configuration**: Configure all Editor.js tools directly from your project's `settings.py`. Add, remove, or override the default toolset, including your own custom-built plugins.
15
+ - **Automatic Image Management**: Integrated image upload endpoint with configurable storage. Automatically deletes unused images from storage when a model instance is updated or deleted.
16
+ - **Extensible HTML Renderer**: A server-side Python class converts the saved JSON data into clean HTML, with methods for each block type that can be easily extended or overridden.
17
+ - **Built-in Template Filter**: Render your content with a simple `{% load ... %}` and filter call, no need to write your own rendering logic.
18
+ - **Sensible Defaults**: Works out-of-the-box with a rich set of common Editor.js tools.
19
+ - **Admin-Friendly UI**: Features include automatic iframe resizing and a fullscreen editing mode for a better user experience.
20
+
21
+ ---
22
+
23
+ ## Installation
24
+
25
+ 1. Install the package from PyPI:
26
+ ```bash
27
+ pip install django-editor-js
28
+ ```
29
+
30
+ 2. Add `'editor_js'` to your `INSTALLED_APPS` in `settings.py`:
31
+ ```python
32
+ # settings.py
33
+ INSTALLED_APPS = [
34
+ # ...
35
+ 'django.contrib.admin',
36
+ 'django.contrib.auth',
37
+ # ...
38
+ 'editor_js',
39
+ ]
40
+ ```
41
+
42
+ ---
43
+
44
+ ## Configuration
45
+
46
+ 1. **Include the URLs**: Add the library's URLs to your project's `urls.py`. These are required for the iframe and the image upload endpoint.
47
+
48
+ ```python
49
+ # your_project/urls.py
50
+ from django.urls import path, include
51
+
52
+ urlpatterns = [
53
+ path('admin/', admin.site.urls),
54
+ path('editor-js/', include('editor_js.urls')),
55
+ # ... your other urls
56
+ ]
57
+ ```
58
+
59
+ 2. **Configure Settings (Optional)**: You can customize the library by adding an `EDITOR_JS` dictionary to your `settings.py`. If you don't provide this, the library will use its sensible defaults.
60
+
61
+ ```python
62
+ # settings.py
63
+ EDITOR_JS = {
64
+ # Define a custom storage backend for uploaded images.
65
+ "STORAGE_BACKEND": "app.storage.PrivateMediaStorage",
66
+
67
+ # Specify the custom CSS files to be loaded inside the editor's iframe.
68
+ "CSS_FILES": ["my_app/css/style.css", "other_app/css/style.css"],
69
+
70
+ # Specify a custom Python class to render the JSON data to HTML.
71
+ "RENDERER_CLASS": "my_app.renderers.MyCustomRenderer",
72
+
73
+ # Configure the tools available to the editor.
74
+ "TOOLS": {
75
+ # Add a new custom tool
76
+ 'my_custom_tool': {
77
+ 'class': 'MyCustomTool',
78
+ 'script': 'my_app/js/my-custom-tool.js',
79
+ 'static': True, # True if the script is a local static file
80
+ 'config': {
81
+ 'placeholder': 'Enter your custom text...'
82
+ }
83
+ },
84
+ # Remove a default tool
85
+ 'quote': None,
86
+ }
87
+ }
88
+ ```
89
+
90
+ ---
91
+
92
+ ## Usage
93
+
94
+ ### In Your Models
95
+
96
+ Use the `EditorJSField` in your models as you would any other Django model field. It stores the editor's content as JSON.
97
+
98
+ - **To use a custom set of Editor.js tools for a field**, pass a `tools` dictionary to the field.
99
+ - **To use the global (default) tool configuration**, define the field without the `tools` argument.
100
+
101
+ Since EditorJSField inherits from Django's models.JSONField, you can also pass any of its standard attributes, such as `blank=True` or `null=True`.
102
+
103
+ Example:
104
+ ```python
105
+ # my_app/models.py
106
+ from django.db import models
107
+ from editor_js.fields import EditorJSField
108
+
109
+ class Post(models.Model):
110
+ title = models.CharField(max_length=200)
111
+
112
+ # This field will only have Header and List tools
113
+ summary = EditorJSField(tools={
114
+ 'header': {
115
+ 'class': 'Header',
116
+ 'script': 'https://cdn.jsdelivr.net/npm/@editorjs/header@latest',
117
+ },
118
+ 'list': {
119
+ 'class': 'EditorjsList',
120
+ 'script': 'https://cdn.jsdelivr.net/npm/@editorjs/list@latest',
121
+ }
122
+ })
123
+
124
+ # This field will use the default or global tool configuration
125
+ body = EditorJSField()
126
+ # ...
127
+ ```
128
+
129
+ The field will automatically render the iframe widget in the Django admin.
130
+
131
+ ### Rendering Content in Templates
132
+
133
+ The library includes a built-in template filter to easily render your `EditorJSField` data as HTML.
134
+
135
+ 1. **Load the filter** in your template:
136
+ ```django
137
+ {% load editor_js_filters %}
138
+ ```
139
+
140
+ 2. **Apply the filter** to your field's data:
141
+ ```django
142
+ <!-- post_detail.html -->
143
+ {% load editor_js_filters %}
144
+
145
+ <article>
146
+ <h1>{{ post.title }}</h1>
147
+ <div class="content">
148
+ {{ post.body|render_editor_js }}
149
+ </div>
150
+ </article>
151
+ ```
152
+
153
+ The filter will automatically use your custom renderer class if you have specified one in your settings.
154
+
155
+ ---
156
+
157
+ ## Demo Application
158
+
159
+ A fully functional demo application is included to showcase the features of this library. To try it out:
160
+
161
+ **1. Clone the repository:**
162
+ ```bash
163
+ git clone https://github.com/otto-torino/django-editor-js.git
164
+ cd django-editor-js
165
+ ```
166
+
167
+ **2. Run the demo:**
168
+
169
+ - **On Windows:**
170
+ ```cmd
171
+ run_demo.bat
172
+ ```
173
+
174
+ - **On macOS / Linux:**
175
+ ```bash
176
+ ./run_demo.sh
177
+ ```
178
+
179
+ This will set up a minimal Django project, create a database, and start the development server so you can explore the editor in action.
180
+
181
+ ---
182
+
183
+ ## Customization
184
+
185
+ This library is designed to be highly extensible.
186
+
187
+ ### Adding & Removing Tools
188
+
189
+ You can fully control the tools available in the editor via the `EDITOR_JS['TOOLS']` dictionary in `settings.py`.
190
+
191
+ - **To remove a default tool**, set its key to `None`:
192
+ ```python
193
+ "TOOLS": { 'raw': None, 'table': None }
194
+ ```
195
+
196
+ - **To add a new tool**, add a new key with its configuration:
197
+ ```python
198
+ "TOOLS": {
199
+ 'my_checklist': {
200
+ 'class': 'Checklist', # The JS class name
201
+ 'script': '[https://cdn.jsdelivr.net/npm/@editorjs/checklist@latest](https://cdn.jsdelivr.net/npm/@editorjs/checklist@latest)', # URL or static path
202
+ 'static': False, # Is it a local static file?
203
+ }
204
+ }
205
+ ```
206
+
207
+ The library comes with the following default tools: **Header**, **List**, **Quote**, **Table**, **Raw HTML**, **Embed**, **Image**, **Button**, and **Divider**.
208
+
209
+ ### Custom HTML Rendering
210
+
211
+ If you add a custom tool, you'll need to tell Django how to render it.
212
+
213
+ 1. Subclass the provided `EditorJsRenderer` and add a `render_my_tool_name` method.
214
+ 2. Update `settings.py` to point to your new class.
215
+
216
+ ```python
217
+ # my_app/renderers.py
218
+ from editor_js.renderers import EditorJsRenderer
219
+
220
+ class MyCustomRenderer(EditorJsRenderer):
221
+ def render_my_custom_tool(self, data):
222
+ # Logic to convert the tool's data to HTML
223
+ items = data.get('items', [])
224
+ html = "<ul>"
225
+ for item in items:
226
+ checked = 'checked' if item.get('checked') else ''
227
+ text = self.escape(item.get('text', ''))
228
+ html += f'<li><input type="checkbox" {checked} disabled> {text}</li>'
229
+ html += "</ul>"
230
+ return html
231
+
232
+ # settings.py
233
+ EDITOR_JS = {
234
+ "RENDERER_CLASS": "my_app.renderers.MyCustomRenderer",
235
+ # ...
236
+ }
237
+ ```
238
+
239
+ ### Custom Storage & Styling
240
+
241
+ - **Storage**: To use a different storage system (like Amazon S3), set the `STORAGE_BACKEND` setting to the dotted path of your storage class (e.g., `'storages.backends.s3boto3.S3Boto3Storage'`).
242
+ - **Styling**: To match the editor's appearance with your frontend, provide a path to a custom CSS file in the `CSS_FILE` setting. This file will be loaded inside the editor's iframe.
243
+
244
+ ## License
245
+
246
+ This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.