@lvce-editor/title-bar-worker 4.9.0 → 4.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/titleBarWorkerMain.js +169 -76
- package/package.json +1 -1
|
@@ -598,7 +598,10 @@ const constructError = (message, type, name) => {
|
|
|
598
598
|
if (ErrorConstructor === Error) {
|
|
599
599
|
const error = new Error(message);
|
|
600
600
|
if (name && name !== 'VError') {
|
|
601
|
-
error
|
|
601
|
+
Object.defineProperty(error, 'name', {
|
|
602
|
+
configurable: true,
|
|
603
|
+
value: name
|
|
604
|
+
});
|
|
602
605
|
}
|
|
603
606
|
return error;
|
|
604
607
|
}
|
|
@@ -629,31 +632,45 @@ const getParentStack = error => {
|
|
|
629
632
|
};
|
|
630
633
|
const MethodNotFound = -32601;
|
|
631
634
|
const Custom = -32001;
|
|
635
|
+
const setStack = (error, stack) => {
|
|
636
|
+
const descriptor = Object.getOwnPropertyDescriptor(error, 'stack');
|
|
637
|
+
if (descriptor) {
|
|
638
|
+
if (!descriptor.configurable && !descriptor.writable) {
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
641
|
+
if (!descriptor.configurable && descriptor.writable) {
|
|
642
|
+
error.stack = stack;
|
|
643
|
+
return;
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
Object.defineProperty(error, 'stack', {
|
|
647
|
+
configurable: true,
|
|
648
|
+
value: stack,
|
|
649
|
+
writable: true
|
|
650
|
+
});
|
|
651
|
+
};
|
|
632
652
|
const restoreExistingError = (error, currentStack) => {
|
|
633
653
|
if (typeof error.stack === 'string') {
|
|
634
|
-
error
|
|
654
|
+
setStack(error, `${error.stack}${NewLine}${currentStack}`);
|
|
635
655
|
}
|
|
636
656
|
return error;
|
|
637
657
|
};
|
|
638
658
|
const restoreMethodNotFoundError = (error, currentStack) => {
|
|
639
659
|
const restoredError = new JsonRpcError(error.message);
|
|
640
660
|
const parentStack = getParentStack(error);
|
|
641
|
-
restoredError
|
|
661
|
+
setStack(restoredError, `${parentStack}${NewLine}${currentStack}`);
|
|
642
662
|
return restoredError;
|
|
643
663
|
};
|
|
644
664
|
const restoreStackFromData = (restoredError, error, currentStack) => {
|
|
645
665
|
if (error.data.stack && error.data.type && error.message) {
|
|
646
|
-
restoredError
|
|
666
|
+
setStack(restoredError, `${error.data.type}: ${error.message}${NewLine}${error.data.stack}${NewLine}${currentStack}`);
|
|
647
667
|
return;
|
|
648
668
|
}
|
|
649
669
|
if (error.data.stack) {
|
|
650
|
-
restoredError
|
|
670
|
+
setStack(restoredError, error.data.stack);
|
|
651
671
|
}
|
|
652
672
|
};
|
|
653
673
|
const applyDataProperties = (restoredError, error) => {
|
|
654
|
-
if (!error.data) {
|
|
655
|
-
return;
|
|
656
|
-
}
|
|
657
674
|
restoreStackFromData(restoredError, error, getCurrentStack());
|
|
658
675
|
if (error.data.codeFrame) {
|
|
659
676
|
// @ts-ignore
|
|
@@ -674,7 +691,7 @@ const applyDirectProperties = (restoredError, error) => {
|
|
|
674
691
|
const indexNewLine = getNewLineIndex(lowerStack);
|
|
675
692
|
const parentStack = getParentStack(error);
|
|
676
693
|
// @ts-ignore
|
|
677
|
-
restoredError
|
|
694
|
+
setStack(restoredError, `${parentStack}${lowerStack.slice(indexNewLine)}`);
|
|
678
695
|
}
|
|
679
696
|
if (error.codeFrame) {
|
|
680
697
|
// @ts-ignore
|
|
@@ -1358,9 +1375,9 @@ const F5$1 = 61;
|
|
|
1358
1375
|
const F6$1 = 62;
|
|
1359
1376
|
const Equal$1 = 84;
|
|
1360
1377
|
const Comma$1 = 85;
|
|
1361
|
-
const Minus$
|
|
1362
|
-
const Backquote$
|
|
1363
|
-
const Backslash$
|
|
1378
|
+
const Minus$2 = 86;
|
|
1379
|
+
const Backquote$2 = 89;
|
|
1380
|
+
const Backslash$2 = 91;
|
|
1364
1381
|
const Star$1 = 131;
|
|
1365
1382
|
const Plus$1 = 132;
|
|
1366
1383
|
|
|
@@ -1424,15 +1441,15 @@ const F5 = 'F5';
|
|
|
1424
1441
|
const F6 = 'F6';
|
|
1425
1442
|
const Equal = '=';
|
|
1426
1443
|
const Comma = ',';
|
|
1427
|
-
const Minus = 'Minus';
|
|
1428
|
-
const Backquote = 'Backquote';
|
|
1429
|
-
const Backslash = 'Backslash';
|
|
1444
|
+
const Minus$1 = 'Minus';
|
|
1445
|
+
const Backquote$1 = 'Backquote';
|
|
1446
|
+
const Backslash$1 = 'Backslash';
|
|
1430
1447
|
const Star = '*';
|
|
1431
1448
|
const Plus = '+';
|
|
1432
1449
|
|
|
1433
1450
|
const keyCodeStringMap = {
|
|
1434
|
-
[Backquote$
|
|
1435
|
-
[Backslash$
|
|
1451
|
+
[Backquote$2]: Backquote$1,
|
|
1452
|
+
[Backslash$2]: Backslash$1,
|
|
1436
1453
|
[Backspace$1]: Backspace,
|
|
1437
1454
|
[Comma$1]: Comma,
|
|
1438
1455
|
[Delete$1]: Delete,
|
|
@@ -1486,7 +1503,7 @@ const keyCodeStringMap = {
|
|
|
1486
1503
|
[KeyY$1]: KeyY,
|
|
1487
1504
|
[KeyZ$1]: KeyZ,
|
|
1488
1505
|
[LeftArrow$1]: LeftArrow,
|
|
1489
|
-
[Minus$
|
|
1506
|
+
[Minus$2]: Minus$1,
|
|
1490
1507
|
[PageDown$1]: PageDown,
|
|
1491
1508
|
[PageUp$1]: PageUp,
|
|
1492
1509
|
[Plus$1]: Plus,
|
|
@@ -2342,12 +2359,12 @@ const selectAllOccurrences = () => {
|
|
|
2342
2359
|
|
|
2343
2360
|
const getMenuEntries$d = () => {
|
|
2344
2361
|
return [{
|
|
2345
|
-
command:
|
|
2362
|
+
command: 'Editor.undo',
|
|
2346
2363
|
flags: None,
|
|
2347
2364
|
id: 'undo',
|
|
2348
2365
|
label: undo()
|
|
2349
2366
|
}, {
|
|
2350
|
-
command:
|
|
2367
|
+
command: 'Editor.redo',
|
|
2351
2368
|
flags: None,
|
|
2352
2369
|
id: 'redo',
|
|
2353
2370
|
label: redo()
|
|
@@ -2381,79 +2398,79 @@ const getMenuEntries$d = () => {
|
|
|
2381
2398
|
|
|
2382
2399
|
const getMenuEntries$c = () => {
|
|
2383
2400
|
return [{
|
|
2384
|
-
command: '
|
|
2401
|
+
command: 'Main.splitUp',
|
|
2385
2402
|
flags: None,
|
|
2386
2403
|
id: 'splitUp',
|
|
2387
2404
|
keyboardShortCut: 'Ctrl+K Ctrl+\\',
|
|
2388
2405
|
label: i18nString(SplitUp)
|
|
2389
2406
|
}, {
|
|
2390
|
-
command: '
|
|
2407
|
+
command: 'Main.splitDown',
|
|
2391
2408
|
flags: None,
|
|
2392
2409
|
id: 'splitDown',
|
|
2393
2410
|
label: i18nString(SplitDown)
|
|
2394
2411
|
}, {
|
|
2395
|
-
command: '
|
|
2412
|
+
command: 'Main.splitLeft',
|
|
2396
2413
|
flags: None,
|
|
2397
2414
|
id: 'splitLeft',
|
|
2398
2415
|
label: i18nString(SplitLeft)
|
|
2399
2416
|
}, {
|
|
2400
|
-
command: '
|
|
2417
|
+
command: 'Main.splitRight',
|
|
2401
2418
|
flags: None,
|
|
2402
2419
|
id: 'splitRight',
|
|
2403
2420
|
label: i18nString(SplitRight)
|
|
2404
2421
|
}, menuEntrySeparator, {
|
|
2405
|
-
command: '
|
|
2422
|
+
command: 'Main.moveIntoNewWindow',
|
|
2406
2423
|
flags: None,
|
|
2407
2424
|
id: 'moveEditorIntoNewWindow',
|
|
2408
2425
|
label: i18nString(MoveEditorIntoNewWindow)
|
|
2409
2426
|
}, {
|
|
2410
|
-
command: '
|
|
2427
|
+
command: 'Main.copyIntoNewWindow',
|
|
2411
2428
|
flags: None,
|
|
2412
2429
|
id: 'copyEditorIntoNewWindow',
|
|
2413
2430
|
keyboardShortCut: 'Ctrl+K O',
|
|
2414
2431
|
label: i18nString(CopyEditorIntoNewWindow)
|
|
2415
2432
|
}, menuEntrySeparator, {
|
|
2416
|
-
command: '
|
|
2433
|
+
command: 'Main.setEditorLayoutSingle',
|
|
2417
2434
|
flags: None,
|
|
2418
2435
|
id: 'single',
|
|
2419
2436
|
label: i18nString(Single)
|
|
2420
2437
|
}, {
|
|
2421
|
-
command: '
|
|
2438
|
+
command: 'Main.setEditorLayoutTwoColumns',
|
|
2422
2439
|
flags: None,
|
|
2423
2440
|
id: 'twoColumns',
|
|
2424
2441
|
label: i18nString(TwoColumns)
|
|
2425
2442
|
}, {
|
|
2426
|
-
command: '
|
|
2443
|
+
command: 'Main.setEditorLayoutThreeColumns',
|
|
2427
2444
|
flags: None,
|
|
2428
2445
|
id: 'threeColumns',
|
|
2429
2446
|
label: i18nString(ThreeColumns)
|
|
2430
2447
|
}, {
|
|
2431
|
-
command: '
|
|
2448
|
+
command: 'Main.setEditorLayoutTwoRows',
|
|
2432
2449
|
flags: None,
|
|
2433
2450
|
id: 'twoRows',
|
|
2434
2451
|
label: i18nString(TwoRows)
|
|
2435
2452
|
}, {
|
|
2436
|
-
command: '
|
|
2453
|
+
command: 'Main.setEditorLayoutThreeRows',
|
|
2437
2454
|
flags: None,
|
|
2438
2455
|
id: 'threeRows',
|
|
2439
2456
|
label: i18nString(ThreeRows)
|
|
2440
2457
|
}, {
|
|
2441
|
-
command: '
|
|
2458
|
+
command: 'Main.setEditorLayoutGrid',
|
|
2442
2459
|
flags: None,
|
|
2443
2460
|
id: 'gridTwoByTwo',
|
|
2444
2461
|
label: i18nString(GridTwoByTwo)
|
|
2445
2462
|
}, {
|
|
2446
|
-
command: '
|
|
2463
|
+
command: 'Main.setEditorLayoutTwoRowsRight',
|
|
2447
2464
|
flags: None,
|
|
2448
2465
|
id: 'twoRowsRight',
|
|
2449
2466
|
label: i18nString(TwoRowsRight)
|
|
2450
2467
|
}, {
|
|
2451
|
-
command: '
|
|
2468
|
+
command: 'Main.setEditorLayoutTwoColumnsBottom',
|
|
2452
2469
|
flags: None,
|
|
2453
2470
|
id: 'twoColumnsBottom',
|
|
2454
2471
|
label: i18nString(TwoColumnsBottom)
|
|
2455
2472
|
}, menuEntrySeparator, {
|
|
2456
|
-
command: '
|
|
2473
|
+
command: 'Main.flipEditorLayout',
|
|
2457
2474
|
flags: None,
|
|
2458
2475
|
id: 'flipLayout',
|
|
2459
2476
|
keyboardShortCut: 'Shift+Alt+8',
|
|
@@ -3490,6 +3507,34 @@ const getTitleBarIndexFromPosition = (titleBarEntries, x, y) => {
|
|
|
3490
3507
|
return -1;
|
|
3491
3508
|
};
|
|
3492
3509
|
|
|
3510
|
+
const toCommandInfo = entry => {
|
|
3511
|
+
return {
|
|
3512
|
+
args: entry.args,
|
|
3513
|
+
command: entry.command
|
|
3514
|
+
};
|
|
3515
|
+
};
|
|
3516
|
+
const addMenuEntryKeyBindings = async entries => {
|
|
3517
|
+
try {
|
|
3518
|
+
const commands = entries.map(toCommandInfo);
|
|
3519
|
+
const keys = await invoke('Layout.getKeyBindings', commands);
|
|
3520
|
+
if (!keys.some(Boolean)) {
|
|
3521
|
+
return entries;
|
|
3522
|
+
}
|
|
3523
|
+
return entries.map((entry, index) => {
|
|
3524
|
+
const key = keys[index];
|
|
3525
|
+
if (!key) {
|
|
3526
|
+
return entry;
|
|
3527
|
+
}
|
|
3528
|
+
return {
|
|
3529
|
+
...entry,
|
|
3530
|
+
key
|
|
3531
|
+
};
|
|
3532
|
+
});
|
|
3533
|
+
} catch {
|
|
3534
|
+
return entries;
|
|
3535
|
+
}
|
|
3536
|
+
};
|
|
3537
|
+
|
|
3493
3538
|
const getTotalWidth = entries => {
|
|
3494
3539
|
let total = 0;
|
|
3495
3540
|
for (const entry of entries) {
|
|
@@ -3601,10 +3646,11 @@ const openMenuAtIndex = async (state, index, shouldBeFocused) => {
|
|
|
3601
3646
|
const {
|
|
3602
3647
|
id
|
|
3603
3648
|
} = titleBarEntry;
|
|
3604
|
-
const
|
|
3649
|
+
const rawItems = id === OverflowMenuId ? getOverflowMenuItems(titleBarEntry.hiddenEntries || []) : await getMenuEntries2(state, {
|
|
3605
3650
|
menuId: id,
|
|
3606
3651
|
platform
|
|
3607
3652
|
});
|
|
3653
|
+
const items = id === OverflowMenuId ? rawItems : await addMenuEntryKeyBindings(rawItems);
|
|
3608
3654
|
const relevantEntries = titleBarEntries.slice(0, index);
|
|
3609
3655
|
const totalWidths = getTotalWidth(relevantEntries);
|
|
3610
3656
|
const offset = totalWidths;
|
|
@@ -3922,6 +3968,7 @@ const renderFocusedIndex = (oldState, newState) => {
|
|
|
3922
3968
|
};
|
|
3923
3969
|
|
|
3924
3970
|
const MaskIconCheck = 'MaskIconCheck';
|
|
3971
|
+
const MaskIcon = 'MaskIcon';
|
|
3925
3972
|
const Menu = 'Menu';
|
|
3926
3973
|
const MenuItem = 'MenuItem';
|
|
3927
3974
|
const MenuItemCheckMark = 'MenuItemCheckMark';
|
|
@@ -3933,6 +3980,7 @@ const MenuItemSeparatorLine = 'MenuItemSeparatorLine';
|
|
|
3933
3980
|
const MenuItemSubMenu = 'MenuItemSubMenu';
|
|
3934
3981
|
const MenuItemSubMenuArrowRight = 'MenuItemSubMenuArrowRight';
|
|
3935
3982
|
const TitleBar = 'TitleBar';
|
|
3983
|
+
const TitleBarButton = 'TitleBarButton';
|
|
3936
3984
|
const TitleBarButtons = 'TitleBarButtons';
|
|
3937
3985
|
const TitleBarEntryActive = 'TitleBarEntryActive';
|
|
3938
3986
|
const TitleBarIcon = 'TitleBarIcon';
|
|
@@ -3942,42 +3990,53 @@ const TitleBarTopLevelEntry = 'TitleBarTopLevelEntry';
|
|
|
3942
3990
|
const TitleBarTopLevelEntryLabel = 'TitleBarTopLevelEntryLabel';
|
|
3943
3991
|
const Viewlet = 'Viewlet';
|
|
3944
3992
|
|
|
3945
|
-
const checkMark = {
|
|
3946
|
-
className: mergeClassNames(MenuItemCheckmarkIcon, MaskIconCheck),
|
|
3947
|
-
type: Div
|
|
3948
|
-
};
|
|
3949
|
-
const getMenuItemCheckedDom = menuItem => {
|
|
3950
|
-
const {
|
|
3951
|
-
isFocused,
|
|
3952
|
-
label
|
|
3953
|
-
} = menuItem;
|
|
3954
|
-
const baseClassName = mergeClassNames(MenuItem, MenuItemCheckMark);
|
|
3955
|
-
const className = isFocused ? mergeClassNames(baseClassName, MenuItemFocused) : baseClassName;
|
|
3956
|
-
return [{
|
|
3957
|
-
ariaChecked: true,
|
|
3958
|
-
childCount: 2,
|
|
3959
|
-
className,
|
|
3960
|
-
role: MenuItemCheckBox,
|
|
3961
|
-
tabIndex: -1,
|
|
3962
|
-
type: Div
|
|
3963
|
-
}, checkMark, text(label)];
|
|
3964
|
-
};
|
|
3965
|
-
|
|
3966
3993
|
const getKeyBindingString = (key, altKey, ctrlKey, shiftKey, metaKey) => {
|
|
3967
3994
|
let string = '';
|
|
3968
3995
|
if (ctrlKey) {
|
|
3969
3996
|
string += 'Ctrl+';
|
|
3970
3997
|
}
|
|
3998
|
+
if (altKey) {
|
|
3999
|
+
string += 'Alt+';
|
|
4000
|
+
}
|
|
3971
4001
|
if (shiftKey) {
|
|
3972
4002
|
string += 'Shift+';
|
|
3973
4003
|
}
|
|
3974
|
-
string += key.toUpperCase();
|
|
4004
|
+
string += key.length === 1 ? key.toUpperCase() : key;
|
|
3975
4005
|
return string;
|
|
3976
4006
|
};
|
|
3977
4007
|
|
|
4008
|
+
const F11 = 67;
|
|
4009
|
+
const Minus = 86;
|
|
4010
|
+
const Slash = 88;
|
|
4011
|
+
const Backquote = 89;
|
|
4012
|
+
const Backslash = 91;
|
|
4013
|
+
const Numpad0 = 96;
|
|
4014
|
+
|
|
4015
|
+
const getKeyLabel = (keyCode, fallback) => {
|
|
4016
|
+
switch (keyCode) {
|
|
4017
|
+
case Backquote:
|
|
4018
|
+
return '`';
|
|
4019
|
+
case Backslash:
|
|
4020
|
+
return '\\';
|
|
4021
|
+
case F11:
|
|
4022
|
+
return 'F11';
|
|
4023
|
+
case Minus:
|
|
4024
|
+
return '-';
|
|
4025
|
+
case Numpad0:
|
|
4026
|
+
return 'NumPad0';
|
|
4027
|
+
case Slash:
|
|
4028
|
+
return '/';
|
|
4029
|
+
default:
|
|
4030
|
+
return fallback;
|
|
4031
|
+
}
|
|
4032
|
+
};
|
|
4033
|
+
|
|
4034
|
+
const altKeyMask = 1 << 9;
|
|
3978
4035
|
const getKeyDom = key => {
|
|
3979
4036
|
const parsedKey = parseKey(key);
|
|
3980
|
-
const
|
|
4037
|
+
const isAlt = Boolean(key & altKeyMask);
|
|
4038
|
+
const keyLabel = getKeyLabel(key & 0xff, parsedKey.key);
|
|
4039
|
+
const keyBindingsString = getKeyBindingString(keyLabel, isAlt, parsedKey.isCtrl, parsedKey.isShift);
|
|
3981
4040
|
return [{
|
|
3982
4041
|
childCount: 1,
|
|
3983
4042
|
className: MenuItemKeyBinding,
|
|
@@ -3985,6 +4044,29 @@ const getKeyDom = key => {
|
|
|
3985
4044
|
}, text(keyBindingsString)];
|
|
3986
4045
|
};
|
|
3987
4046
|
|
|
4047
|
+
const checkMark = {
|
|
4048
|
+
className: mergeClassNames(MenuItemCheckmarkIcon, MaskIconCheck),
|
|
4049
|
+
type: Div
|
|
4050
|
+
};
|
|
4051
|
+
const getMenuItemCheckedDom = menuItem => {
|
|
4052
|
+
const {
|
|
4053
|
+
isFocused,
|
|
4054
|
+
key,
|
|
4055
|
+
label
|
|
4056
|
+
} = menuItem;
|
|
4057
|
+
const baseClassName = mergeClassNames(MenuItem, MenuItemCheckMark);
|
|
4058
|
+
const className = isFocused ? mergeClassNames(baseClassName, MenuItemFocused) : baseClassName;
|
|
4059
|
+
const keyDom = key ? getKeyDom(key) : [];
|
|
4060
|
+
return [{
|
|
4061
|
+
ariaChecked: true,
|
|
4062
|
+
childCount: key ? 3 : 2,
|
|
4063
|
+
className,
|
|
4064
|
+
role: MenuItemCheckBox,
|
|
4065
|
+
tabIndex: -1,
|
|
4066
|
+
type: Div
|
|
4067
|
+
}, checkMark, text(label), ...keyDom];
|
|
4068
|
+
};
|
|
4069
|
+
|
|
3988
4070
|
const classNameFocused = mergeClassNames(MenuItem, MenuItemFocused);
|
|
3989
4071
|
const getMenuItemClassName = isFocused => {
|
|
3990
4072
|
if (isFocused) {
|
|
@@ -4010,19 +4092,20 @@ const getMenuItemDefaultDom = menuItem => {
|
|
|
4010
4092
|
}, text(label), ...keyDom];
|
|
4011
4093
|
};
|
|
4012
4094
|
|
|
4013
|
-
const disabled = {
|
|
4014
|
-
childCount: 1,
|
|
4015
|
-
className: MenuItem,
|
|
4016
|
-
disabled: true,
|
|
4017
|
-
role: MenuItem$1,
|
|
4018
|
-
tabIndex: -1,
|
|
4019
|
-
type: Div
|
|
4020
|
-
};
|
|
4021
4095
|
const getMenuItemDisabledDom = menuItem => {
|
|
4022
4096
|
const {
|
|
4097
|
+
key,
|
|
4023
4098
|
label
|
|
4024
4099
|
} = menuItem;
|
|
4025
|
-
|
|
4100
|
+
const keyDom = key ? getKeyDom(key) : [];
|
|
4101
|
+
return [{
|
|
4102
|
+
childCount: key ? 2 : 1,
|
|
4103
|
+
className: MenuItem,
|
|
4104
|
+
disabled: true,
|
|
4105
|
+
role: MenuItem$1,
|
|
4106
|
+
tabIndex: -1,
|
|
4107
|
+
type: Div
|
|
4108
|
+
}, text(label), ...keyDom];
|
|
4026
4109
|
};
|
|
4027
4110
|
|
|
4028
4111
|
const getMenuItemsNoopDom = () => {
|
|
@@ -4073,17 +4156,19 @@ const getMenuItemSubMenuDom = menuItem => {
|
|
|
4073
4156
|
const getMenuItemUncheckedDom = menuItem => {
|
|
4074
4157
|
const {
|
|
4075
4158
|
isFocused,
|
|
4159
|
+
key,
|
|
4076
4160
|
label
|
|
4077
4161
|
} = menuItem;
|
|
4078
4162
|
const className = isFocused ? mergeClassNames(MenuItem, MenuItemFocused) : MenuItem;
|
|
4163
|
+
const keyDom = key ? getKeyDom(key) : [];
|
|
4079
4164
|
return [{
|
|
4080
4165
|
ariaChecked: false,
|
|
4081
|
-
childCount: 1,
|
|
4166
|
+
childCount: key ? 2 : 1,
|
|
4082
4167
|
className,
|
|
4083
4168
|
role: MenuItemCheckBox,
|
|
4084
4169
|
tabIndex: -1,
|
|
4085
4170
|
type: Div
|
|
4086
|
-
}, text(label)];
|
|
4171
|
+
}, text(label), ...keyDom];
|
|
4087
4172
|
};
|
|
4088
4173
|
|
|
4089
4174
|
const getMenuItemRenderer = flags => {
|
|
@@ -4190,7 +4275,7 @@ const getIcon = assetDir => {
|
|
|
4190
4275
|
const getIconVirtualDom = (icon, type = Div) => {
|
|
4191
4276
|
return {
|
|
4192
4277
|
childCount: 0,
|
|
4193
|
-
className:
|
|
4278
|
+
className: mergeClassNames(MaskIcon, `MaskIcon${icon}`),
|
|
4194
4279
|
role: None$1,
|
|
4195
4280
|
type
|
|
4196
4281
|
};
|
|
@@ -4206,7 +4291,7 @@ const createTitleBarButton = button => {
|
|
|
4206
4291
|
const dom = [{
|
|
4207
4292
|
ariaLabel: label,
|
|
4208
4293
|
childCount: 1,
|
|
4209
|
-
className:
|
|
4294
|
+
className: mergeClassNames(TitleBarButton, `TitleBarButton${id}`),
|
|
4210
4295
|
name: id,
|
|
4211
4296
|
onClick,
|
|
4212
4297
|
type: Button$1
|
|
@@ -4534,12 +4619,17 @@ const create = (id, uri, x, y, width, height) => {
|
|
|
4534
4619
|
|
|
4535
4620
|
const closeMenu = (state, keepFocus) => {
|
|
4536
4621
|
const {
|
|
4537
|
-
focusedIndex
|
|
4622
|
+
focusedIndex,
|
|
4623
|
+
isMenuOpen,
|
|
4624
|
+
menus
|
|
4538
4625
|
} = state;
|
|
4539
4626
|
// TODO send to renderer process
|
|
4540
4627
|
// 1. close menu
|
|
4541
4628
|
// 2. focus top level entry
|
|
4542
4629
|
const newFocusedIndex = keepFocus ? focusedIndex : -1;
|
|
4630
|
+
if (!isMenuOpen && menus.length === 0 && focusedIndex === newFocusedIndex) {
|
|
4631
|
+
return state;
|
|
4632
|
+
}
|
|
4543
4633
|
return {
|
|
4544
4634
|
...state,
|
|
4545
4635
|
focusedIndex: newFocusedIndex,
|
|
@@ -4778,7 +4868,8 @@ const handleKeyArrowRightMenuOpen = async state => {
|
|
|
4778
4868
|
}
|
|
4779
4869
|
const item = items[focusedIndex];
|
|
4780
4870
|
if (item.flags === SubMenu$1 && item.id !== undefined) {
|
|
4781
|
-
const
|
|
4871
|
+
const rawSubMenuEntries = await getMenuEntries(item.id);
|
|
4872
|
+
const subMenuEntries = await addMenuEntryKeyBindings(rawSubMenuEntries);
|
|
4782
4873
|
const subMenu = {
|
|
4783
4874
|
focusedIndex: 0,
|
|
4784
4875
|
items: subMenuEntries,
|
|
@@ -4943,7 +5034,8 @@ const selectIndexSubMenu = async (state, menu, index) => {
|
|
|
4943
5034
|
if (!item.id) {
|
|
4944
5035
|
return state;
|
|
4945
5036
|
}
|
|
4946
|
-
const
|
|
5037
|
+
const rawSubMenuEntries = await getMenuEntries(item.id);
|
|
5038
|
+
const subMenuEntries = await addMenuEntryKeyBindings(rawSubMenuEntries);
|
|
4947
5039
|
const subMenu = {
|
|
4948
5040
|
focusedIndex: -1,
|
|
4949
5041
|
items: subMenuEntries,
|
|
@@ -5030,7 +5122,8 @@ const getNewMenus = async (menus, level, index, flags) => {
|
|
|
5030
5122
|
if (!item.id) {
|
|
5031
5123
|
return menus;
|
|
5032
5124
|
}
|
|
5033
|
-
const
|
|
5125
|
+
const rawSubMenuEntries = await getMenuEntries(item.id);
|
|
5126
|
+
const subMenuEntries = await addMenuEntryKeyBindings(rawSubMenuEntries);
|
|
5034
5127
|
const subMenu = {
|
|
5035
5128
|
focusedIndex: -1,
|
|
5036
5129
|
items: subMenuEntries,
|