Can the editor be instructed to ignore a class?
Question
Once the editor creates HTML/CSS we hand it off to another piece of code. That piece of code relies on classes using a predetermined class name to perform actions on the HTML. (switching out placeholders for actual data etc.) If this class is added to an element, once that element is clicked, it attempts to add styles to this class. Is it possible to tell the editor to ignore a class?
Answers (3)
You could place a listener on a new selector
editor.on('selector:add', selector => {
const name = selector.get('name');
if (someConditionForSelectors(name)) {
selector.set({
// Can't be seen by the style manager, therefore even by the user
private: true,
})
}
});
What do you mean "to ignore"? To ignore where? Being available in the style manager or something else?
Sorry, I was unclear there. When clicking an element/block and proceeding to styling the element, the class is chosen by default. Could this class be deselected by default and hidden from the Classes field?

Related Questions and Answers
Continue research with similar issue discussions.
Issue #2596
[QUESTION] Add html, css and js to Block Manager
[QUESTION] Hi! I'm retrieving dynamic html,css and js codes from the database. How can I create Blocks with this? Currently, this is my cod...
Issue #1608
[Question] Customize CSS class name
GrapesJs editor creates a unique class for element and adds CSS rules to it. For example, Now, is there any way to customize this behaviour...
Issue #4529
When we resize an image with a class 'xyz', all the elements on the page with same class also gets resized because editor adds css to those classes.
GrapesJS version[X] I confirm to use the latest version of GrapesJSWhat browser are you using? Version 104.0.5112.101 (Official Build) (arm...
Issue #3832
The css classes are removed and the autogenerated ids for each html tags gets changed ( Example : ivj5m-2) after each reload
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome Reproducible demo link Not there De...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins →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.