Issue #2005Opened May 8, 2019by benvmatheson0 reactions

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)

artfMay 11, 20190 reactions

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}` });
      	}
    });
benvmathesonMay 31, 20190 reactions

That's perfect. Thank you!

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...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.