aimeos / ai-cms-grapesjs

GrapesJS CMS integration into Aimeos
GNU Lesser General Public License v2.1
22 stars 18 forks source link

Customize extension ai-cms-grapesjs #11

Closed godadada closed 2 years ago

godadada commented 2 years ago

I would like to customize it. any references, examples, instructions I can use.

Thanks

aimeos commented 2 years ago

Not yet. This is the most interesting part for customization because it adds new blocks and components: https://github.com/aimeos/ai-cms-grapesjs/blob/master/admin/jqadm/themes/custom.js#L206-L626

You can add your own ones in the custom.js file of your own extension by adding:

Aimeos.CMSContent.GrapesJS.blocks.yourblock = {
    // ...
};

Aimeos.CMSContent.GrapesJS.components.yourcomponent = {
    // ...
};

For how GrapesJS works and what you can do, read the GrapesJS documentation:

Alababdiy commented 8 months ago

Not yet. This is the most interesting part for customization because it adds new blocks and components: https://github.com/aimeos/ai-cms-grapesjs/blob/master/admin/jqadm/themes/custom.js#L206-L626

You can add your own ones in the custom.js file of your own extension by adding:

Aimeos.CMSContent.GrapesJS.blocks.yourblock = {
    // ...
};

Aimeos.CMSContent.GrapesJS.components.yourcomponent = {
    // ...
};

For how GrapesJS works and what you can do, read the GrapesJS documentation:

how i c

Aimeos.CMSContent.GrapesJS.blocks.yourblock = { // ... };

Aimeos.CMSContent.GrapesJS.components.yourcomponent = { // ... };

Thanks @aimeos but when I try to add my custom component, is not showing and all the existing default elements disappear

*
 * Custom myext JS
 */
Aimeos.CMSContent.GrapesJS.blocks.yourblock = {
    label: "Your Block",
    category: "Custom Blocks",
    content: {
        type: "yourblock",
        components: {
            yourcomponent: {}
        },
        activeOnRender: true
    },
    render: ({ el }) => {
        el.innerHTML = "<div>Your Block Content Goes Here</div>";
    }
};

Aimeos.CMSContent.GrapesJS.components.yourcomponent = {
    label: "Your Component",
    content: {
        type: "yourcomponent",
        components: {},
    },
    render: ({ el }) => {
        el.innerHTML = "<div>Your Component Content Goes Here</div>";
    }
};

JFGq4wJ.md.png

aimeos commented 8 months ago

Most likely because of a JS error because your code is wrong. Check the examples to see how they must look like: Blocks: https://github.com/aimeos/ai-cms-grapesjs/blob/master/themes/admin/jqadm/custom.js#L229-L238 Components: https://github.com/aimeos/ai-cms-grapesjs/blob/master/themes/admin/jqadm/custom.js#L383-L412