feat(editor): add SCEditor as an optional BBCode editor - #152
Conversation
Registers SCEditor alongside the existing editors. dhtmltextarea remains the default, so nothing changes for an existing site until an administrator selects the new editor in preferences. It runs permanently in BBCode source mode and never in WYSIWYG. That is a safety property rather than a preference: in visual mode any tag the editor does not recognise -- [siteurl], [img id=], [[WikiPage]] and the smilie text codes held in the smiles table -- would be silently dropped when an existing post is opened and saved. In source mode nothing re-serialises the document, so stored content is never rewritten. MyTextSanitizer remains the only thing that parses BBCode, and no read path changes. js/xoops-bbcode.js teaches SCEditor the XOOPS dialect. Two defaults had to be overridden because they differ from XOOPS and would rewrite existing posts: strikethrough is [d], not [s], and [size=] takes the named XOOPS sizes (xx-small .. xx-large) rather than the numeric 1-7 scale. Tags that are off by default in the sanitiser are registered so existing content round-trips, but are kept off the toolbar. The plugin self-gates. editor_registry.php reports an empty order, and isActive() returns false, unless every required file is readable, so a missing or partial library leaves the editor out of the preferences list rather than offering a control that cannot work. Note that XoopsEditorHandler::getList() builds the list from the registry alone and never consults isActive(), which is why the gate lives in the registry. The library is vendored under minified/ following the layout of its upstream release, matching how tinymce and easymde are already carried in this repo. It is MIT licensed, which is compatible with GPL-2.0-or-later; the copyright notice is preserved inside the minified bundle.
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
There was a problem hiding this comment.
Sorry @mambax7, your pull request is larger than the review limit of 150000 diff characters
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Reviewer's GuideAdds SCEditor as an optional BBCode editor, wiring it into the XOOPS editor registry, providing a PHP integration class and a JS plugin that encodes the XOOPS-specific BBCode dialect, while vendoring the SCEditor minified library and related assets with safety gating to ensure source-mode-only editing and correct behavior when the library is missing or partially installed. Sequence diagram for SCEditor initialization in BBCode source modesequenceDiagram
participant User
participant XOOPS_Form as XoopsForm
participant FormSCEditor
participant Browser
participant SCEditor as SCEditor_JS
User->>XOOPS_Form: submit form config using FormSCEditor
XOOPS_Form->>FormSCEditor: render()
FormSCEditor->>FormSCEditor: isActive()
FormSCEditor->>Browser: HTML textarea + script tags
Browser->>SCEditor: load sceditor.min.js
Browser->>SCEditor: load minified/formats/bbcode.js
Browser->>SCEditor: load js/xoops-bbcode.js
Browser->>SCEditor: sceditor.create(textarea, format="bbcode", toolbar=xoopsBBCodeToolbar, emoticonsEnabled=false)
Browser->>SCEditor: instance.sourceMode(true)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #152 +/- ##
=========================================
Coverage 19.29% 19.29%
Complexity 8227 8227
=========================================
Files 672 672
Lines 44266 44266
=========================================
Hits 8539 8539
Misses 35727 35727 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds SCEditor as an optional XOOPS editor implementation, aiming to provide a BBCode source-mode editing experience while preserving XOOPS-specific BBCode semantics via a custom SCEditor dialect plugin and a registry-based availability gate.
Changes:
- Introduces a new
FormSCEditoreditor implementation and registers it witheditor_registry.php. - Vendors SCEditor minified assets under
minified/and adds XOOPS BBCode integration glue (js/xoops-bbcode.js). - Adds install/documentation and standard directory
index.phpguards.
Reviewed changes
Copilot reviewed 12 out of 34 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| htdocs/class/xoopseditor/sceditor/sceditor.php | New SCEditor-backed editor class that renders a textarea and initializes SCEditor. |
| htdocs/class/xoopseditor/sceditor/editor_registry.php | Registers the editor and gates visibility in the preference list based on required files. |
| htdocs/class/xoopseditor/sceditor/INSTALL.md | Installation/documentation for SCEditor availability and file layout. |
| htdocs/class/xoopseditor/sceditor/js/xoops-bbcode.js | XOOPS-authored SCEditor BBCode dialect + toolbar/command configuration. |
| htdocs/class/xoopseditor/sceditor/language/english.php | Adds the editor title language constant. |
| htdocs/class/xoopseditor/sceditor/language/index.php | Directory guard returning 404. |
| htdocs/class/xoopseditor/sceditor/index.php | Directory guard returning 404. |
| htdocs/class/xoopseditor/sceditor/js/index.php | Directory guard returning 404. |
| htdocs/class/xoopseditor/sceditor/css/index.php | Directory guard returning 404. |
| htdocs/class/xoopseditor/sceditor/minified/sceditor.min.js | Vendored SCEditor core JS bundle. |
| htdocs/class/xoopseditor/sceditor/minified/formats/bbcode.js | Vendored SCEditor BBCode format implementation. |
| htdocs/class/xoopseditor/sceditor/minified/formats/xhtml.js | Vendored SCEditor XHTML format implementation. |
| htdocs/class/xoopseditor/sceditor/minified/themes/default.min.css | Vendored SCEditor default theme CSS. |
| htdocs/class/xoopseditor/sceditor/minified/themes/defaultdark.min.css | Vendored SCEditor default dark theme CSS. |
| htdocs/class/xoopseditor/sceditor/minified/themes/modern.min.css | Vendored SCEditor modern theme CSS. |
| htdocs/class/xoopseditor/sceditor/minified/themes/office.min.css | Vendored SCEditor office theme CSS. |
| htdocs/class/xoopseditor/sceditor/minified/themes/office-toolbar.min.css | Vendored SCEditor office-toolbar theme CSS. |
| htdocs/class/xoopseditor/sceditor/minified/themes/square.min.css | Vendored SCEditor square theme CSS. |
| htdocs/class/xoopseditor/sceditor/minified/themes/content/default.min.css | Vendored SCEditor content CSS for the editing area. |
| htdocs/class/xoopseditor/sceditor/minified/plugins/alternative-lists.js | Vendored SCEditor plugin. |
| htdocs/class/xoopseditor/sceditor/minified/plugins/autosave.js | Vendored SCEditor plugin. |
| htdocs/class/xoopseditor/sceditor/minified/plugins/autoyoutube.js | Vendored SCEditor plugin. |
| htdocs/class/xoopseditor/sceditor/minified/plugins/dragdrop.js | Vendored SCEditor plugin. |
| htdocs/class/xoopseditor/sceditor/minified/plugins/emojis.js | Vendored SCEditor plugin. |
| htdocs/class/xoopseditor/sceditor/minified/plugins/format.js | Vendored SCEditor plugin. |
| htdocs/class/xoopseditor/sceditor/minified/plugins/plaintext.js | Vendored SCEditor plugin. |
| htdocs/class/xoopseditor/sceditor/minified/plugins/undo.js | Vendored SCEditor plugin. |
| htdocs/class/xoopseditor/sceditor/minified/plugins/v1compat.js | Vendored SCEditor compatibility plugin. |
| htdocs/class/xoopseditor/sceditor/minified/icons/material.js | Vendored SCEditor icon pack. |
| htdocs/class/xoopseditor/sceditor/minified/icons/monocons.js | Vendored SCEditor icon pack. |
Files not reviewed (17)
- htdocs/class/xoopseditor/sceditor/minified/formats/bbcode.js: Generated file
- htdocs/class/xoopseditor/sceditor/minified/formats/xhtml.js: Generated file
- htdocs/class/xoopseditor/sceditor/minified/icons/material.js: Generated file
- htdocs/class/xoopseditor/sceditor/minified/icons/monocons.js: Generated file
- htdocs/class/xoopseditor/sceditor/minified/plugins/alternative-lists.js: Generated file
- htdocs/class/xoopseditor/sceditor/minified/plugins/autosave.js: Generated file
- htdocs/class/xoopseditor/sceditor/minified/plugins/autoyoutube.js: Generated file
- htdocs/class/xoopseditor/sceditor/minified/plugins/dragdrop.js: Generated file
- htdocs/class/xoopseditor/sceditor/minified/plugins/emojis.js: Generated file
- htdocs/class/xoopseditor/sceditor/minified/plugins/format.js: Generated file
- htdocs/class/xoopseditor/sceditor/minified/plugins/plaintext.js: Generated file
- htdocs/class/xoopseditor/sceditor/minified/plugins/undo.js: Generated file
- htdocs/class/xoopseditor/sceditor/minified/plugins/v1compat.js: Generated file
- htdocs/class/xoopseditor/sceditor/minified/themes/content/default.min.css: Generated file
- htdocs/class/xoopseditor/sceditor/minified/themes/default.min.css: Generated file
- htdocs/class/xoopseditor/sceditor/minified/themes/defaultdark.min.css: Generated file
- htdocs/class/xoopseditor/sceditor/minified/themes/modern.min.css: Generated file
| $html .= ' sceditor.create(el, {' . "\n"; | ||
| $html .= ' format: "bbcode",' . "\n"; | ||
| // Content stylesheet for the editing area, per the upstream usage docs. | ||
| $html .= ' style: ' . json_encode($editorPath . '/minified/themes/content/default.min.css', JSON_THROW_ON_ERROR) . ',' . "\n"; | ||
| $html .= ' toolbar: (typeof xoopsBBCodeToolbar !== "undefined") ? xoopsBBCodeToolbar : "bold,italic,underline,strike",' . "\n"; | ||
| $html .= ' emoticonsEnabled: false,' . "\n"; | ||
| $html .= ' resizeEnabled: true,' . "\n"; | ||
| $html .= ' width: ' . json_encode($configs['width'] ?? $this->width, JSON_THROW_ON_ERROR) . ',' . "\n"; | ||
| $html .= ' height: ' . json_encode($configs['height'] ?? $this->height, JSON_THROW_ON_ERROR) . "\n"; | ||
| $html .= ' });' . "\n"; | ||
| $html .= ' var instance = sceditor.instance(el);' . "\n"; | ||
| $html .= ' if (instance && typeof instance.sourceMode === "function") {' . "\n"; | ||
| $html .= ' instance.sourceMode(true);' . "\n"; | ||
| $html .= ' }' . "\n"; |
| This directory contains only the XOOPS-side integration for | ||
| [SCEditor](https://github.com/samclarke/SCEditor). The SCEditor library | ||
| itself is **not** included with XOOPS and must be installed manually. Until | ||
| it is, `FormSCEditor::isActive()` returns `false` and this editor simply does | ||
| not appear in the editor selection list — it is inert, not broken. |
| From the release archive's `minified/` directory, copy: | ||
|
|
||
| | Source (in the SCEditor release) | Destination in this directory | | ||
| |---------------------------------------|----------------------------------| | ||
| | `minified/sceditor.min.js` | `js/sceditor.min.js` | | ||
| | `minified/themes/default.min.css` | `css/sceditor.min.css` | | ||
|
|
||
| Only `js/sceditor.min.js` is required for `isActive()` to return `true` | ||
| (together with `js/xoops-bbcode.js`, which already ships with XOOPS). The | ||
| CSS file is optional — `sceditor.php` includes it only if present. |
| sceditor.command.set('siteurl', { | ||
| txtExec: function (caller) { | ||
| var path = window.prompt('Site-relative path:', ''); | ||
| if (path) { | ||
| this.insertText('[siteurl=' + path + ']', '[/siteurl]'); | ||
| } | ||
| }, | ||
| tooltip: 'Site URL' | ||
| }); | ||
|
|
||
| sceditor.command.set('quote', { | ||
| txtExec: ['[quote]', '[/quote]'], | ||
| tooltip: 'Quote' | ||
| }); |
| bbcode.set('strike', { | ||
| tags: { del: null, s: null, strike: null }, | ||
| format: '[d]{0}[/d]', | ||
| html: '<del>{0}</del>' | ||
| }); |
Registers SCEditor alongside the existing editors. dhtmltextarea remains the default, so nothing changes for an existing site until an administrator selects the new editor in preferences.
It runs permanently in BBCode source mode and never in WYSIWYG. That is a safety property rather than a preference: in visual mode any tag the editor does not recognise -- [siteurl], [img id=], [[WikiPage]] and the smilie text codes held in the smiles table -- would be silently dropped when an existing post is opened and saved. In source mode nothing re-serialises the document, so stored content is never rewritten. MyTextSanitizer remains the only thing that parses BBCode, and no read path changes.
js/xoops-bbcode.js teaches SCEditor the XOOPS dialect. Two defaults had to be overridden because they differ from XOOPS and would rewrite existing posts: strikethrough is [d], not [s], and [size=] takes the named XOOPS sizes (xx-small .. xx-large) rather than the numeric 1-7 scale. Tags that are off by default in the sanitiser are registered so existing content round-trips, but are kept off the toolbar.
The plugin self-gates. editor_registry.php reports an empty order, and isActive() returns false, unless every required file is readable, so a missing or partial library leaves the editor out of the preferences list rather than offering a control that cannot work. Note that XoopsEditorHandler::getList() builds the list from the registry alone and never consults isActive(), which is why the gate lives in the registry.
The library is vendored under minified/ following the layout of its upstream release, matching how tinymce and easymde are already carried in this repo. It is MIT licensed, which is compatible with GPL-2.0-or-later; the copyright notice is preserved inside the minified bundle.
Summary by Sourcery
Integrate SCEditor as an optional BBCode source-mode editor, aligned with XOOPS BBCode dialect and safely gated on the presence of the vendored SCEditor library.
New Features:
Enhancements:
Documentation: