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