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
-
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.
![imagen](https://private-user-images.githubusercontent.com/11996363/346218749-ef1fdfa2-13cb-43e2-bb13-26315a7c696a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwMTg0OTMsIm5iZiI6MTczOTAxODE5MywicGF0aCI6Ii8xMTk5NjM2My8zNDYyMTg3NDktZWYxZmRmYTItMTNjYi00M2UyLWJiMTMtMjYzMTVhN2M2OTZhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA4VDEyMzYzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWQ5ZDI5NzhiNWUwOTk5ZWJhNzhkYzE1ZWJjZjM1NjAxZjQyZGRiZTZhNzNmNmQzNTEwNWNhYThiNzI4OGQzZmUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.oj-ZmM5bI4hgoiCpEVsQgloZkz_F65b5qpGxH0BosH4)
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