Skip to content

MelisAICommunityExtensions

Injects AI generation into existing CMS editing surfaces — mini-template creator, news content creator, and drag-and-drop zone AI buttons. In the React back-office it ships an extension (host-injection) brick with no page of its own. Package melisplatform/melis-ai-community-extensions.

Purpose

MelisAICommunityExtensions is an app layer on top of the MelisAI suite that wires AI generation directly into existing editing surfaces. It registers two pre-configured instances (minitemplatecreator and newscontentcreator), an MCP tool set, and a set of event listeners that manage the lifecycle of AI-generated front-end assets (CSS, JS, images). It has no standalone tool screen; instead it injects Generate with AI buttons and chat modals into the Mini-Template Manager, the News editor, and page drag-and-drop zones. The AI chat itself is served by MelisAI / MelisAIEngine — this module provides only the surrounding UI and the entry/exit wiring.

Enable it

Add to config/melis.module.load.php:

php
return [
    'MelisAICommunityExtensions',
];

Requires melisplatform/melis-ai. Run the dbdeploy after enabling — the module seeds the minitemplatecreator and newscontentcreator agent/instance rows into the MelisAI engine tables (dbdeploy: true). It integrates with MelisCms and MelisCmsNews.

Where it lives in the React back-office

The React brick is an extension / host-injection brick: it draws no page and adds no sidebar entry. On load it registers two host extension points on window that other modules' React pages call to render the Generate with AI button inline, plus one always-mounted Header widget (MiniTemplateAiDialogHost) that anchors the page-edition dialog above the legacy edit frames.

Because it has no route, there is nothing to navigate to — you meet it inside other tools:

  • News editor (MelisCmsNews) → Texts tab → per-paragraph button.
  • Mini-Template manager (MelisCms) → the Template's HTML field → button.
  • Page edition (MelisCms drag-and-drop) → the zone's / HTML-tag plugin's button.

