@@ -1490,7 +1490,7 @@ class EditorFontSize extends SimpleEditorOption<EditorOption.fontSize, number> {
14901490//#region fontWeight
14911491
14921492class EditorFontWeight extends BaseEditorOption < EditorOption . fontWeight , string > {
1493- private static ENUM_VALUES = [ 'normal' , 'bold' , '100' , '200' , '300' , '400' , '500' , '600' , '700' , '800' , '900' ] ;
1493+ private static SUGGESTION_VALUES = [ 'normal' , 'bold' , '100' , '200' , '300' , '400' , '500' , '600' , '700' , '800' , '900' ] ;
14941494 private static MINIMUM_VALUE = 1 ;
14951495 private static MAXIMUM_VALUE = 1000 ;
14961496
@@ -1502,23 +1502,29 @@ class EditorFontWeight extends BaseEditorOption<EditorOption.fontWeight, string>
15021502 {
15031503 type : 'number' ,
15041504 minimum : EditorFontWeight . MINIMUM_VALUE ,
1505- maximum : EditorFontWeight . MAXIMUM_VALUE
1505+ maximum : EditorFontWeight . MAXIMUM_VALUE ,
1506+ errorMessage : nls . localize ( 'fontWeightErrorMessage' , "Only \"normal\" and \"bold\" keywords or numbers between 1 and 1000 are allowed." )
15061507 } ,
15071508 {
1508- enum : EditorFontWeight . ENUM_VALUES
1509+ type : 'string' ,
1510+ pattern : '^(normal|bold|1000|[1-9][0-9]{0,2})$'
1511+ } ,
1512+ {
1513+ enum : EditorFontWeight . SUGGESTION_VALUES
15091514 }
15101515 ] ,
15111516 default : EDITOR_FONT_DEFAULTS . fontWeight ,
1512- description : nls . localize ( 'fontWeight' , "Controls the font weight." )
1517+ description : nls . localize ( 'fontWeight' , "Controls the font weight. Accepts \"normal\" and \"bold\" keywords or numbers between 1 and 1000. " )
15131518 }
15141519 ) ;
15151520 }
15161521
15171522 public validate ( input : any ) : string {
1518- if ( typeof input === 'number ' ) {
1519- return EditorFontWeight . MINIMUM_VALUE <= input && input <= EditorFontWeight . MAXIMUM_VALUE ? String ( input ) : EDITOR_FONT_DEFAULTS . fontWeight ;
1523+ if ( input === 'normal' || input === 'bold ' ) {
1524+ return input ;
15201525 }
1521- return EditorStringEnumOption . stringSet < string > ( input , EDITOR_FONT_DEFAULTS . fontWeight , EditorFontWeight . ENUM_VALUES ) ;
1526+ const numericValue = Number ( input ) ;
1527+ return EditorFontWeight . MINIMUM_VALUE <= numericValue && numericValue <= EditorFontWeight . MAXIMUM_VALUE ? String ( numericValue ) : EDITOR_FONT_DEFAULTS . fontWeight ;
15221528 }
15231529}
15241530
0 commit comments