@lvce-editor/title-bar-worker 3.1.0 → 3.3.0
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 +149 -134
- package/package.json +1 -1
|
@@ -1401,6 +1401,27 @@ const Selection$1 = 'Selection';
|
|
|
1401
1401
|
const Terminal$1 = 'Terminal';
|
|
1402
1402
|
const ToggleDeveloperTools = 'Toggle Developer Tools';
|
|
1403
1403
|
const View$1 = 'View';
|
|
1404
|
+
const AddCursorAbove = 'Add Cursor Above';
|
|
1405
|
+
const AddCursorBelow = 'Add Cursor Below';
|
|
1406
|
+
const AddCursorsToLineEnds = 'Add Cursors to Line ends';
|
|
1407
|
+
const AddNextOccurrence = 'Add Next Occurrence';
|
|
1408
|
+
const AddPreviousOccurrence = 'Add Previous Occurrence';
|
|
1409
|
+
const Copy = 'Copy';
|
|
1410
|
+
const CopyLineDown = 'Copy Line Down';
|
|
1411
|
+
const CopyLineUp = 'Copy Line Up';
|
|
1412
|
+
const Cut = 'Cut';
|
|
1413
|
+
const DuplicateSelection = 'Duplicate Selection';
|
|
1414
|
+
const ExpandSelection = 'Expand Selection';
|
|
1415
|
+
const MoveLineDown = 'Move Line Down';
|
|
1416
|
+
const MoveLineUp = 'Move Line Up';
|
|
1417
|
+
const Paste = 'Paste';
|
|
1418
|
+
const Redo = 'Redo';
|
|
1419
|
+
const SelectAll = 'Select All';
|
|
1420
|
+
const SelectAllOccurrences = 'Select All Occurrences';
|
|
1421
|
+
const ShrinkSelection = 'Shrink Selection';
|
|
1422
|
+
const ToggleBlockComment = 'Toggle Block Comment';
|
|
1423
|
+
const ToggleLineComment = 'Toggle Line Comment';
|
|
1424
|
+
const Undo = 'Undo';
|
|
1404
1425
|
|
|
1405
1426
|
const file = () => {
|
|
1406
1427
|
return i18nString(File$2);
|
|
@@ -1679,90 +1700,68 @@ const getMenuIds = () => {
|
|
|
1679
1700
|
return [Edit$2, File$3, Go$2, Help$2, OpenRecent$1, Run$2, Selection$2, Terminal$2, TitleBar, View$2, MenuIdTitleBarContextMenu, TitleBarContextMenu];
|
|
1680
1701
|
};
|
|
1681
1702
|
|
|
1682
|
-
/**
|
|
1683
|
-
* @enum {string}
|
|
1684
|
-
*/
|
|
1685
|
-
const UiStrings$1 = {
|
|
1686
|
-
AddCursorAbove: 'Add Cursor Above',
|
|
1687
|
-
AddNextOccurrence: 'Add Next Occurrence',
|
|
1688
|
-
AddPreviousOccurrence: 'Add Previous Occurrence',
|
|
1689
|
-
Copy: 'Copy',
|
|
1690
|
-
CopyLineDown: 'Copy Line Down',
|
|
1691
|
-
CopyLineUp: 'Copy Line Up',
|
|
1692
|
-
Cut: 'Cut',
|
|
1693
|
-
MoveLineDown: 'Move Line Down',
|
|
1694
|
-
MoveLineUp: 'Move Line Up',
|
|
1695
|
-
Paste: 'Paste',
|
|
1696
|
-
Redo: 'Redo',
|
|
1697
|
-
SelectAll: 'Select All',
|
|
1698
|
-
SelectAllOccurrences: 'Select All Occurrences',
|
|
1699
|
-
ShrinkSelection: 'Shrink Selection',
|
|
1700
|
-
ToggleBlockComment: 'Toggle Block Comment',
|
|
1701
|
-
ToggleLineComment: 'Toggle Line Comment',
|
|
1702
|
-
Undo: 'Undo'
|
|
1703
|
-
};
|
|
1704
1703
|
const cut = () => {
|
|
1705
|
-
return i18nString(
|
|
1704
|
+
return i18nString(Cut);
|
|
1706
1705
|
};
|
|
1707
1706
|
const copy = () => {
|
|
1708
|
-
return i18nString(
|
|
1707
|
+
return i18nString(Copy);
|
|
1709
1708
|
};
|
|
1710
1709
|
const paste = () => {
|
|
1711
|
-
return i18nString(
|
|
1710
|
+
return i18nString(Paste);
|
|
1712
1711
|
};
|
|
1713
1712
|
const undo = () => {
|
|
1714
|
-
return i18nString(
|
|
1713
|
+
return i18nString(Undo);
|
|
1715
1714
|
};
|
|
1716
1715
|
const redo = () => {
|
|
1717
|
-
return i18nString(
|
|
1716
|
+
return i18nString(Redo);
|
|
1718
1717
|
};
|
|
1719
1718
|
const toggleLineComment = () => {
|
|
1720
|
-
return i18nString(
|
|
1719
|
+
return i18nString(ToggleLineComment);
|
|
1721
1720
|
};
|
|
1722
1721
|
const toggleBlockComment = () => {
|
|
1723
|
-
return i18nString(
|
|
1722
|
+
return i18nString(ToggleBlockComment);
|
|
1724
1723
|
};
|
|
1725
1724
|
const selectAll = () => {
|
|
1726
|
-
return i18nString(
|
|
1725
|
+
return i18nString(SelectAll);
|
|
1727
1726
|
};
|
|
1728
1727
|
const expandSelection = () => {
|
|
1729
|
-
return i18nString(
|
|
1728
|
+
return i18nString(ExpandSelection);
|
|
1730
1729
|
};
|
|
1731
1730
|
const shrinkSelection = () => {
|
|
1732
|
-
return i18nString(
|
|
1731
|
+
return i18nString(ShrinkSelection);
|
|
1733
1732
|
};
|
|
1734
1733
|
const copyLineUp = () => {
|
|
1735
|
-
return i18nString(
|
|
1734
|
+
return i18nString(CopyLineUp);
|
|
1736
1735
|
};
|
|
1737
1736
|
const copyLineDown = () => {
|
|
1738
|
-
return i18nString(
|
|
1737
|
+
return i18nString(CopyLineDown);
|
|
1739
1738
|
};
|
|
1740
1739
|
const moveLineUp = () => {
|
|
1741
|
-
return i18nString(
|
|
1740
|
+
return i18nString(MoveLineUp);
|
|
1742
1741
|
};
|
|
1743
1742
|
const moveLineDown = () => {
|
|
1744
|
-
return i18nString(
|
|
1743
|
+
return i18nString(MoveLineDown);
|
|
1745
1744
|
};
|
|
1746
1745
|
const duplicateSelection = () => {
|
|
1747
|
-
return i18nString(
|
|
1746
|
+
return i18nString(DuplicateSelection);
|
|
1748
1747
|
};
|
|
1749
1748
|
const addCursorAbove = () => {
|
|
1750
|
-
return i18nString(
|
|
1749
|
+
return i18nString(AddCursorAbove);
|
|
1751
1750
|
};
|
|
1752
1751
|
const addCursorBelow = () => {
|
|
1753
|
-
return i18nString(
|
|
1752
|
+
return i18nString(AddCursorBelow);
|
|
1754
1753
|
};
|
|
1755
1754
|
const addCursorsToLineEnds = () => {
|
|
1756
|
-
return i18nString(
|
|
1755
|
+
return i18nString(AddCursorsToLineEnds);
|
|
1757
1756
|
};
|
|
1758
1757
|
const addNextOccurrence = () => {
|
|
1759
|
-
return i18nString(
|
|
1758
|
+
return i18nString(AddNextOccurrence);
|
|
1760
1759
|
};
|
|
1761
1760
|
const addPreviousOccurrence = () => {
|
|
1762
|
-
return i18nString(
|
|
1761
|
+
return i18nString(AddPreviousOccurrence);
|
|
1763
1762
|
};
|
|
1764
1763
|
const selectAllOccurrences = () => {
|
|
1765
|
-
return i18nString(
|
|
1764
|
+
return i18nString(SelectAllOccurrences);
|
|
1766
1765
|
};
|
|
1767
1766
|
|
|
1768
1767
|
const menuEntrySeparator = {
|
|
@@ -1775,12 +1774,12 @@ const menuEntrySeparator = {
|
|
|
1775
1774
|
const getMenuEntries$c = () => {
|
|
1776
1775
|
return [{
|
|
1777
1776
|
command: /* TODO */'-1',
|
|
1778
|
-
flags:
|
|
1777
|
+
flags: None,
|
|
1779
1778
|
id: 'undo',
|
|
1780
1779
|
label: undo()
|
|
1781
1780
|
}, {
|
|
1782
1781
|
command: /* TODO */'-1',
|
|
1783
|
-
flags:
|
|
1782
|
+
flags: None,
|
|
1784
1783
|
id: 'redo',
|
|
1785
1784
|
label: redo()
|
|
1786
1785
|
}, menuEntrySeparator, {
|
|
@@ -2057,47 +2056,47 @@ const getMenuEntries$6 = () => {
|
|
|
2057
2056
|
label: copyLineDown()
|
|
2058
2057
|
}, {
|
|
2059
2058
|
command: 'Editor.moveLineUp',
|
|
2060
|
-
flags:
|
|
2059
|
+
flags: None,
|
|
2061
2060
|
id: 'moveLineUp',
|
|
2062
2061
|
label: moveLineUp()
|
|
2063
2062
|
}, {
|
|
2064
2063
|
command: 'Editor.moveLineDown',
|
|
2065
|
-
flags:
|
|
2064
|
+
flags: None,
|
|
2066
2065
|
id: 'moveLineDown',
|
|
2067
2066
|
label: moveLineDown()
|
|
2068
2067
|
}, {
|
|
2069
2068
|
command: 'Editor.duplicateSelection',
|
|
2070
|
-
flags:
|
|
2069
|
+
flags: None,
|
|
2071
2070
|
id: 'duplicateSelection',
|
|
2072
2071
|
label: duplicateSelection()
|
|
2073
2072
|
}, menuEntrySeparator, {
|
|
2074
2073
|
command: 'Editor.addCursorAbove',
|
|
2075
|
-
flags:
|
|
2074
|
+
flags: None,
|
|
2076
2075
|
id: 'addCursorAbove',
|
|
2077
2076
|
label: addCursorAbove()
|
|
2078
2077
|
}, {
|
|
2079
2078
|
command: 'Editor.addCursorBelow',
|
|
2080
|
-
flags:
|
|
2079
|
+
flags: None,
|
|
2081
2080
|
id: 'addCursorBelow',
|
|
2082
2081
|
label: addCursorBelow()
|
|
2083
2082
|
}, {
|
|
2084
2083
|
command: 'Editor.addCursorsToLineEnds',
|
|
2085
|
-
flags:
|
|
2084
|
+
flags: None,
|
|
2086
2085
|
id: 'addCursorsToLineEnds',
|
|
2087
2086
|
label: addCursorsToLineEnds()
|
|
2088
2087
|
}, {
|
|
2089
2088
|
command: 'Editor.addNextOccurrence',
|
|
2090
|
-
flags:
|
|
2089
|
+
flags: None,
|
|
2091
2090
|
id: 'addNextOccurrence',
|
|
2092
2091
|
label: addNextOccurrence()
|
|
2093
2092
|
}, {
|
|
2094
2093
|
command: 'Editor.addPreviousOccurrence',
|
|
2095
|
-
flags:
|
|
2094
|
+
flags: None,
|
|
2096
2095
|
id: 'addPreviousOccurrence',
|
|
2097
2096
|
label: addPreviousOccurrence()
|
|
2098
2097
|
}, {
|
|
2099
2098
|
command: 'Editor.selectAllOccurrences',
|
|
2100
|
-
flags:
|
|
2099
|
+
flags: None,
|
|
2101
2100
|
id: 'selectAllOccurrences',
|
|
2102
2101
|
label: selectAllOccurrences()
|
|
2103
2102
|
}];
|
|
@@ -2877,7 +2876,8 @@ const renderMenus = (oldState, newState) => {
|
|
|
2877
2876
|
const oldMenu = oldMenus[i];
|
|
2878
2877
|
const newMenu = newMenus[i];
|
|
2879
2878
|
if (oldMenu !== newMenu) {
|
|
2880
|
-
const
|
|
2879
|
+
const expanded = newMenu.expanded ?? false;
|
|
2880
|
+
const visible = getVisible(newMenu.items, newMenu.focusedIndex, expanded, newMenu.level);
|
|
2881
2881
|
const dom = getMenuVirtualDom(visible).slice(1);
|
|
2882
2882
|
changes.push([/* method */'updateMenu', newMenu, /* newLength */newLength, dom]);
|
|
2883
2883
|
}
|
|
@@ -2885,9 +2885,12 @@ const renderMenus = (oldState, newState) => {
|
|
|
2885
2885
|
const difference = newLength - oldLength;
|
|
2886
2886
|
if (difference > 0) {
|
|
2887
2887
|
const newMenu = newMenus.at(-1);
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2888
|
+
if (newMenu) {
|
|
2889
|
+
const expanded = newMenu.expanded ?? false;
|
|
2890
|
+
const visible = getVisible(newMenu.items, newMenu.focusedIndex, expanded, newMenu.level);
|
|
2891
|
+
const dom = getMenuVirtualDom(visible).slice(1);
|
|
2892
|
+
changes.push(['addMenu', newMenu, dom]);
|
|
2893
|
+
}
|
|
2891
2894
|
} else if (difference < 0) {
|
|
2892
2895
|
changes.push(['closeMenus', newLength]);
|
|
2893
2896
|
}
|
|
@@ -2927,7 +2930,10 @@ const createTitleBarButton = button => {
|
|
|
2927
2930
|
return dom;
|
|
2928
2931
|
};
|
|
2929
2932
|
|
|
2930
|
-
const getTitleBarButtonsVirtualDom = buttons => {
|
|
2933
|
+
const getTitleBarButtonsVirtualDom = (buttonsEnabled, buttons) => {
|
|
2934
|
+
if (!buttonsEnabled) {
|
|
2935
|
+
return [];
|
|
2936
|
+
}
|
|
2931
2937
|
return [{
|
|
2932
2938
|
childCount: buttons.length,
|
|
2933
2939
|
className: mergeClassNames(Viewlet, TitleBarButtons),
|
|
@@ -2940,7 +2946,10 @@ const parentNode$1 = {
|
|
|
2940
2946
|
className: mergeClassNames(Viewlet, TitleBarIcon),
|
|
2941
2947
|
type: Div
|
|
2942
2948
|
};
|
|
2943
|
-
const getTitleBarIconVirtualDom = iconSrc => {
|
|
2949
|
+
const getTitleBarIconVirtualDom = (titleBarIconEnabled, iconSrc) => {
|
|
2950
|
+
if (!titleBarIconEnabled) {
|
|
2951
|
+
return [];
|
|
2952
|
+
}
|
|
2944
2953
|
return [parentNode$1, {
|
|
2945
2954
|
alt: '',
|
|
2946
2955
|
childCount: 0,
|
|
@@ -2970,34 +2979,27 @@ const getItemVirtualDom = item => {
|
|
|
2970
2979
|
keyboardShortCut,
|
|
2971
2980
|
label
|
|
2972
2981
|
} = item;
|
|
2973
|
-
|
|
2974
|
-
|
|
2982
|
+
let className = TitleBarTopLevelEntry;
|
|
2983
|
+
if (isFocused) {
|
|
2984
|
+
className += ' ' + TitleBarEntryActive;
|
|
2985
|
+
}
|
|
2986
|
+
return [{
|
|
2975
2987
|
ariaExpanded: isOpen,
|
|
2976
2988
|
ariaHasPopup: true,
|
|
2977
2989
|
ariaKeyShortcuts: keyboardShortCut,
|
|
2990
|
+
ariaOwns: isOpen ? 'Menu-0' : undefined,
|
|
2978
2991
|
childCount: 1,
|
|
2979
|
-
className
|
|
2992
|
+
className,
|
|
2993
|
+
id: isFocused ? 'TitleBarEntryActive' : undefined,
|
|
2980
2994
|
name: label,
|
|
2981
2995
|
// TODO have separate name attribute
|
|
2982
2996
|
role: MenuItem$1,
|
|
2983
2997
|
type: Button$1
|
|
2984
|
-
}
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
}
|
|
2989
|
-
if (isFocused) {
|
|
2990
|
-
dom[0].className += ' ' + TitleBarEntryActive;
|
|
2991
|
-
// @ts-ignore
|
|
2992
|
-
dom[0].id = 'TitleBarEntryActive';
|
|
2993
|
-
dom.push({
|
|
2994
|
-
childCount: 1,
|
|
2995
|
-
className: TitleBarTopLevelEntryLabel,
|
|
2996
|
-
type: Div
|
|
2997
|
-
});
|
|
2998
|
-
}
|
|
2999
|
-
dom.push(text(label));
|
|
3000
|
-
return dom;
|
|
2998
|
+
}, ...(isFocused ? [{
|
|
2999
|
+
childCount: 1,
|
|
3000
|
+
className: TitleBarTopLevelEntryLabel,
|
|
3001
|
+
type: Div
|
|
3002
|
+
}] : []), text(label)];
|
|
3001
3003
|
};
|
|
3002
3004
|
const getTitleBarMenuBarItemsVirtualDom = visibleItems => {
|
|
3003
3005
|
const dom = visibleItems.flatMap(getItemVirtualDom);
|
|
@@ -3005,7 +3007,10 @@ const getTitleBarMenuBarItemsVirtualDom = visibleItems => {
|
|
|
3005
3007
|
};
|
|
3006
3008
|
|
|
3007
3009
|
const activeId = 'TitleBarEntryActive';
|
|
3008
|
-
const getTitleBarMenuBarVirtualDom = (visibleItems, focusedIndex) => {
|
|
3010
|
+
const getTitleBarMenuBarVirtualDom = (menuBarEnabled, visibleItems, focusedIndex) => {
|
|
3011
|
+
if (!menuBarEnabled) {
|
|
3012
|
+
return [];
|
|
3013
|
+
}
|
|
3009
3014
|
return [{
|
|
3010
3015
|
ariaActivedescendant: focusedIndex === -1 ? '' : activeId,
|
|
3011
3016
|
childCount: visibleItems.length,
|
|
@@ -3026,7 +3031,10 @@ const parentNode = {
|
|
|
3026
3031
|
className: 'TitleBarTitle',
|
|
3027
3032
|
type: Div
|
|
3028
3033
|
};
|
|
3029
|
-
const getTitleVirtualDom = title => {
|
|
3034
|
+
const getTitleVirtualDom = (titleBarTitleEnabled, title) => {
|
|
3035
|
+
if (!titleBarTitleEnabled) {
|
|
3036
|
+
return [];
|
|
3037
|
+
}
|
|
3030
3038
|
return [parentNode, text(title)];
|
|
3031
3039
|
};
|
|
3032
3040
|
|
|
@@ -3077,44 +3085,24 @@ const getTitleBarVirtualDom = state => {
|
|
|
3077
3085
|
isMenuOpen,
|
|
3078
3086
|
title,
|
|
3079
3087
|
titleBarButtons,
|
|
3088
|
+
titleBarButtonsEnabled,
|
|
3080
3089
|
titleBarEntries,
|
|
3090
|
+
titleBarIconEnabled,
|
|
3091
|
+
titleBarMenuBarEnabled,
|
|
3092
|
+
titleBarTitleEnabled,
|
|
3081
3093
|
width
|
|
3082
3094
|
} = state;
|
|
3083
|
-
const
|
|
3095
|
+
const iconSrc = getIcon(assetDir);
|
|
3096
|
+
const visibleEntries = getVisibleTitleBarEntries(titleBarEntries, width, focusedIndex, isMenuOpen);
|
|
3097
|
+
return [{
|
|
3084
3098
|
ariaLabel: 'Title Bar',
|
|
3099
|
+
// TODO i18n string
|
|
3085
3100
|
childCount: 4,
|
|
3086
3101
|
className: 'Viewlet TitleBar',
|
|
3087
3102
|
id: 'TitleBar',
|
|
3088
3103
|
role: ContentInfo,
|
|
3089
3104
|
type: Div
|
|
3090
|
-
}];
|
|
3091
|
-
|
|
3092
|
-
// Add icon if enabled
|
|
3093
|
-
if (state.titleBarIconEnabled) {
|
|
3094
|
-
const iconSrc = getIcon(assetDir);
|
|
3095
|
-
const iconDom = getTitleBarIconVirtualDom(iconSrc);
|
|
3096
|
-
dom.push(...iconDom);
|
|
3097
|
-
}
|
|
3098
|
-
|
|
3099
|
-
// Add menu bar if enabled
|
|
3100
|
-
if (state.titleBarMenuBarEnabled) {
|
|
3101
|
-
const visibleEntries = getVisibleTitleBarEntries(titleBarEntries, width, focusedIndex, isMenuOpen);
|
|
3102
|
-
const menuBarDom = getTitleBarMenuBarVirtualDom(visibleEntries, focusedIndex);
|
|
3103
|
-
dom.push(...menuBarDom);
|
|
3104
|
-
}
|
|
3105
|
-
|
|
3106
|
-
// Add title if enabled
|
|
3107
|
-
if (state.titleBarTitleEnabled) {
|
|
3108
|
-
const titleDom = getTitleVirtualDom(title);
|
|
3109
|
-
dom.push(...titleDom);
|
|
3110
|
-
}
|
|
3111
|
-
|
|
3112
|
-
// Add buttons if enabled
|
|
3113
|
-
if (state.titleBarButtonsEnabled) {
|
|
3114
|
-
const buttonsDom = getTitleBarButtonsVirtualDom(titleBarButtons);
|
|
3115
|
-
dom.push(...buttonsDom);
|
|
3116
|
-
}
|
|
3117
|
-
return dom;
|
|
3105
|
+
}, ...getTitleBarIconVirtualDom(titleBarIconEnabled, iconSrc), ...getTitleBarMenuBarVirtualDom(titleBarMenuBarEnabled, visibleEntries, focusedIndex), ...getTitleVirtualDom(titleBarTitleEnabled, title), ...getTitleBarButtonsVirtualDom(titleBarButtonsEnabled, titleBarButtons)];
|
|
3118
3106
|
};
|
|
3119
3107
|
|
|
3120
3108
|
const renderTitleBar = (oldState, newState) => {
|
|
@@ -3398,6 +3386,9 @@ const handleKeyArrowDownMenuOpen = state => {
|
|
|
3398
3386
|
menus
|
|
3399
3387
|
} = state;
|
|
3400
3388
|
const menu = menus.at(-1);
|
|
3389
|
+
if (!menu) {
|
|
3390
|
+
return state;
|
|
3391
|
+
}
|
|
3401
3392
|
const newFocusedIndex = getIndexToFocusNext(menu);
|
|
3402
3393
|
const newMenus = [...menus.slice(0, -1), {
|
|
3403
3394
|
...menu,
|
|
@@ -3421,6 +3412,9 @@ const closeOneMenu = state => {
|
|
|
3421
3412
|
menus
|
|
3422
3413
|
} = state;
|
|
3423
3414
|
const parentMenu = menus.at(-2);
|
|
3415
|
+
if (!parentMenu) {
|
|
3416
|
+
return state;
|
|
3417
|
+
}
|
|
3424
3418
|
const newParentMenu = {
|
|
3425
3419
|
...parentMenu,
|
|
3426
3420
|
expanded: false
|
|
@@ -3487,6 +3481,9 @@ const handleKeyArrowRightMenuOpen = async state => {
|
|
|
3487
3481
|
} = state;
|
|
3488
3482
|
// if menu can open sub menu to the right -> do that
|
|
3489
3483
|
const menu = menus.at(-1);
|
|
3484
|
+
if (!menu) {
|
|
3485
|
+
return state;
|
|
3486
|
+
}
|
|
3490
3487
|
const {
|
|
3491
3488
|
focusedIndex,
|
|
3492
3489
|
items,
|
|
@@ -3497,7 +3494,7 @@ const handleKeyArrowRightMenuOpen = async state => {
|
|
|
3497
3494
|
return focusNext(state);
|
|
3498
3495
|
}
|
|
3499
3496
|
const item = items[focusedIndex];
|
|
3500
|
-
if (item.flags === SubMenu) {
|
|
3497
|
+
if (item.flags === SubMenu && item.id !== undefined) {
|
|
3501
3498
|
const subMenuEntries = await getMenuEntries(item.id);
|
|
3502
3499
|
const subMenu = {
|
|
3503
3500
|
focusedIndex: 0,
|
|
@@ -3530,6 +3527,9 @@ const handleKeyArrowUpMenuOpen = state => {
|
|
|
3530
3527
|
menus
|
|
3531
3528
|
} = state;
|
|
3532
3529
|
const menu = menus.at(-1);
|
|
3530
|
+
if (!menu) {
|
|
3531
|
+
return state;
|
|
3532
|
+
}
|
|
3533
3533
|
const previousIndex = getIndexToFocusPrevious(menu);
|
|
3534
3534
|
const newMenus = [...menus.slice(0, -1), {
|
|
3535
3535
|
...menu,
|
|
@@ -3656,6 +3656,9 @@ const selectIndexSubMenu = async (state, menu, index) => {
|
|
|
3656
3656
|
y
|
|
3657
3657
|
} = menu;
|
|
3658
3658
|
const item = items[index];
|
|
3659
|
+
if (!item.id) {
|
|
3660
|
+
return state;
|
|
3661
|
+
}
|
|
3659
3662
|
const subMenuEntries = await getMenuEntries(item.id);
|
|
3660
3663
|
const subMenu = {
|
|
3661
3664
|
focusedIndex: -1,
|
|
@@ -3698,16 +3701,10 @@ const handleMenuClick = async (state, level, index) => {
|
|
|
3698
3701
|
}
|
|
3699
3702
|
};
|
|
3700
3703
|
|
|
3701
|
-
const
|
|
3702
|
-
object(state);
|
|
3703
|
-
number(level);
|
|
3704
|
-
number(index);
|
|
3705
|
-
const {
|
|
3706
|
-
menus
|
|
3707
|
-
} = state;
|
|
3704
|
+
const getNewMenus = async (menus, level, index, flags) => {
|
|
3708
3705
|
const menu = menus[level];
|
|
3709
3706
|
if (!menu) {
|
|
3710
|
-
return
|
|
3707
|
+
return menus;
|
|
3711
3708
|
}
|
|
3712
3709
|
const {
|
|
3713
3710
|
focusedIndex,
|
|
@@ -3718,7 +3715,7 @@ const handleMenuMouseOver = async (state, level, index) => {
|
|
|
3718
3715
|
const item = items[index];
|
|
3719
3716
|
if (focusedIndex === index) {
|
|
3720
3717
|
if (index === -1) {
|
|
3721
|
-
return
|
|
3718
|
+
return menus;
|
|
3722
3719
|
}
|
|
3723
3720
|
if (item.flags === SubMenu && level === menus.length - 2) {
|
|
3724
3721
|
const subMenu = menus[level + 1];
|
|
@@ -3728,26 +3725,23 @@ const handleMenuMouseOver = async (state, level, index) => {
|
|
|
3728
3725
|
focusedIndex: -1
|
|
3729
3726
|
};
|
|
3730
3727
|
const newMenus = [...menus.slice(0, -1), newSubMenu];
|
|
3731
|
-
return
|
|
3732
|
-
...state,
|
|
3733
|
-
menus: newMenus
|
|
3734
|
-
};
|
|
3728
|
+
return newMenus;
|
|
3735
3729
|
}
|
|
3736
3730
|
}
|
|
3737
|
-
return
|
|
3731
|
+
return menus;
|
|
3738
3732
|
}
|
|
3739
3733
|
if (index === -1) {
|
|
3740
3734
|
const newMenus = [...menus.slice(0, level), {
|
|
3741
3735
|
...menu,
|
|
3742
3736
|
focusedIndex: -1
|
|
3743
3737
|
}];
|
|
3744
|
-
return
|
|
3745
|
-
...state,
|
|
3746
|
-
menus: newMenus
|
|
3747
|
-
};
|
|
3738
|
+
return newMenus;
|
|
3748
3739
|
}
|
|
3749
3740
|
if (item.flags === SubMenu) {
|
|
3750
3741
|
const item = items[index];
|
|
3742
|
+
if (!item.id) {
|
|
3743
|
+
return menus;
|
|
3744
|
+
}
|
|
3751
3745
|
const subMenuEntries = await getMenuEntries(item.id);
|
|
3752
3746
|
const subMenu = {
|
|
3753
3747
|
focusedIndex: -1,
|
|
@@ -3761,15 +3755,36 @@ const handleMenuMouseOver = async (state, level, index) => {
|
|
|
3761
3755
|
focusedIndex: index
|
|
3762
3756
|
};
|
|
3763
3757
|
const newMenus = [...menus.slice(0, level - 1), newParentMenu, subMenu];
|
|
3764
|
-
return
|
|
3765
|
-
...state,
|
|
3766
|
-
menus: newMenus
|
|
3767
|
-
};
|
|
3758
|
+
return newMenus;
|
|
3768
3759
|
}
|
|
3769
3760
|
const newMenus = [...menus.slice(0, level), {
|
|
3770
3761
|
...menu,
|
|
3771
3762
|
focusedIndex: index
|
|
3772
3763
|
}];
|
|
3764
|
+
return newMenus;
|
|
3765
|
+
};
|
|
3766
|
+
const handleMenuMouseOver = async (state, level, index) => {
|
|
3767
|
+
object(state);
|
|
3768
|
+
number(level);
|
|
3769
|
+
number(index);
|
|
3770
|
+
const {
|
|
3771
|
+
menus
|
|
3772
|
+
} = state;
|
|
3773
|
+
const menu = menus[level];
|
|
3774
|
+
if (!menu) {
|
|
3775
|
+
return state;
|
|
3776
|
+
}
|
|
3777
|
+
const {
|
|
3778
|
+
items
|
|
3779
|
+
} = menu;
|
|
3780
|
+
const item = items[index];
|
|
3781
|
+
if (!item) {
|
|
3782
|
+
return state;
|
|
3783
|
+
}
|
|
3784
|
+
const newMenus = await getNewMenus(menus, level, index);
|
|
3785
|
+
if (menus === newMenus) {
|
|
3786
|
+
return state;
|
|
3787
|
+
}
|
|
3773
3788
|
return {
|
|
3774
3789
|
...state,
|
|
3775
3790
|
menus: newMenus
|