Issue #391✓ SolvedOpened October 7, 2017by tomichal7 reactions

Namespace CSS?

Quick answerby danfitz363

do you think you could just prefix all class names generated by grapejs? if instead of .row you use .grape-row or whatever (i'd probably make the prefix a variable), you'll mostly get the effect that @tomichal is after.

Read full answer below ↓

Question

Hi there, Is there a way to setup the grapesjs editor such that the CSS generated for the HTML content is namespaced? In other words, how to avoid the style rules defined for the content created/edited in the editor to leak out to the rest of the website page? In the case of my website the user can edit a large part of the page, but not all of it - the rest of the page HTML content and CSS is dynamically generated by the server (this is a Rails + Angular site). I find that if e.g. I use a row with columns, the CSS generated by grapesjs editor will have a definition for a "row" class (i.e. ".r...

Answers (3)

👍 Most helpfuldanfitz36October 10, 2017

do you think you could just prefix all class names generated by grapejs? if instead of .row you use .grape-row or whatever (i'd probably make the prefix a variable), you'll mostly get the effect that @tomichal is after.

artfMay 24, 2018

Actually, you can add a listener on new selectors and add a prefix there

devmohitagarwalNovember 4, 2019

HI, People looking to sandbox, prefix the exported CSS can give this a try, we had the same use case and took the sass approach. To do so, I used sass.js (https://github.com/medialize/sass.js/) Steps:enclose the cssString with your custom class. say MyCustomClass.Run sass.compile from the above lib...

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.

Browse premium plugins →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.