@@ -31,6 +31,7 @@ export interface IToolbarItemConfig {
31
31
template ?: any ;
32
32
component ?: any ;
33
33
shortKey ?: string ;
34
+ shortKeyWithCode ?: string ;
34
35
params ?: { [ key : string ] : any } ;
35
36
handler ?( editor ?: any , params ?: any ) : void ;
36
37
}
@@ -277,93 +278,107 @@ class ToolBarHandler {
277
278
static color = ( ) : void => { } ;
278
279
}
279
280
281
+ export const CTRL_KEY = navigator ?. platform ?. indexOf ( 'Mac' ) !== - 1 ? '⌘' : 'Ctrl' ;
282
+ export const ALT_KEY = navigator ?. platform ?. indexOf ( 'Mac' ) !== - 1 ? '⌥' : 'Alt' ;
283
+
280
284
export const DEFAULT_TOOLBARS : Record < string , IToolbarItemConfig > = {
281
285
undo : {
282
286
id : 'undo' ,
283
287
name : 'undo' ,
284
288
type : 'button' ,
285
289
icon : UNDO_ICON ,
286
- shortKey : 'Ctrl+Z' ,
290
+ shortKey : `${ CTRL_KEY } +Z` ,
291
+ shortKeyWithCode : `${ CTRL_KEY } +90` ,
287
292
handler : ToolBarHandler . undo ,
288
293
} ,
289
294
redo : {
290
295
id : 'redo' ,
291
296
name : 'redo' ,
292
297
type : 'button' ,
293
298
icon : REDO_ICON ,
294
- shortKey : 'Ctrl+Y' ,
299
+ shortKey : `${ CTRL_KEY } +Y` ,
300
+ shortKeyWithCode : `${ CTRL_KEY } +89` ,
295
301
handler : ToolBarHandler . redo ,
296
302
} ,
297
303
bold : {
298
304
id : 'bold' ,
299
305
name : 'bold' ,
300
306
type : 'button' ,
301
307
icon : BOLD_ICON ,
302
- shortKey : 'Ctrl+B' ,
308
+ shortKey : `${ CTRL_KEY } +B` ,
309
+ shortKeyWithCode : `${ CTRL_KEY } +66` ,
303
310
handler : ToolBarHandler . bold ,
304
311
} ,
305
312
italic : {
306
313
id : 'italic' ,
307
314
name : 'italic' ,
308
315
type : 'button' ,
309
316
icon : ITALIC_ICON ,
310
- shortKey : 'Ctrl+I' ,
317
+ shortKey : `${ CTRL_KEY } +I` ,
318
+ shortKeyWithCode : `${ CTRL_KEY } +73` ,
311
319
handler : ToolBarHandler . italic ,
312
320
} ,
313
321
strike : {
314
322
id : 'strike' ,
315
323
name : 'strike' ,
316
324
type : 'button' ,
317
325
icon : STRIKE_ICON ,
318
- shortKey : 'Ctrl+D' ,
326
+ shortKey : `${ CTRL_KEY } +D` ,
327
+ shortKeyWithCode : `${ CTRL_KEY } +68` ,
319
328
handler : ToolBarHandler . strike ,
320
329
} ,
321
330
h1 : {
322
331
id : 'h1' ,
323
332
name : 'h1' ,
324
333
type : 'button' ,
325
334
icon : H1_ICON ,
326
- shortKey : 'Ctrl+1' ,
335
+ shortKey : `${ CTRL_KEY } +1` ,
336
+ shortKeyWithCode : `${ CTRL_KEY } +49` ,
327
337
handler : ToolBarHandler . h1 ,
328
338
} ,
329
339
h2 : {
330
340
id : 'h2' ,
331
341
name : 'h2' ,
332
342
type : 'button' ,
333
343
icon : H2_ICON ,
334
- shortKey : 'Ctrl+2' ,
344
+ shortKey : `${ CTRL_KEY } +2` ,
345
+ shortKeyWithCode : `${ CTRL_KEY } +50` ,
335
346
handler : ToolBarHandler . h2 ,
336
347
} ,
337
348
ul : {
338
349
id : 'ul' ,
339
350
name : 'unorderedlist' ,
340
351
type : 'button' ,
341
352
icon : LIST_UNORDERED_ICON ,
342
- shortKey : 'Ctrl+U' ,
353
+ shortKey : `${ CTRL_KEY } +U` ,
354
+ shortKeyWithCode : `${ CTRL_KEY } +85` ,
343
355
handler : ToolBarHandler . ul ,
344
356
} ,
345
357
ol : {
346
358
id : 'ol' ,
347
359
name : 'orderedlist' ,
348
360
type : 'button' ,
349
361
icon : LIST_ORDERED_ICON ,
350
- shortKey : 'Ctrl+O' ,
362
+ shortKey : `${ CTRL_KEY } +O` ,
363
+ shortKeyWithCode : `${ CTRL_KEY } +79` ,
351
364
handler : ToolBarHandler . ol ,
352
365
} ,
353
366
checklist : {
354
367
id : 'checklist' ,
355
368
name : 'checklist' ,
356
369
type : 'button' ,
357
370
icon : LIST_CHECK_ICON ,
358
- shortKey : 'Ctrl+Alt+C' ,
371
+ shortKey : `${ CTRL_KEY } +${ ALT_KEY } +C` ,
372
+ shortKeyWithCode : `${ CTRL_KEY } +${ ALT_KEY } +67` ,
359
373
handler : ToolBarHandler . checkList ,
360
374
} ,
361
375
underline : {
362
376
id : 'underline' ,
363
377
name : 'underline' ,
364
378
type : 'button' ,
365
379
icon : UNDERLINE_ICON ,
366
- shortKey : 'Ctrl+R' ,
380
+ shortKey : `${ CTRL_KEY } +R` ,
381
+ shortKeyWithCode : `${ CTRL_KEY } +82` ,
367
382
handler : ToolBarHandler . underline ,
368
383
} ,
369
384
font : {
@@ -379,15 +394,17 @@ export const DEFAULT_TOOLBARS: Record<string, IToolbarItemConfig> = {
379
394
name : 'link' ,
380
395
type : 'button' ,
381
396
icon : LINK_ICON ,
382
- shortKey : 'Ctrl+L' ,
397
+ shortKey : `${ CTRL_KEY } +L` ,
398
+ shortKeyWithCode : `${ CTRL_KEY } +76` ,
383
399
handler : ToolBarHandler . link ,
384
400
} ,
385
401
image : {
386
402
id : 'image' ,
387
403
name : 'image' ,
388
404
type : 'button' ,
389
405
icon : IMAGE_ICON ,
390
- shortKey : 'Ctrl+G' ,
406
+ shortKey : `${ CTRL_KEY } +G` ,
407
+ shortKeyWithCode : `${ CTRL_KEY } +71` ,
391
408
params : { imageUploadToServer : false } ,
392
409
handler : ToolBarHandler . image ,
393
410
} ,
@@ -397,23 +414,26 @@ export const DEFAULT_TOOLBARS: Record<string, IToolbarItemConfig> = {
397
414
type : 'button' ,
398
415
icon : FILE_ICON ,
399
416
params : { } ,
400
- shortKey : 'Ctrl+F' ,
417
+ shortKey : `${ CTRL_KEY } +F` ,
418
+ shortKeyWithCode : `${ CTRL_KEY } +70` ,
401
419
handler : ToolBarHandler . file ,
402
420
} ,
403
421
code : {
404
422
id : 'code' ,
405
423
name : 'code' ,
406
424
type : 'button' ,
407
425
icon : CODE_ICON ,
408
- shortKey : 'Ctrl+K' ,
426
+ shortKey : `${ CTRL_KEY } +K` ,
427
+ shortKeyWithCode : `${ CTRL_KEY } +75` ,
409
428
handler : ToolBarHandler . code ,
410
429
} ,
411
430
table : {
412
431
id : 'table' ,
413
432
name : 'table' ,
414
433
type : 'button' ,
415
434
icon : TABLE_ICON ,
416
- shortKey : 'Ctrl+Alt+T' ,
435
+ shortKey : `${ CTRL_KEY } +${ ALT_KEY } +T` ,
436
+ shortKeyWithCode : `${ CTRL_KEY } +${ ALT_KEY } +84` ,
417
437
handler : ToolBarHandler . table ,
418
438
} ,
419
439
fullscreen : {
0 commit comments