@lvce-editor/main-area-worker 9.37.0 → 9.37.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.
@@ -2887,6 +2887,37 @@ const diff2 = uid => {
2887
2887
  return result;
2888
2888
  };
2889
2889
 
2890
+ const getActiveTab = state => {
2891
+ const {
2892
+ layout
2893
+ } = state;
2894
+ const {
2895
+ groups
2896
+ } = layout;
2897
+ const activeGroup = groups.find(group => group.focused);
2898
+ if (!activeGroup || !activeGroup.activeTabId) {
2899
+ return undefined;
2900
+ }
2901
+ const activeTab = activeGroup.tabs.find(tab => tab.id === activeGroup.activeTabId);
2902
+ if (!activeTab) {
2903
+ return undefined;
2904
+ }
2905
+ return {
2906
+ groupId: activeGroup.id,
2907
+ tab: activeTab
2908
+ };
2909
+ };
2910
+
2911
+ const focus = async state => {
2912
+ const activeTab = getActiveTab(state);
2913
+ const editorUid = activeTab?.tab.editorUid;
2914
+ if (typeof editorUid !== 'number' || editorUid < 0) {
2915
+ return state;
2916
+ }
2917
+ await invoke('Viewlet.focusSelector', editorUid, '[name="editor"]');
2918
+ return state;
2919
+ };
2920
+
2890
2921
  const requestIdState = {
2891
2922
  counter: 0
2892
2923
  };
@@ -3402,27 +3433,6 @@ const getActiveGroup = (groups, activeGroupId) => {
3402
3433
  const Left$1 = 'left';
3403
3434
  const Right$1 = 'right';
3404
3435
 
3405
- const getActiveTab = state => {
3406
- const {
3407
- layout
3408
- } = state;
3409
- const {
3410
- groups
3411
- } = layout;
3412
- const activeGroup = groups.find(group => group.focused);
3413
- if (!activeGroup || !activeGroup.activeTabId) {
3414
- return undefined;
3415
- }
3416
- const activeTab = activeGroup.tabs.find(tab => tab.id === activeGroup.activeTabId);
3417
- if (!activeTab) {
3418
- return undefined;
3419
- }
3420
- return {
3421
- groupId: activeGroup.id,
3422
- tab: activeTab
3423
- };
3424
- };
3425
-
3426
3436
  const handleClickTogglePreview = async state => {
3427
3437
  const activeTabInfo = getActiveTab(state);
3428
3438
  if (!activeTabInfo || !activeTabInfo.tab.uri) {
@@ -8004,6 +8014,7 @@ const commandMap = {
8004
8014
  'Main.closeTabsRight': wrapSerialCommand(closeTabsRight),
8005
8015
  'Main.copyPath': wrapSerialCommand(copyPath$1),
8006
8016
  'Main.copyRelativePath': wrapSerialCommand(copyRelativePath$1),
8017
+ 'Main.focus': wrapSerialCommand(focus),
8007
8018
  'Main.focusNext': wrapSerialCommand(focusNextTab),
8008
8019
  'Main.focusNextTab': wrapSerialCommand(focusNextTab),
8009
8020
  'Main.focusPrevious': wrapSerialCommand(focusPreviousTab),
@@ -8033,6 +8044,7 @@ const commandMap = {
8033
8044
  'MainArea.create': create$1,
8034
8045
  'MainArea.diff2': diff2,
8035
8046
  'MainArea.flipEditorLayout': wrapSerialCommand(flipLayout),
8047
+ 'MainArea.focus': wrapSerialCommand(focus),
8036
8048
  'MainArea.focusNext': wrapSerialCommand(focusNextTab),
8037
8049
  'MainArea.focusNextTab': wrapSerialCommand(focusNextTab),
8038
8050
  'MainArea.focusPrevious': wrapSerialCommand(focusPreviousTab),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-area-worker",
3
- "version": "9.37.0",
3
+ "version": "9.37.2",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",