Invalid class names allowed
Question
When adding a class name, the editor allows you to create class names that are invalid in CSS, but valid in HTML (e.g. 123). As adding class names with this tool is primarily meant for styling, it may make sense to add a warning when the class name is invalid for CSS.
Answers (2)
You can add this kind of warning (and even apply your logic to fix the invalid name) by yourself by using selector:add event
editor.on('selector:add', selector => {
const name = selector.get('name');
if (nameNotValid(name)) {
alert('Class changed');
selector.set({ name: `fixed-${name}` });
}
});
That's perfect. Thank you!
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 #2177
How to create a block with HTML and CSS and javascript content.
Can somebody please show me a code example of how to create a block with javascript and css styles. The main problem is that the js code is...
Issue #2008
[Question]The canvas turns dark and unmodifiable on adding a large piece of custom html.
I used to add custom html with editor.addComponent(). It works well at most of the time, but when I try to insert a large piece of HTML whi...
Issue #1670
Adding default Layout in grapejs
When I open the grapejs editor for the first time it appears as white-board. I need to add default HTML layout (columns) like in this photo...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.