Skip to content

feat(editor): add SCEditor as an optional BBCode editor - #152

Open
mambax7 wants to merge 1 commit into
XOOPS:masterfrom
mambax7:feat/sceditor-bbcode-editor
Open

feat(editor): add SCEditor as an optional BBCode editor#152
mambax7 wants to merge 1 commit into
XOOPS:masterfrom
mambax7:feat/sceditor-bbcode-editor

Conversation

@mambax7

@mambax7 mambax7 commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

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:

  • Add SCEditor-based BBCode source editor implementation and register it as an optional XOOPS editor.
  • Provide a XOOPS BBCode dialect plugin for SCEditor, including toolbar configuration and command mappings.

Enhancements:

  • Vendor SCEditor minified assets and plugins into the codebase following existing editor layout.
  • Gate the SCEditor editor and registry on required library files to avoid exposing unusable options in preferences.

Documentation:

  • Add INSTALL instructions describing how to install the external SCEditor library for use with the new editor.

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.
Copilot AI review requested due to automatic review settings August 1, 2026 09:16
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @mambax7, your pull request is larger than the review limit of 150000 diff characters

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: d797d5c9-2b4d-486c-bedc-a596b74f7880

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gitar-bot

gitar-bot Bot commented Aug 1, 2026

Copy link
Copy Markdown

Important

You are using the Gitar free plan. Upgrade to unlock code review, CI analysis, auto-apply, custom automations, and more.

Gitar

@sourcery-ai

sourcery-ai Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Adds 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 mode

sequenceDiagram
  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)
Loading

File-Level Changes

Change Details Files
Introduce SCEditor-based BBCode editor implementation and render pipeline that runs SCEditor in permanent source mode and integrates with XOOPS forms.
  • Create FormSCEditor class extending XoopsEditor with width/height defaults and rootPath configuration.
  • Implement isActive() to check readability of SCEditor core JS, bbcode format JS, and XOOPS integration JS before enabling the editor.
  • Implement render() to include SCEditor assets once per page, render the textarea, and initialize SCEditor in bbcode format with content stylesheet, custom toolbar, and forced source mode.
  • Provide renderValidationJS() to perform required-field client-side validation against the textarea value.
htdocs/class/xoopseditor/sceditor/sceditor.php
Register SCEditor editor in XOOPS editor registry with self-gating on vendored assets and language support.
  • Add editor_registry.php that defines the SCEditor editor config and sets order based on whether required JS and format files plus dialect JS are readable, avoiding broken entries in preferences.
  • Introduce English language file defining the SCEditor editor title constant.
  • Add index.php stubs in sceditor root, css, js, and language directories returning 404 to prevent direct access listing.
htdocs/class/xoopseditor/sceditor/editor_registry.php
htdocs/class/xoopseditor/sceditor/language/english.php
htdocs/class/xoopseditor/sceditor/index.php
htdocs/class/xoopseditor/sceditor/css/index.php
htdocs/class/xoopseditor/sceditor/js/index.php
htdocs/class/xoopseditor/sceditor/language/index.php
Define XOOPS-specific BBCode dialect and toolbar/command behavior for SCEditor, ensuring tags round-trip correctly and preserving unknown BBCode by staying in source mode.
  • Implement js/xoops-bbcode.js plugin that validates SCEditor bbcode format availability and maps XOOPS BBCode tags to SCEditor formats with correct HTML mappings.
  • Override SCEditor defaults for strike and size tags to match XOOPS ([d] for strike, named sizes for [size=]).
  • Register XOOPS-specific tags such as [siteurl], [youtube], [ul]/[li], [[WikiPage]], and various media/iframe tags, including default-off tags that are parsed but not shown in toolbar.
  • Define SCEditor command txtExec behaviors for tags (strike, alignment, size, siteurl, quote, code, bulletlist, image, youtube, wikipage) that operate by inserting/wrapping BBCode in source mode.
  • Provide window.xoopsBBCodeToolbar string describing the default toolbar layout limited to tags XOOPS can render.
htdocs/class/xoopseditor/sceditor/js/xoops-bbcode.js
Vendor SCEditor minified distribution (core, formats, icons, jQuery plugin, plugins, and themes) into the XOOPS repository following upstream structure and adjust INSTALL documentation accordingly.
  • Add INSTALL.md describing how SCEditor is integrated, emphasizing that the upstream library is MIT licensed and XOOPS glue is GPL, and explaining installation steps and gating behavior.
  • Vendor minified SCEditor formats (bbcode.js, xhtml.js), icons (material.js, monocons.js), jQuery integration bundles, core sceditor.min.js, plugins (alternative-lists, autosave, autoyoutube, dragdrop, emojis, format, plaintext, undo, v1compat), and multiple CSS themes under minified/ directory.
  • Ensure minified assets carry upstream MIT license headers and are referenced by FormSCEditor render() in correct order (core, bbcode format, XOOPS bbcode integration).
htdocs/class/xoopseditor/sceditor/INSTALL.md
htdocs/class/xoopseditor/sceditor/minified/sceditor.min.js
htdocs/class/xoopseditor/sceditor/minified/jquery.sceditor.min.js
htdocs/class/xoopseditor/sceditor/minified/jquery.sceditor.bbcode.min.js
htdocs/class/xoopseditor/sceditor/minified/jquery.sceditor.xhtml.min.js
htdocs/class/xoopseditor/sceditor/minified/formats/bbcode.js
htdocs/class/xoopseditor/sceditor/minified/formats/xhtml.js
htdocs/class/xoopseditor/sceditor/minified/icons/material.js
htdocs/class/xoopseditor/sceditor/minified/icons/monocons.js
htdocs/class/xoopseditor/sceditor/minified/plugins/alternative-lists.js
htdocs/class/xoopseditor/sceditor/minified/plugins/autosave.js
htdocs/class/xoopseditor/sceditor/minified/plugins/autoyoutube.js
htdocs/class/xoopseditor/sceditor/minified/plugins/dragdrop.js
htdocs/class/xoopseditor/sceditor/minified/plugins/emojis.js
htdocs/class/xoopseditor/sceditor/minified/plugins/format.js
htdocs/class/xoopseditor/sceditor/minified/plugins/plaintext.js
htdocs/class/xoopseditor/sceditor/minified/plugins/undo.js
htdocs/class/xoopseditor/sceditor/minified/plugins/v1compat.js
htdocs/class/xoopseditor/sceditor/minified/themes/default.min.css
htdocs/class/xoopseditor/sceditor/minified/themes/defaultdark.min.css
htdocs/class/xoopseditor/sceditor/minified/themes/modern.min.css
htdocs/class/xoopseditor/sceditor/minified/themes/office-toolbar.min.css
htdocs/class/xoopseditor/sceditor/minified/themes/office.min.css
htdocs/class/xoopseditor/sceditor/minified/themes/square.min.css
htdocs/class/xoopseditor/sceditor/minified/themes/content/default.min.css

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov

codecov Bot commented Aug 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 19.29%. Comparing base (d2b5bde) to head (e376439).
⚠️ Report is 3 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 FormSCEditor editor implementation and registers it with editor_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.php guards.

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

Comment on lines +131 to +144
$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";
Comment on lines +3 to +7
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.
Comment on lines +18 to +27
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.
Comment on lines +399 to +412
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'
});
Comment on lines +94 to +98
bbcode.set('strike', {
tags: { del: null, s: null, strike: null },
format: '[d]{0}[/d]',
html: '<del>{0}</del>'
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants