File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
app/code/Magento/PageBuilder/view/adminhtml Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 184
184
<dataType >text</dataType >
185
185
<label translate =" true" >CSS Classes</label >
186
186
<notice translate =" true" >Space separated list of classes.</notice >
187
+ <validation >
188
+ <rule name =" validate-css-class" xsi : type =" boolean" >true</rule >
189
+ </validation >
187
190
</settings >
188
191
</field >
189
192
<field name =" margins_and_padding" sortOrder =" 70" formElement =" input" component =" Magento_PageBuilder/js/form/element/margins-and-padding" >
Original file line number Diff line number Diff line change @@ -52,6 +52,15 @@ define([
52
52
return ( / < a [ \s ] + ( [ ^ > ] + ) > | < a > | < \/ a > / igm) . test ( str ) ;
53
53
}
54
54
55
+ /**
56
+ * Validate that string is a proper css-class
57
+ * @param {String } str
58
+ * @return {Boolean }
59
+ */
60
+ function validateCssClass ( str ) {
61
+ return ( / ^ [ a - z A - Z _ \- \d ] + $ / i) . test ( str ) ;
62
+ }
63
+
55
64
/**
56
65
* Validate message field and url field anchor tag is used exclusively by one field
57
66
* @param {String } message
@@ -147,6 +156,18 @@ define([
147
156
$ . mage . __ ( 'Please enter a valid video URL.' )
148
157
) ;
149
158
159
+ validator . addRule (
160
+ 'validate-css-class' ,
161
+ function ( value ) {
162
+ if ( utils . isEmptyNoTrim ( value ) ) {
163
+ return true ;
164
+ }
165
+
166
+ return validateCssClass ( value ) ;
167
+ } ,
168
+ $ . mage . __ ( 'Please enter a valid CSS class.' )
169
+ ) ;
170
+
150
171
validator . addRule (
151
172
'required-entry' ,
152
173
function ( value ) {
You can’t perform that action at this time.
0 commit comments