
Integration
How to enable mxEditorJs in MODX, use it in TVs, and output content on the site.
Enabling in the manager
- Settings → System settings → find which_editor → select mxEditorJs.
- Ensure mxeditorjs.enabled = Yes (namespace
mxeditorjs). - Open a resource — the content field shows the block editor.
The plugin hooks OnDocFormPrerender and initializes when the content field (or richtext TV) appears.
Save via resource form (primary path):
- Editor.js sends JSON and HTML (client
renderPreviewHtml) to textarea and hidden fields - MODX saves HTML to
modResource.content/ TV - Plugin on
OnBeforeDocFormSavewrites JSON to sidecar
The form does not call connector content/save. Use that for AJAX and custom integrations. Details: Flows.
Using in Template Variables
- Create a TV of type Text (multiline) (textarea).
- In the TV settings, enable Use visual editor (richtext).
- With
which_editor= mxEditorJs, this TV uses the same block editor.
TV content is stored in mxeditorjs_tv_content as Editor.js JSON. Frontend output uses generated HTML (same as main content).
Output on the site
After saving, main resource content exists in two forms:
- JSON — sidecar for the editor (loaded on next form open)
- HTML —
modResource.contentfor the frontend
In the template:
[[*content]]{$_modx->resource.content}Editor.js TVs use TV placeholders (e.g. [[*my_richtext_tv]] or Fenom). HTML lands in the TV textarea on save. Frontend always receives ready HTML.
HTML → Editor.js migration
Convert existing HTML in the content field to Editor.js:
- Connector action content/migrate with
resource_id, optionallydry_run=1(preview), thenconfirmed=1to overwrite - With
dry_runthe response includespreview(blocks) andblocks_count. On success —migrated,blocks_count,overwritten
After migration the manager shows the block editor. The site still outputs HTML from modResource.content, updated during migration.
Profiles and tools
Block set (paragraph, header, list, image, etc.) is defined by mxeditorjs.profile or mxeditorjs.enabled_tools. See System settings.
Media and presets
- Images and Gallery — mxeditorjs.image_mediasource, path mxeditorjs.image_upload_path (template with
{resource_id}) - Attaches — mxeditorjs.file_mediasource, path mxeditorjs.file_upload_path
- Gallery image limit — mxeditorjs.gallery_max_count (
0= no limit) - CSS presets (mxeditorjs.image_class_presets, mxeditorjs.link_class_presets, etc.). Image presets in the editor UI do not add a class to
<img>in the HTML snapshot — see System settings
Gallery on the frontend
Gallery HTML is generated on save (client renderPreviewHtml or server HtmlRenderer on content/save). Markup:
<figure class="mxeditorjs-gallery mxeditorjs-gallery--fit">— grid (Fit)<figure class="mxeditorjs-gallery mxeditorjs-gallery--slider">— horizontal scroll (Slider)
gallery-front.css loads only in the manager (form preview). The frontend does not load it automatically.
Add styles in template or theme:
<link rel="stylesheet" href="/assets/components/mxeditorjs/css/gallery-front.css">Or copy rules from assets/components/mxeditorjs/css/gallery-front.css into theme CSS.
Embed on the frontend
Embed blocks output <div class="mxeditorjs-embed"><iframe ...></iframe></div>. RuTube and other @editorjs/embed services are configured in mxeditorjs.ts (services section), not via system settings. Custom services are added in source — see Architecture.
Next steps
- Editor guide — blocks, embed, TVs
- Flows — save flow, sidecar, connector
- API — connector endpoints, PHP classes
- System settings — profiles, media, presets
- FAQ — common questions
