Skip to content

Commit 13a222e

Browse files
authored
fix: Adding text-enabled plugins failed after adding first plugin (#91)
1 parent 6df8ae3 commit 13a222e

File tree

6 files changed

+48
-9
lines changed

6 files changed

+48
-9
lines changed

CHANGELOG.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
Changelog
33
=========
44

5+
0.8.6 (23-05-2025)
6+
==================
7+
8+
* fix: Adding text-enabled plugins failed after adding first plugin by @fsbraun in https://github.com/django-cms/djangocms-text/pull/91
9+
* fix: Crashed if `STATIC_URL` was not set by @fsbraun
10+
511
0.8.5 (15-05-2025)
612
==================
713

README.rst

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ from djangocms-text-ckeditor, and clean up old tables. All you have to do is:
6666
* add ``djangocms_text`` to ``INSTALLED_APPS`` (see above)
6767
* run ``python -m manage migrate djangocms_text``
6868

69-
**Attention**: The migration command also deletes djangocms-text-ckeditor's
69+
**Attention**: The migration command also deletes djangocms-text-ckeditor's
7070
tables from the database (to avoid referential integrity issues). To be on
7171
the safe side, make a backup of its content.
7272

@@ -156,7 +156,36 @@ Example::
156156

157157
TEXT_EDITOR = "djangocms_text.contrib.text_ckeditor4.ckeditor4"
158158

159+
Rich text editor configuration
160+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
161+
162+
The ``TEXT_EDITOR`` setting points to a ``RTEConfig`` object. You can create your custom
163+
``RTEConfig`` instance. The following attributes are available:
164+
165+
- name (str): The name of the RTE configuration.
166+
- config (str): The configuration string.
167+
- js (Iterable[str]): An iterable of JavaScript files to include.
168+
- css (dict): A dictionary of CSS files to include.
169+
- admin_css (Iterable[str]): An iterable of CSS files for the admin interface only.
170+
- inline_editing (bool): Whether to enable inline editing.
171+
- child_plugin_support (bool): Whether to support child plugins.
172+
173+
The default configuration is:
174+
175+
.. code-block:: python
159176
177+
RTEConfig(
178+
name="tiptap",
179+
config="TIPTAP",
180+
js=("djangocms_text/bundles/bundle.tiptap.min.js",),
181+
css={"all": ("djangocms_text/css/bundle.tiptap.min.css",)},
182+
admin_css=("djangocms_text/css/tiptap.admin.css",),
183+
inline_editing=True,
184+
child_plugin_support=True,
185+
)
186+
187+
You can use the ``admin_css`` attribute to include CSS files that you need to be loaded into the
188+
dialog window, e.g., to declare custom colors or other styles.
160189

161190
Inline editing feature
162191
~~~~~~~~~~~~~~~~~~~~~~

djangocms_text/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
10. Github actions will publish the new package to pypi
1717
"""
1818

19-
__version__ = "0.8.5"
19+
__version__ = "0.8.6"

djangocms_text/editors.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,12 +433,18 @@ class RTEConfig:
433433
config (str): The configuration string.
434434
js (Iterable[str]): An iterable of JavaScript files to include.
435435
css (dict): A dictionary of CSS files to include.
436+
admin_css (Iterable[str]): An iterable of CSS files for the admin interface only.
437+
inline_editing (bool): Whether to enable inline editing.
438+
child_plugin_support (bool): Whether to support child plugins.
436439
437440
Attributes:
438441
name (str): The name of the RTE configuration.
439442
config (str): The configuration string.
440443
js (Iterable[str]): An iterable of JavaScript files to include.
441444
css (dict): A dictionary of CSS files to include.
445+
admin_css (Iterable[str]): An iterable of CSS files for the admin interface only.
446+
inline_editing (bool): Whether to enable inline editing.
447+
child_plugin_support (bool): Whether to support child plugins.
442448
"""
443449

444450
def __init__(

private/js/cms.editor.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ class CMSEditor {
521521
cms_history: 0,
522522
};
523523
const url = `${settings.add_plugin_url}?${new URLSearchParams(data).toString()}`;
524-
return this.loadForm(url, iframe, el, onLoad, onSave);
524+
return this.loadPluginForm(url, iframe, el, onLoad, onSave);
525525
}
526526

527527
// CMS Editor: addPluginForm
@@ -535,10 +535,10 @@ class CMSEditor {
535535
cms_history: 0,
536536
};
537537
url = `${url}?${new URLSearchParams(data).toString()}`;
538-
return this.loadForm(url, iframe, el, onLoad, onSave);
538+
return this.loadPluginForm(url, iframe, el, onLoad, onSave);
539539
}
540540

541-
loadForm (url, iframe, el, onLoad, onSave) {
541+
loadPluginForm (url, iframe, el, onLoad, onSave) {
542542
iframe.addEventListener('load', () => {
543543
const form = iframe.contentDocument;
544544
const heading = form.querySelector('#content h1');
@@ -565,9 +565,7 @@ class CMSEditor {
565565
// Hook into the django CMS dataBridge to get the details of the newly created or saved
566566
// plugin. For new plugins we need their id to get the content.
567567

568-
if (!this.CMS.API.Helpers.dataBridge) {
569-
this.processDataBridge(form);
570-
}
568+
this.processDataBridge(form);
571569
// Needed to update StructureBoard
572570
if (onSave && this.CMS.API.Helpers.dataBridge) {
573571
onSave(el, form, this.CMS.API.Helpers.dataBridge);

tests/js/cms.editor.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ describe('CMSEditor', () => {
6565
const el = document.getElementById('editor1');
6666
document.body.appendChild(iframe);
6767

68-
editor.loadForm('about:blank', iframe, el, () => {
68+
editor.loadPluginForm('about:blank', iframe, el, () => {
6969
expect(iframe.contentDocument).toBeTruthy();
7070
done();
7171
});

0 commit comments

Comments
 (0)