@@ -19,6 +19,7 @@ function Command(keyword, options, configs=null) {
19
19
this . keyword_ = keyword ;
20
20
this . options_ = options ;
21
21
this . configs_ = configs ;
22
+ this . icon_ = '' ;
22
23
} ;
23
24
Command . prototype . getHints = function ( token ) { return null } ;
24
25
Command . create = function ( definition , prefix = '/' ) {
@@ -37,15 +38,19 @@ Command.create = function(definition, prefix='/') {
37
38
}
38
39
39
40
// COMMAND: String
40
- function StringCommand ( keyword , options , configs = null ) { Command . call ( this , keyword , options , configs ) ; } ;
41
+ function StringCommand ( keyword , options , configs = null ) {
42
+ Command . call ( this , keyword , options , configs ) ;
43
+ this . icon_ = '𝐓' ;
44
+ } ;
41
45
StringCommand . prototype . getHints = function ( token ) {
42
46
if ( this . keyword_ !== token ) { return [ ] ; }
43
47
44
48
let hints = [ ] ;
49
+ let icon = this . icon_ ;
45
50
this . options_ . forEach ( option => {
46
51
hints . push ( {
47
52
text : option ,
48
- displayText : '𝐓 \t' + option . replace ( / \n / gm, "⏎" ) + ' ' ,
53
+ displayText : icon + ' \t' + option . replace ( / \n / gm, "⏎" ) + ' ' ,
49
54
hint : async ( cm , data , completion ) => {
50
55
const from = completion . from || data . from ;
51
56
cm . replaceRange ( option , from , cm . getCursor ( ) , "complete" ) ;
@@ -58,6 +63,7 @@ StringCommand.prototype.getHints = function (token) {
58
63
// COMMAND: Datetime
59
64
function DatetimeCommand ( keyword , options , configs = null ) {
60
65
Command . call ( this , keyword , options , configs ) ;
66
+ this . icon_ = '🕒' ;
61
67
} ;
62
68
DatetimeCommand . prototype . getHints = function ( token ) {
63
69
if ( this . keyword_ > token . length ) { return [ ] ; }
@@ -147,11 +153,12 @@ DatetimeCommand.prototype.getHints = function (token) {
147
153
} else {
148
154
dateFormat . i18n = I18N_ ;
149
155
}
156
+ let icon = this . icon_ ;
150
157
this . options_ . forEach ( option => {
151
158
let text = dateFormat ( dt , option ) ;
152
159
hints . push ( {
153
160
text : text ,
154
- displayText : '🕒 \t' + text + ' ' ,
161
+ displayText : icon + ' \t' + text + ' ' ,
155
162
hint : async ( cm , data , completion ) => {
156
163
const from = completion . from || data . from ;
157
164
cm . replaceRange ( text , from , cm . getCursor ( ) , "complete" ) ;
@@ -162,7 +169,10 @@ DatetimeCommand.prototype.getHints = function (token) {
162
169
} ;
163
170
164
171
165
- function CalendarCommand ( keyword , options , configs = null ) { Command . call ( this , keyword , options , configs ) ; } ;
172
+ function CalendarCommand ( keyword , options , configs = null ) {
173
+ Command . call ( this , keyword , options , configs ) ;
174
+ this . icon_ = '📅' ;
175
+ } ;
166
176
CalendarCommand . prototype . getHints = function ( token ) {
167
177
if ( this . keyword_ > token . length ) { return [ ] ; }
168
178
if ( this . keyword_ !== token . slice ( 0 , this . keyword_ . length ) ) { return [ ] ; }
@@ -187,6 +197,7 @@ CalendarCommand.prototype.getHints = function (token) {
187
197
188
198
let hints = [ ] ;
189
199
let date = new Date ( year , month , 1 ) ;
200
+ let icon = this . icon_ ;
190
201
this . options_ . forEach ( option => {
191
202
let text = "" ;
192
203
let display = "" ;
@@ -197,14 +208,14 @@ CalendarCommand.prototype.getHints = function (token) {
197
208
text += asciiCalendar ( year , month , lang ) ;
198
209
text += "\n\n" ;
199
210
} )
200
- display = `📅 \t${ month + 1 } ${ year } (DEBUG - all locales)` ;
211
+ display = `${ icon } \t${ month + 1 } ${ year } (DEBUG - all locales)` ;
201
212
} else if ( LOCALES_ . includes ( option ) ) {
202
213
text = asciiCalendar ( year , month , option ) ;
203
- display = `📅 \t${ date . toLocaleString ( option , { month : 'long' } ) } ${ year } (${ option } )` ;
214
+ display = `${ icon } \t${ date . toLocaleString ( option , { month : 'long' } ) } ${ year } (${ option } )` ;
204
215
} else {
205
216
let lang = typeof window !== 'undefined' ? window . navigator . language : undefined
206
217
text = asciiCalendar ( year , month , lang ) ;
207
- display = `📅 \t${ date . toLocaleString ( lang , { month : 'long' } ) } ${ year } (${ option } → ${ lang } )` ;
218
+ display = `${ icon } \t${ date . toLocaleString ( lang , { month : 'long' } ) } ${ year } (${ option } → ${ lang } )` ;
208
219
}
209
220
hints . push ( {
210
221
text : text ,
0 commit comments