@lvce-editor/title-bar-worker 4.15.3 → 4.15.5

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.
@@ -2195,6 +2195,7 @@ const Unchecked = 3;
2195
2195
  const Disabled = 5;
2196
2196
  const RestoreFocus = 6;
2197
2197
  const Ignore = 7;
2198
+ const RestoreEditorFocus = 8;
2198
2199
 
2199
2200
  const getMenuEntriesTitleBarContextMenu = async state => {
2200
2201
  const {
@@ -2367,37 +2368,37 @@ const selectAllOccurrences = () => {
2367
2368
  const getMenuEntries$d = () => {
2368
2369
  return [{
2369
2370
  command: 'Editor.undo',
2370
- flags: None,
2371
+ flags: RestoreEditorFocus,
2371
2372
  id: 'undo',
2372
2373
  label: undo()
2373
2374
  }, {
2374
2375
  command: 'Editor.redo',
2375
- flags: None,
2376
+ flags: RestoreEditorFocus,
2376
2377
  id: 'redo',
2377
2378
  label: redo()
2378
2379
  }, menuEntrySeparator, {
2379
2380
  command: /* Editor.cut */'Editor.cut',
2380
- flags: None,
2381
+ flags: RestoreEditorFocus,
2381
2382
  id: 'cut',
2382
2383
  label: cut()
2383
2384
  }, {
2384
2385
  command: /* Editor.copy */'Editor.copy',
2385
- flags: None,
2386
+ flags: RestoreEditorFocus,
2386
2387
  id: 'copy',
2387
2388
  label: copy()
2388
2389
  }, {
2389
2390
  command: /* Editor.paste */'Editor.paste',
2390
- flags: None,
2391
+ flags: RestoreEditorFocus,
2391
2392
  id: 'paste',
2392
2393
  label: paste()
2393
2394
  }, menuEntrySeparator, {
2394
2395
  command: /* Editor.toggleLineComment */'Editor.toggleLineComment',
2395
- flags: None,
2396
+ flags: RestoreEditorFocus,
2396
2397
  id: 'toggle-line-comment',
2397
2398
  label: toggleLineComment()
2398
2399
  }, {
2399
2400
  command: /* Editor.toggleBlockComment */'Editor.toggleBlockComment',
2400
- flags: None,
2401
+ flags: RestoreEditorFocus,
2401
2402
  id: 'toggle-block-comment',
2402
2403
  label: toggleBlockComment()
2403
2404
  }];
@@ -2706,7 +2707,7 @@ const getMenuEntries$9 = async platform => {
2706
2707
  }
2707
2708
  entries.push({
2708
2709
  command: 'License.openLicense',
2709
- flags: None,
2710
+ flags: RestoreEditorFocus,
2710
2711
  id: 'viewLicense',
2711
2712
  label: viewLicense()
2712
2713
  });
@@ -2834,72 +2835,72 @@ const getMenuEntries$7 = () => {
2834
2835
  const getMenuEntries$6 = () => {
2835
2836
  return [{
2836
2837
  command: 'Editor.selectAll',
2837
- flags: None,
2838
+ flags: RestoreEditorFocus,
2838
2839
  id: 'selectAll',
2839
2840
  label: selectAll()
2840
2841
  }, {
2841
2842
  command: 'Editor.expandSelection',
2842
- flags: None,
2843
+ flags: RestoreEditorFocus,
2843
2844
  id: 'expandSelection',
2844
2845
  label: expandSelection()
2845
2846
  }, {
2846
2847
  command: 'Editor.shrinkSelection',
2847
- flags: None,
2848
+ flags: RestoreEditorFocus,
2848
2849
  id: 'shrinkSelection',
2849
2850
  label: shrinkSelection()
2850
2851
  }, menuEntrySeparator, {
2851
2852
  command: 'Editor.copyLineUp',
2852
- flags: None,
2853
+ flags: RestoreEditorFocus,
2853
2854
  id: 'copyLineUp',
2854
2855
  label: copyLineUp()
2855
2856
  }, {
2856
2857
  command: 'Editor.copyLineDown',
2857
- flags: None,
2858
+ flags: RestoreEditorFocus,
2858
2859
  id: 'copyLineDown',
2859
2860
  label: copyLineDown()
2860
2861
  }, {
2861
2862
  command: 'Editor.moveLineUp',
2862
- flags: None,
2863
+ flags: RestoreEditorFocus,
2863
2864
  id: 'moveLineUp',
2864
2865
  label: moveLineUp()
2865
2866
  }, {
2866
2867
  command: 'Editor.moveLineDown',
2867
- flags: None,
2868
+ flags: RestoreEditorFocus,
2868
2869
  id: 'moveLineDown',
2869
2870
  label: moveLineDown()
2870
2871
  }, {
2871
2872
  command: 'Editor.duplicateSelection',
2872
- flags: None,
2873
+ flags: RestoreEditorFocus,
2873
2874
  id: 'duplicateSelection',
2874
2875
  label: duplicateSelection()
2875
2876
  }, menuEntrySeparator, {
2876
2877
  command: 'Editor.addCursorAbove',
2877
- flags: None,
2878
+ flags: RestoreEditorFocus,
2878
2879
  id: 'addCursorAbove',
2879
2880
  label: addCursorAbove()
2880
2881
  }, {
2881
2882
  command: 'Editor.addCursorBelow',
2882
- flags: None,
2883
+ flags: RestoreEditorFocus,
2883
2884
  id: 'addCursorBelow',
2884
2885
  label: addCursorBelow()
2885
2886
  }, {
2886
2887
  command: 'Editor.addCursorsToLineEnds',
2887
- flags: None,
2888
+ flags: RestoreEditorFocus,
2888
2889
  id: 'addCursorsToLineEnds',
2889
2890
  label: addCursorsToLineEnds()
2890
2891
  }, {
2891
2892
  command: 'Editor.addNextOccurrence',
2892
- flags: None,
2893
+ flags: RestoreEditorFocus,
2893
2894
  id: 'addNextOccurrence',
2894
2895
  label: addNextOccurrence()
2895
2896
  }, {
2896
2897
  command: 'Editor.addPreviousOccurrence',
2897
- flags: None,
2898
+ flags: RestoreEditorFocus,
2898
2899
  id: 'addPreviousOccurrence',
2899
2900
  label: addPreviousOccurrence()
2900
2901
  }, {
2901
2902
  command: 'Editor.selectAllOccurrences',
2902
- flags: None,
2903
+ flags: RestoreEditorFocus,
2903
2904
  id: 'selectAllOccurrences',
2904
2905
  label: selectAllOccurrences()
2905
2906
  }];
@@ -3347,6 +3348,10 @@ const getKeyBindings = () => {
3347
3348
  command: 'TitleBar.handleKeyArrowLeft',
3348
3349
  key: LeftArrow$1,
3349
3350
  when: FocusTitleBarMenuBar
3351
+ }, {
3352
+ command: 'TitleBar.handleKeyEnter',
3353
+ key: Enter$1,
3354
+ when: FocusTitleBarMenuBar
3350
3355
  }, {
3351
3356
  command: 'TitleBar.handleKeySpace',
3352
3357
  key: Space$1,
@@ -4259,6 +4264,7 @@ const getMenuItemRenderer = flags => {
4259
4264
  return getMenuItemDisabledDom;
4260
4265
  case Ignore:
4261
4266
  case None:
4267
+ case RestoreEditorFocus:
4262
4268
  case RestoreFocus:
4263
4269
  return getMenuItemDefaultDom;
4264
4270
  case Separator$1:
@@ -5076,6 +5082,21 @@ const selectIndexNone = async (state, item) => {
5076
5082
  };
5077
5083
  };
5078
5084
 
5085
+ const selectIndexRestoreEditorFocus = async (state, item) => {
5086
+ await executeMenuItemCommand(item);
5087
+ try {
5088
+ await invoke('Main.focus');
5089
+ } catch {
5090
+ // Focus restoration is best effort and must not turn a successful command into a failure.
5091
+ }
5092
+ return {
5093
+ ...state,
5094
+ focusedIndex: -1,
5095
+ isMenuOpen: false,
5096
+ menus: []
5097
+ };
5098
+ };
5099
+
5079
5100
  const selectIndexRestoreFocus = async (state, item) => {
5080
5101
  await executeMenuItemCommand(item);
5081
5102
  const latestState = get(state.uid)?.newState ?? state;
@@ -5137,6 +5158,8 @@ const handleMenuClick = async (state, level, index) => {
5137
5158
  return selectIndexIgnore(state, item);
5138
5159
  case None:
5139
5160
  return selectIndexNone(state, item);
5161
+ case RestoreEditorFocus:
5162
+ return selectIndexRestoreEditorFocus(state, item);
5140
5163
  case RestoreFocus:
5141
5164
  return selectIndexRestoreFocus(state, item);
5142
5165
  case SubMenu$1:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/title-bar-worker",
3
- "version": "4.15.3",
3
+ "version": "4.15.5",
4
4
  "description": "Title Bar Worker",
5
5
  "repository": {
6
6
  "type": "git",