Activation-gated by two modules. The buttons appear only if both MelisAICommunityExtensions and MelisAI are active (checked live via the host's __melisIsModuleActive, backed by GET /melis/react-api/react-modules). MelisAI is required because it serves the chat; if either module is disabled mid-session the buttons vanish without a reload. The brick contributes no capability node — visibility is purely this two-module check.

Back-office editing surfaces

Three editing surfaces are extended. In each, an AI button opens a scoped chat and the result is written back into the correct field.

AI Mini-Template Creator

In the Mini-Template manager, the Template's HTML field carries a Generate with AI button rendered by the renderHtmlActions() extension point. It opens a full-window dialog: AI chat + existing-templates list on the left, live preview on the right (the two panels collapse to segmented AI & Templates / Preview tabs on narrow widths). The chat uses instance minitemplatecreator, starts fresh on each open (clearSession), and re-fetches the real site shell on each AI result so freshly written CSS/JS is reflected.

The Mini-Template manager, per-site list with the Generate with AI entry point

The minitemplatecreator chat generating a template, previewed against the real site shell

Each row in the templates list shows a Melis-AI icon: click it to generate a new template using that one as the base reference (the chat re-runs seeded with the selected template's markup). Insert captures a PNG thumbnail of the preview (html2canvas) and fills the form; the form's own submit saves it.

The Melis-AI icon on a template row — vary or duplicate an existing template with AI

The Add mini-template form — Generate with AI next to the HTML field

News Content Creator

In the News editor's Texts tab, every Paragraph gets a Generate with AI button (per language) rendered by the renderParagraphActions() extension point. It opens a compact modal with the newscontentcreator chat, scoped to the article (seeded with the title, subtitle, the other paragraphs, and the article images). The answer replaces that paragraph's text and marks it validated. Sessions are isolated per article via a newscontentcreator|<newsId> instance id.

The News Texts tab — each paragraph header bar carries the Generate with AI action

The newscontentcreator chat, aware of the article context

Generate with AI in drag-and-drop zones

When editing a CMS page, empty drag-and-drop zones (and HTML-tag plugins) get an injected Generate with AI button. Because page edition is a legacy iframe below the React shell, the button asks the React host to open the same Mini-Template dialog as above. On accept, three commit options are offered: Close, Insert (drop into this zone only), or Save & Insert (drop and also promote the block to a permanent reusable mini-template).

An empty drag-and-drop zone with the injected Generate with AI button

A full styled block generated straight into the page zone

The Close / Insert / Save & Insert commit choice for a generated block

The brick

ui-react/ is a Vite IIFE library (name MelisAiCommunityExtensionsBrick, output public/ui-react/brick.js). React, react-dom and react-router-dom are externalised to the host globals; a @melis-ai-engine alias imports the shared AiChatContainer chat component.

FileRole
src/brick.tsxRegisters the two extension points + the Header; injects Tailwind once.
src/NewsAiExtension.tsxrenderParagraphActions() → per-paragraph button + modal (instance newscontentcreator).
src/MiniTemplateAiExtension.tsxrenderHtmlActions() → the full-window MiniTemplateAiDialog (chat + list + preview; Insert / Save & Insert; html2canvas thumbnail).
src/MiniTemplateAiDialogHost.tsxThe Header anchor for page edition; listens for melis-ai-minitemplate-open and mounts the dialog.

The brick registers with no Component and no Sidebar — only guarded extension points and the Header anchor:

ts
window.__melisNewsExtensions.renderParagraphActions = /* guarded by isModuleActive() */
window.__melisMiniTemplateExtensions.renderHtmlActions = /* guarded by isModuleActive() */
window.__melisRegisterBrick?.({ id: 'melis-ai-community-extensions', Header: MiniTemplateAiDialogHost })

Endpoints the brick calls

The brick has no config/react-api.php. It consumes endpoints owned by other modules plus one legacy MVC action of its own:

CallOwner
GET /melis/react-api/cms-mini-templates?site=<m>&limit=9999MelisCms (template list)
GET /melis/react-api/cms-mini-templates/item?site=<m>&name=<n>MelisCms (one template's HTML)
GET /melis/MelisAICommunityExtensions/MiniTemplate/getMiniTemplatePreviewShell?siteModule=<m>this module (legacy MVC; returns the site shell HTML)
AiChatContainer run/exit trafficMelisAI / MelisAIEngine

The chat answer routes back into the host field via a window callback declared in the exit params (masse_exit_js_callback): __melisNewsAiCallback_<paraIdx> for news, __melisMiniTemplateAiCallback for mini-templates.

Host integration (page-edition bridge)

Page edition runs several frames below the React shell, so MiniTemplateAiDialogHost sets window.__melisAiMiniTemplateDialogReady = true and listens for a melis-ai-minitemplate-open event. The edited page runs public/js/minitemplate/react-bridge.js, which walks up the frame chain for __melisAiMiniTemplateDialogReady; when found it dispatches the open event with same-origin onInsert / onSaveInsert callbacks. If no React host is found (legacy /melis), the bridge falls back to the historical Bootstrap modal — nothing changes there.

For legacy tools shown in the React "Old" view, config/module.config.php registers melis_react_override.toolpage_extensionsPluginViewToolPageExtension, which injects this module's tool.js / style.css so the jsCallbacks grafted onto the MelisCms / MelisCmsNews tools find their globals.

Event listeners

ListenerEventEffect
…TinyMCEConfigurationListenermeliscore_tinymce_configPoints the TinyMCE minitemplate plugin at this module's JS.
…CreateMiniTemplateListenermeliscms_mini_template_manager_create_endMoves temp CSS/JS/images to permanent storage; renames the init JS per template.
…PublishPageListenermeliscms_page_publish_startPromotes temp assets a published page references; updates page_content.
…SanitizeSavedPluginHtmlListenermeliscms_page_savesession_plugin_startCleans carousel/slider runtime markup (Owl/Slick/Swiper artefacts) before save.
…DeleteMiniTemplateAssetsListenermeliscms_mini_template_manager_delete_endDeletes the template's CSS/JS/images.
…AttachAIGeneratedCssListenerMvcEvent::EVENT_FINISH (front + back)Injects AI CSS/JS into rendered pages.
…InjectDndAiButtonListenerMvcEvent::EVENT_FINISHInjects the Generate with AI button into legacy drag-and-drop zones.

The module also registers a MelisPluginRendererOverride so AI assets are injected correctly during plugin rendering.

MCP server

A stdio MCP server minitemplate_creator (entry point mcp/minitemplatecreator/bin/server.php) is registered in config['mcp']['servers']. The tools below are declared with mcp: true:

ToolParametersPurpose
readSiteAssetssiteModule, templateRequestReturns the site's relevant CSS/JS/view files so the AI matches the real design.
getSitePublicUrlsiteModuleReturns the site's public URL/domain for visual inspection before generating.
uploadMinitemplateImagessiteModule, image, filenameSaves an image (base64/data-URL/HTTP) under the AI temp dir and returns a web path for <img src>.
renderMinitemplatePreviewsiteModuleTriggers the editor preview of the generated template.

The minitemplatecreator agent also has the engine's filesystem tools (createFile / readFile / updateFiles / …) in its allow-list. Mid-conversation, the React dialog registers window.melisReactActionMap.preview_minitemplate so the engine can push the generated html block into the live preview when render_minitemplate_preview returns.

Database tables

This module creates no tables of its own. Its dbdeploy deltas insert rows into tables owned by melis-ai:

TableHolds
melis_ai_instancesThe seeded minitemplatecreator and newscontentcreator instances.
melis_ai_agentsThe seeded agents for the two instances.

At runtime, news data is accessed via NewsTable (getNewsData($newsId)), which joins the site table to resolve the siteModule needed to place generated images.

Key files

ConcernPath
Module config (MVC route, toolpage_extensions)vendor/melisplatform/melis-ai-community-extensions/config/module.config.php
Brick sourcevendor/melisplatform/melis-ai-community-extensions/ui-react/src/
Built brickvendor/melisplatform/melis-ai-community-extensions/public/ui-react/{brick.js, brick.manifest.json}
Page-edition frame bridgevendor/melisplatform/melis-ai-community-extensions/public/js/minitemplate/react-bridge.js
MCP tools declarationvendor/melisplatform/melis-ai-community-extensions/config/mcp.tools.php
Mini-template controllervendor/melisplatform/melis-ai-community-extensions/src/Controller/MiniTemplateController.php
News controllervendor/melisplatform/melis-ai-community-extensions/src/Controller/NewsController.php
"Old" view injectorvendor/melisplatform/melis-ai-community-extensions/src/Controller/React/PluginViewToolPageExtension.php
Listenersvendor/melisplatform/melis-ai-community-extensions/src/Listener/
Generate-with-AI button helpervendor/melisplatform/melis-ai-community-extensions/src/View/Helper/MelisGenerateWithAIBtnHelper.php
News table gatewayvendor/melisplatform/melis-ai-community-extensions/src/Model/Tables/NewsTable.php
MCP server entry pointvendor/melisplatform/melis-ai-community-extensions/mcp/minitemplatecreator/bin/server.php
AI assets directorypublic/miniTemplatesTinyMce/AI/{siteModule}/{temp|css|js|images}/
Install deltas (seed agents)vendor/melisplatform/melis-ai-community-extensions/install/dbdeploy/

See also: MelisAIEngine, MelisAI, MelisAIToolCreator, MelisCms, MelisCmsNews