-
Notifications
You must be signed in to change notification settings - Fork 7
feat: Add CKEDITOR_BASEPATH
configuration for CKEditor 4
#94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Reviewer's GuideThis PR introduces a configurable CKEDITOR_BASEPATH for CKEditor 4 by extending RTEConfig to accept additional_context values (pulled from Django settings or static files), wiring that context through to both the editor initialization and a small basepath loader script; it also updates the CMSEditor JS API (renaming loadForm→loadPluginForm and simplifying dataBridge handling), merges additional_context into widget global settings, and includes version bump, test adjustments, and cleanup of an obsolete template. Sequence Diagram for CMSEditor loadPluginForm InteractionsequenceDiagram
participant Caller
participant Editor as CMSEditor
participant IFrame
participant PluginFormDoc as Plugin Form Document
Caller->>Editor: invoke method like addPlugin() or addPluginForm()
activate Editor
Editor->>Editor: Internally calls loadPluginForm(url, iframe, el, onLoad, onSave)
Editor->>IFrame: Set src = url_with_params (to load plugin form)
deactivate Editor
IFrame-->>Editor: 'load' event triggered (form loaded)
activate Editor
Editor->>PluginFormDoc: Access document (form) from IFrame
Editor->>Editor: this.processDataBridge(PluginFormDoc) // Called unconditionally
opt onSave callback provided AND CMS.API.Helpers.dataBridge exists
Editor->>Caller: onSave(el, PluginFormDoc, CMS.API.Helpers.dataBridge)
end
deactivate Editor
Updated Class Diagram for RTEConfigclassDiagram
class RTEConfig {
+name: str
+config: str
+js: Iterable~str~
+css: dict
+admin_css: Iterable~str~
+inline_editing: bool
+child_plugin_support: bool
+additional_context: dict
+__init__(name, config, js, css, admin_css, inline_editing, child_plugin_support, additional_context: dict | None)
+process_base_config(base_config: dict) dict
}
Updated Class Diagram for CMSEditor (JavaScript)classDiagram
class CMSEditor {
<<JavaScript Class>>
+addPlugin(placeholder_id, plugin_type, plugin_language, parent_plugin_id, el, onLoad, onSave)
+addPluginForm(url, iframe, el, onLoad, onSave)
-loadForm(url, iframe, el, onLoad, onSave) // Method removed
+loadPluginForm(url, iframe, el, onLoad, onSave) // Method added (replaces loadForm)
}
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @fsbraun - I've reviewed your changes - here's some feedback:
- Remove the debugging
print(toolbar_setting)
left inget_global_settings
to avoid console pollution. - Fix the typo in the RTEConfig docstring/parameter name (
additonal_context
should beadditional_context
). - Ensure the new
additional_context
is merged insideRTEConfig.process_base_config
so it’s actually applied during editor initialization.
Here's what I looked at during the review
- 🟡 General issues: 4 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
djangocms_text/contrib/text_ckeditor4/static/djangocms_text/js/basepath.js
Outdated
Show resolved
Hide resolved
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #94 +/- ##
==========================================
+ Coverage 81.61% 81.86% +0.25%
==========================================
Files 14 14
Lines 941 954 +13
Branches 110 110
==========================================
+ Hits 768 781 +13
Misses 130 130
Partials 43 43 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
I tried this out and it's almost there :) The problem is that Here's an alternative: setting the path as a data attribute on the script tag and then reading/setting it in the script: PR #95 for your convenience and consideration. This makes use of paths as objects available since Django 4.1.. |
Summary by Sourcery
Introduce support for customizing the base path of CKEditor 4 by adding a new TEXT_CKEDITOR_BASE_PATH setting and passing it through additional_context to the frontend; refactor RTEConfig to support this context and remove an obsolete template.
New Features:
Enhancements:
Chores: