From 2d67f66d927e5863d3a270b7fe5806cc16846038 Mon Sep 17 00:00:00 2001 From: Fabian Braun Date: Fri, 23 May 2025 08:09:46 +0200 Subject: [PATCH 1/4] fix: Adding text-enabled plugins failed after second --- README.rst | 2 +- private/js/cms.editor.js | 10 ++++------ tests/js/cms.editor.test.js | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/README.rst b/README.rst index 2d8b4d5d..12f970e5 100644 --- a/README.rst +++ b/README.rst @@ -66,7 +66,7 @@ from djangocms-text-ckeditor, and clean up old tables. All you have to do is: * add ``djangocms_text`` to ``INSTALLED_APPS`` (see above) * run ``python -m manage migrate djangocms_text`` -**Attention**: The migration command also deletes djangocms-text-ckeditor's +**Attention**: The migration command also deletes djangocms-text-ckeditor's tables from the database (to avoid referential integrity issues). To be on the safe side, make a backup of its content. diff --git a/private/js/cms.editor.js b/private/js/cms.editor.js index 8b2f806c..eacbfb8e 100644 --- a/private/js/cms.editor.js +++ b/private/js/cms.editor.js @@ -521,7 +521,7 @@ class CMSEditor { cms_history: 0, }; const url = `${settings.add_plugin_url}?${new URLSearchParams(data).toString()}`; - return this.loadForm(url, iframe, el, onLoad, onSave); + return this.loadPluginForm(url, iframe, el, onLoad, onSave); } // CMS Editor: addPluginForm @@ -535,10 +535,10 @@ class CMSEditor { cms_history: 0, }; url = `${url}?${new URLSearchParams(data).toString()}`; - return this.loadForm(url, iframe, el, onLoad, onSave); + return this.loadPluginForm(url, iframe, el, onLoad, onSave); } - loadForm (url, iframe, el, onLoad, onSave) { + loadPluginForm (url, iframe, el, onLoad, onSave) { iframe.addEventListener('load', () => { const form = iframe.contentDocument; const heading = form.querySelector('#content h1'); @@ -565,9 +565,7 @@ class CMSEditor { // Hook into the django CMS dataBridge to get the details of the newly created or saved // plugin. For new plugins we need their id to get the content. - if (!this.CMS.API.Helpers.dataBridge) { - this.processDataBridge(form); - } + this.processDataBridge(form); // Needed to update StructureBoard if (onSave && this.CMS.API.Helpers.dataBridge) { onSave(el, form, this.CMS.API.Helpers.dataBridge); diff --git a/tests/js/cms.editor.test.js b/tests/js/cms.editor.test.js index 5d75e9f4..4c71db22 100644 --- a/tests/js/cms.editor.test.js +++ b/tests/js/cms.editor.test.js @@ -65,7 +65,7 @@ describe('CMSEditor', () => { const el = document.getElementById('editor1'); document.body.appendChild(iframe); - editor.loadForm('about:blank', iframe, el, () => { + editor.loadPluginForm('about:blank', iframe, el, () => { expect(iframe.contentDocument).toBeTruthy(); done(); }); From e51aec3a312d057a5ce7e2145a842b70633fe10e Mon Sep 17 00:00:00 2001 From: Fabian Braun Date: Fri, 23 May 2025 08:28:39 +0200 Subject: [PATCH 2/4] Docs update --- README.rst | 28 ++++++++++++++++++++++++++++ djangocms_text/editors.py | 6 ++++++ 2 files changed, 34 insertions(+) diff --git a/README.rst b/README.rst index 12f970e5..7c72b3fd 100644 --- a/README.rst +++ b/README.rst @@ -156,7 +156,35 @@ Example:: TEXT_EDITOR = "djangocms_text.contrib.text_ckeditor4.ckeditor4" +Rich text editor configuration +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The ``TEXT_EDITOR`` setting points to a ``RTEConfig`` object. You can create your custom +``RTEConfig`` instance. The following attributes are available: + +- name (str): The name of the RTE configuration. +- config (str): The configuration string. +- js (Iterable[str]): An iterable of JavaScript files to include. +- css (dict): A dictionary of CSS files to include. +- admin_css (Iterable[str]): An iterable of CSS files for the admin interface only. +- inline_editing (bool): Whether to enable inline editing. +- child_plugin_support (bool): Whether to support child plugins. +The default configuration is: + +.. code-block:: python + RTEConfig( + name="tiptap", + config="TIPTAP", + js=("djangocms_text/bundles/bundle.tiptap.min.js",), + css={"all": ("djangocms_text/css/bundle.tiptap.min.css",)}, + admin_css=("djangocms_text/css/tiptap.admin.css",), + inline_editing=True, + child_plugin_support=True, + ) + +You can use the ``admin_css`` attribute to include CSS files that you need to be loaded into the +dialog window, e.g., to declare custom colors or other styles. Inline editing feature ~~~~~~~~~~~~~~~~~~~~~~ diff --git a/djangocms_text/editors.py b/djangocms_text/editors.py index 7d32ca3a..61bd1676 100644 --- a/djangocms_text/editors.py +++ b/djangocms_text/editors.py @@ -433,12 +433,18 @@ class RTEConfig: config (str): The configuration string. js (Iterable[str]): An iterable of JavaScript files to include. css (dict): A dictionary of CSS files to include. + admin_css (Iterable[str]): An iterable of CSS files for the admin interface only. + inline_editing (bool): Whether to enable inline editing. + child_plugin_support (bool): Whether to support child plugins. Attributes: name (str): The name of the RTE configuration. config (str): The configuration string. js (Iterable[str]): An iterable of JavaScript files to include. css (dict): A dictionary of CSS files to include. + admin_css (Iterable[str]): An iterable of CSS files for the admin interface only. + inline_editing (bool): Whether to enable inline editing. + child_plugin_support (bool): Whether to support child plugins. """ def __init__( From 42c9b89c83c6a164505f5aadff65fe400cea4a09 Mon Sep 17 00:00:00 2001 From: Fabian Braun Date: Fri, 23 May 2025 08:37:56 +0200 Subject: [PATCH 3/4] fix readme --- README.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/README.rst b/README.rst index 7c72b3fd..0291d753 100644 --- a/README.rst +++ b/README.rst @@ -173,6 +173,7 @@ The ``TEXT_EDITOR`` setting points to a ``RTEConfig`` object. You can create you The default configuration is: .. code-block:: python + RTEConfig( name="tiptap", config="TIPTAP", From ff140b2c993cdd67d8f4216eb067e3b3c944b279 Mon Sep 17 00:00:00 2001 From: Fabian Braun Date: Fri, 23 May 2025 08:43:29 +0200 Subject: [PATCH 4/4] Prepare hotfix release --- CHANGELOG.rst | 6 ++++++ djangocms_text/__init__.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 9446433b..4951d5ea 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,12 @@ Changelog ========= +0.8.6 (23-05-2025) +================== + +* fix: Adding text-enabled plugins failed after adding first plugin by @fsbraun in https://github.com/django-cms/djangocms-text/pull/91 +* fix: Crashed if `STATIC_URL` was not set by @fsbraun + 0.8.5 (15-05-2025) ================== diff --git a/djangocms_text/__init__.py b/djangocms_text/__init__.py index a688da92..0b06e793 100644 --- a/djangocms_text/__init__.py +++ b/djangocms_text/__init__.py @@ -16,4 +16,4 @@ 10. Github actions will publish the new package to pypi """ -__version__ = "0.8.5" +__version__ = "0.8.6"