ai-cms-grapesjs
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
- MaxymZorenkofromNinesquares
- Posts: 1
- Joined: 23 Mar 2026, 20:59
ai-cms-grapesjs
Mac, php 8.1, laravel 12.0, aimeos 2025.10.*
I need to create new blocks for ai-cms-grapesjs, but making changes to the custom.js of my own extension does not work.
example code that I made
document.addEventListener('aimeos.cms.editor', function(ev) {
const editor = ev.detail.editor;
// Блок "Hero Banner"
editor.BlockManager.add('hero-banner', {
label: 'Hero Banner',
category: 'Custom',
content: `
<section class="hero-banner" style="padding: 60px 20px; text-align: center; background: #1a1a2e; color: white;">
<h1>Заголовок</h1>
<p>Підзаголовок або короткий опис</p>
<a href="#" class="btn" style="display: inline-block; padding: 12px 30px; background: #e94560; color: white; text-decoration: none; border-radius: 5px;">Кнопка</a>
</section>
`
});
I need to create new blocks for ai-cms-grapesjs, but making changes to the custom.js of my own extension does not work.
example code that I made
document.addEventListener('aimeos.cms.editor', function(ev) {
const editor = ev.detail.editor;
// Блок "Hero Banner"
editor.BlockManager.add('hero-banner', {
label: 'Hero Banner',
category: 'Custom',
content: `
<section class="hero-banner" style="padding: 60px 20px; text-align: center; background: #1a1a2e; color: white;">
<h1>Заголовок</h1>
<p>Підзаголовок або короткий опис</p>
<a href="#" class="btn" style="display: inline-block; padding: 12px 30px; background: #e94560; color: white; text-decoration: none; border-radius: 5px;">Кнопка</a>
</section>
`
});
Re: ai-cms-grapesjs
This event doesn't exist. The GrapesJS editor is initialized inside a Vue component, and custom blocks/components are registered through a global configuration object, not through DOM events.MaxymZorenkofromNinesquares wrote: ↑23 Mar 2026, 21:06 document.addEventListener('aimeos.cms.editor', function(ev) {
// ...
});
The Correct Approach
To add custom blocks from your own extension, you need to:
1. In your extension's manifest.php, register a JSB2 manifest:
Code: Select all
'custom' => [
'admin/jqadm' => ['manifest.jsb2'],
]Code: Select all
{
"pkgs": [{
"name": "My Custom Blocks",
"file": "index-js",
"fileIncludes": [{
"text": "custom-blocks.js",
"path": "themes/admin/jqadm/"
}]
}]
}Code: Select all
Aimeos.CMSContent.GrapesJS.blocks['hero-banner'] = {
category: 'Custom',
label: 'Hero Banner',
content: '<section class="hero-banner">...</section>'
};If you also need custom component types (for traits/behaviors), add them to Aimeos.CMSContent.GrapesJS.components:
Code: Select all
Aimeos.CMSContent.GrapesJS.components['hero-banner'] = function(editor) {
editor.DomComponents.addType('hero-banner', { /* ... */ });
};
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,