Skip to content

Commit 586aad6

Browse files
committed
feat: Add config for CKEDITOR_BASEPATH
1 parent ff140b2 commit 586aad6

File tree

5 files changed

+18
-12
lines changed

5 files changed

+18
-12
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
11
from djangocms_text.editors import RTEConfig
22

3+
from django.conf import settings
4+
from django.templatetags.static import static
5+
36
from cms.utils.urlutils import static_with_version
7+
from django.utils.functional import lazy
48

59

610
ckeditor4 = RTEConfig(
711
name="ckeditor4",
812
config="CKEDITOR",
913
js=(
1014
static_with_version("cms/js/dist/bundle.admin.base.min.js"),
15+
"djangocms_text/js/basepath.js",
1116
"djangocms_text/vendor/ckeditor4/ckeditor.js",
1217
"djangocms_text/bundles/bundle.ckeditor4.min.js",
1318
),
1419
css={"all": ("djangocms_text/css/cms.ckeditor4.css",)},
1520
inline_editing=True,
1621
child_plugin_support=True,
22+
additional_context=dict(
23+
CKEDITOR_BASEPATH=getattr(
24+
settings, "TEXT_CKEDITOR_BASE_PATH", lazy(static, str)("/djangocms_text/vendor/ckeditor4/")
25+
),
26+
),
1727
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
window.CKEDITOR_BASEPATH = JSON.parse(document.getElementById('cms-editor-cfg').textContent).CKEDITOR_BASEPATH;

djangocms_text/editors.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ class RTEConfig:
436436
admin_css (Iterable[str]): An iterable of CSS files for the admin interface only.
437437
inline_editing (bool): Whether to enable inline editing.
438438
child_plugin_support (bool): Whether to support child plugins.
439+
additonal_context (dict | None): Additional context to pass to the editor's global setting.
439440
440441
Attributes:
441442
name (str): The name of the RTE configuration.
@@ -445,6 +446,7 @@ class RTEConfig:
445446
admin_css (Iterable[str]): An iterable of CSS files for the admin interface only.
446447
inline_editing (bool): Whether to enable inline editing.
447448
child_plugin_support (bool): Whether to support child plugins.
449+
additional_context (dict): Additional context to pass to the editor's global setting.
448450
"""
449451

450452
def __init__(
@@ -456,6 +458,7 @@ def __init__(
456458
admin_css: Iterable[str] | None = None,
457459
inline_editing: bool = False,
458460
child_plugin_support: bool = False,
461+
additional_context: dict | None = None,
459462
):
460463
""" """
461464
self.name = name
@@ -465,6 +468,7 @@ def __init__(
465468
self.admin_css = admin_css or ()
466469
self.inline_editing = inline_editing
467470
self.child_plugin_support = child_plugin_support
471+
self.additional_context = additional_context or {}
468472

469473
def process_base_config(self, base_config: dict) -> dict:
470474
"""

djangocms_text/templates/cms/plugins/text_plugin_change_formx.html

Lines changed: 0 additions & 12 deletions
This file was deleted.

djangocms_text/widgets.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,9 @@ def get_global_settings(self, language):
225225
"""The global settings are shared by all widgets and are the same for all instances. They only need
226226
to be loaded once."""
227227
# Get the toolbar setting
228+
editor_config = get_editor_config()
228229
toolbar_setting = get_editor_base_config()
230+
print(toolbar_setting)
229231
for plugin in self.installed_plugins:
230232
toolbar_setting[plugin["value"]] = {
231233
"title": plugin["name"],
@@ -247,6 +249,7 @@ def get_global_settings(self, language):
247249
"render_plugin_url": self.render_plugin_url or "",
248250
"cancel_plugin_url": self.cancel_url or "",
249251
"messages_url": self.messages_url or "",
252+
**editor_config.additional_context,
250253
}
251254

252255
def render_additions(self, name, value, attrs=None, renderer=None):

0 commit comments

Comments
 (0)