Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflict between GrapesJS-generated classes with bootstrap classes #29

Closed
maynor96 opened this issue Feb 8, 2023 · 2 comments
Closed

Comments

@maynor96
Copy link
Contributor

maynor96 commented Feb 8, 2023

Hello!

When you add any style to the column component (for example: margins) from the GrapesJS style manager, the necessary styles are generated. However, these styles conflict with bootstrap classes.

You can see the following thread: GrapesJS/grapesjs#391

To solve this, I suggest adding the following code in the "initialize" method inside the GrapesJS object that is defined in the custom.js file:

`const prefix = 'cms-page-';

editor.on('selector:add', selector => {
    const name = selector.get('name');

    if (selector.get('type') === editor.SelectorManager.Selector.TYPE_CLASS &&
        name.indexOf(prefix) !== 0) {
        selector.set('name', prefix + name);
    }

});`

In this way the classes will be generated with the prefix: 'cms-page'. This would be very useful since we could define our own styles for the different visual components in the file: packages/custom-theme/themes/client/html/custom-theme/cms-page.css

What do you think about this approach?

Best regards!

@aimeos
Copy link
Owner

aimeos commented Feb 9, 2023

We've disable the style manager by default because instead allowing to change CSS styles directly, you should implement own components with all CSS classes already applied so editors are not able to break the design.

If you want to enable the style manager for any reason, you have to deal with such issues in your own code.

@maynor96
Copy link
Contributor Author

maynor96 commented Feb 9, 2023

Hello!

You are right, also developers should make the admin panel as intuitive as possible for the end customer. And certainly the style manager requires the client to know about css terms and properties like margins, paddings, etc.

I am going to disable the style manager and instead create components and have them styled with settings/traits.

This way I will add styles to the cms-page.css instead of adding the styles generated by grapesjs directly in the html (inline styles).

Regards!

@aimeos aimeos closed this as completed Feb 9, 2023
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

No branches or pull requests

2 participants