diff --git a/README.md b/README.md index 0fa1233..438c1a9 100644 --- a/README.md +++ b/README.md @@ -302,7 +302,9 @@ file. | `EDITORJS_IMAGE_NAME_ORIGINAL` | To use the original name of the image file? | `False` | `bool` | | `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/)) | | `EDITORJS_EMBED_HOSTNAME_ALLOWED` | List of allowed hostname for embed | `('player.vimeo.com','www.youtube.com','coub.com','vine.co','imgur.com','gfycat.com','player.twitch.tv','player.twitch.tv','music.yandex.ru','codepen.io','www.instagram.com','twitframe.com','assets.pinterest.com','www.facebook.com','www.aparat.com'),` | `list[str]`, `tuple[str]` | -| `EDITORJS_VERSION` | Version Editor.js | `2.25.0` | `str` | +| `EDITORJS_SCRIPT_PATH` | Path to Editor.js script | `//cdn.jsdelivr.net/npm/@editorjs/editorjs@` + `EDITORJS_VERSION` | `str` | +| `PLUGINS_SCRIPT_PATH` | Path to Editor.js plugins scripts | `//cdn.jsdelivr.net/npm/` | `str` | +| `EDITORJS_VERSION` | Version Editor.js | `2.30.8` | `str` | For `EDITORJS_IMAGE_NAME` was used `from secrets import token_urlsafe` diff --git a/django_editorjs_fields/config.py b/django_editorjs_fields/config.py index e213ecd..0fe830c 100644 --- a/django_editorjs_fields/config.py +++ b/django_editorjs_fields/config.py @@ -5,12 +5,22 @@ DEBUG = getattr(settings, "DEBUG", False) -VERSION = getattr(settings, "EDITORJS_VERSION", '2.25.0') +VERSION = getattr(settings, "EDITORJS_VERSION", '2.30.8') # ATTACHMENT_REQUIRE_AUTHENTICATION = str( # getattr(settings, "EDITORJS_ATTACHMENT_REQUIRE_AUTHENTICATION", True) # ) +EDITORJS_SCRIPT_PATH = getattr( + settings, + "EDITORJS_SCRIPT_PATH", + '//cdn.jsdelivr.net/npm/@editorjs/editorjs@' + VERSION, +) + +PLUGINS_SCRIPT_PATH = getattr( + settings, "PLUGINS_SCRIPT_PATH", '//cdn.jsdelivr.net/npm/' +) + EMBED_HOSTNAME_ALLOWED = str( getattr(settings, "EDITORJS_EMBED_HOSTNAME_ALLOWED", ( 'player.vimeo.com', diff --git a/django_editorjs_fields/widgets.py b/django_editorjs_fields/widgets.py index 98fb2e6..73e0484 100644 --- a/django_editorjs_fields/widgets.py +++ b/django_editorjs_fields/widgets.py @@ -8,7 +8,7 @@ from django.utils.html import conditional_escape from django.utils.safestring import mark_safe -from .config import CONFIG_TOOLS, PLUGINS, PLUGINS_KEYS, VERSION +from .config import CONFIG_TOOLS, PLUGINS, PLUGINS_KEYS, EDITORJS_SCRIPT_PATH, PLUGINS_SCRIPT_PATH class LazyEncoder(DjangoJSONEncoder): @@ -76,14 +76,12 @@ def configuration(self): @cached_property def media(self): - js_list = [ - '//cdn.jsdelivr.net/npm/@editorjs/editorjs@' + VERSION # lib - ] + js_list = [EDITORJS_SCRIPT_PATH] # lib plugins = self.plugins or PLUGINS if plugins: - js_list += ['//cdn.jsdelivr.net/npm/' + p for p in plugins] + js_list += [PLUGINS_SCRIPT_PATH + p for p in plugins] js_list.append('django-editorjs-fields/js/django-editorjs-fields.js')