Issue: Incorrect Handling of CSS Class Names with Special Characters in GrapesJS #5994
Isc-mntl-snchz
started this conversation in
General
Replies: 1 comment 2 replies
-
So yeah, it's not the first time there has been a complaint about this kind of issue, especially with Tailwind. I think it would make sense to make the default escaping strategy less strict. grapesjs.init({
// ...
selectorManager: {
escapeName: (name) => `${name}`.trim().replace(/\s+/g, '-'),
}
}) |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm working with Tailwind CSS, which allows the use of special characters in class names such as !max-h-[4rem]. However, when adding a custom trait for editing CSS classes, these special characters are being replaced with -, preventing the styles from being applied correctly to the canvas.
Custom Trait Code:
Issue Description:
When I add classes containing special characters (e.g., !max-h-[4rem]) through the custom trait, the characters are replaced with -. As a result, the styles are not applied correctly to the elements in the canvas.
Steps to Reproduce:
Expected Behavior:
The class name should be preserved as !max-h-[4rem].
Additional Observations:
When I open the class inspector, the class names appear normal, as shown in the trait.
However, when I log the class names using console.log('classes after manual class update:', component.get('classes'));, the characters are replaced as mentioned previously.

Additionally, if I run a command like command: "export-template", the characters are also replaced.
Questions:
Thank you for your assistance.
Beta Was this translation helpful? Give feedback.
All reactions