@lvce-editor/main-area-worker 9.64.0 → 9.64.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.
@@ -1798,14 +1798,42 @@ const getActiveFileUri = state => {
1798
1798
  return editorInput && 'uri' in editorInput ? editorInput.uri : '';
1799
1799
  };
1800
1800
 
1801
+ const getActiveTab = state => {
1802
+ const {
1803
+ layout
1804
+ } = state;
1805
+ const {
1806
+ groups
1807
+ } = layout;
1808
+ const activeGroup = groups.find(group => group.focused);
1809
+ if (!activeGroup || !activeGroup.activeTabId) {
1810
+ return undefined;
1811
+ }
1812
+ const activeTab = activeGroup.tabs.find(tab => tab.id === activeGroup.activeTabId);
1813
+ if (!activeTab) {
1814
+ return undefined;
1815
+ }
1816
+ return {
1817
+ groupId: activeGroup.id,
1818
+ tab: activeTab
1819
+ };
1820
+ };
1821
+
1822
+ const hasActiveTextEditor = state => {
1823
+ const activeTab = getActiveTab(state);
1824
+ return activeTab?.tab.editorInput?.type === 'editor';
1825
+ };
1826
+
1801
1827
  const notifyActiveEditorChange = async (oldState, newState) => {
1802
1828
  const oldUri = getActiveFileUri(oldState);
1803
1829
  const newUri = getActiveFileUri(newState);
1804
- if (oldUri === newUri) {
1830
+ const oldIsTextEditor = hasActiveTextEditor(oldState);
1831
+ const newIsTextEditor = hasActiveTextEditor(newState);
1832
+ if (oldUri === newUri && oldIsTextEditor === newIsTextEditor) {
1805
1833
  return;
1806
1834
  }
1807
1835
  try {
1808
- await invoke$1(newState.applicationId, 'Layout.handleActiveEditorChange', newUri);
1836
+ await invoke$1(newState.applicationId, 'Layout.handleActiveEditorChange', newUri, newIsTextEditor);
1809
1837
  } catch (error) {
1810
1838
  console.warn('Failed to notify viewlets about active editor change', error);
1811
1839
  }
@@ -2764,27 +2792,6 @@ const diff2 = uid => {
2764
2792
  return result;
2765
2793
  };
2766
2794
 
2767
- const getActiveTab = state => {
2768
- const {
2769
- layout
2770
- } = state;
2771
- const {
2772
- groups
2773
- } = layout;
2774
- const activeGroup = groups.find(group => group.focused);
2775
- if (!activeGroup || !activeGroup.activeTabId) {
2776
- return undefined;
2777
- }
2778
- const activeTab = activeGroup.tabs.find(tab => tab.id === activeGroup.activeTabId);
2779
- if (!activeTab) {
2780
- return undefined;
2781
- }
2782
- return {
2783
- groupId: activeGroup.id,
2784
- tab: activeTab
2785
- };
2786
- };
2787
-
2788
2795
  const state = {
2789
2796
  connected: false
2790
2797
  };
@@ -3865,6 +3872,7 @@ const HandleTabKeyDown = 29;
3865
3872
  const HandleTabsWheel = 30;
3866
3873
  const HandleTabDragOver = 31;
3867
3874
  const HandleTabsDragOver = 32;
3875
+ const HandleFocus = 33;
3868
3876
 
3869
3877
  const dragOverlayVirtualDom = {
3870
3878
  childCount: 0,
@@ -4515,6 +4523,7 @@ const renderEmptyEditorGroup = (group, groupIndex, closeButtonEnabled = true) =>
4515
4523
  className: mergeClassNames(EditorGroupEmpty, getEditorGroupClassName(group.id)),
4516
4524
  'data-groupId': String(group.id),
4517
4525
  onContextMenu: HandleContextMenu,
4526
+ onFocus: HandleFocus,
4518
4527
  tabIndex: Focusable,
4519
4528
  type: Div
4520
4529
  }, ...closeButtonDom, ...renderWaterMark(group.id)];
@@ -4560,6 +4569,7 @@ const renderSash = (direction, sashId) => {
4560
4569
  }, {
4561
4570
  childCount: 0,
4562
4571
  className: getSashBorderClassName(direction),
4572
+ 'data-sashId': sashId,
4563
4573
  type: Div
4564
4574
  }];
4565
4575
  };
@@ -4747,11 +4757,42 @@ const getMenuIds = () => {
4747
4757
  return [Main$1, Tab];
4748
4758
  };
4749
4759
 
4760
+ const focusEditorGroup = (state, groupId) => {
4761
+ const {
4762
+ layout
4763
+ } = state;
4764
+ const {
4765
+ groups
4766
+ } = layout;
4767
+ const updatedGroups = groups.map(group => ({
4768
+ ...group,
4769
+ focused: group.id === groupId
4770
+ }));
4771
+ return {
4772
+ ...state,
4773
+ layout: {
4774
+ ...layout,
4775
+ activeGroupId: groupId,
4776
+ groups: updatedGroups
4777
+ }
4778
+ };
4779
+ };
4780
+
4781
+ const parseRawGroupId = rawGroupId => {
4782
+ if (!rawGroupId) {
4783
+ return undefined;
4784
+ }
4785
+ const groupId = Number(rawGroupId);
4786
+ return Number.isNaN(groupId) ? undefined : groupId;
4787
+ };
4788
+
4750
4789
  const handleClick = async (state, name) => {
4751
- if (!name) {
4790
+ const groupId = parseRawGroupId(name);
4791
+ if (groupId === undefined) {
4752
4792
  return state;
4753
4793
  }
4754
- return state;
4794
+ const hasGroup = state.layout.groups.some(group => group.id === groupId);
4795
+ return hasGroup ? focusEditorGroup(state, groupId) : state;
4755
4796
  };
4756
4797
 
4757
4798
  const getActiveGroup = (groups, activeGroupId) => {
@@ -4800,27 +4841,6 @@ const findTabByUri = (state, uri) => {
4800
4841
  return undefined;
4801
4842
  };
4802
4843
 
4803
- const focusEditorGroup = (state, groupId) => {
4804
- const {
4805
- layout
4806
- } = state;
4807
- const {
4808
- groups
4809
- } = layout;
4810
- const updatedGroups = groups.map(group => ({
4811
- ...group,
4812
- focused: group.id === groupId
4813
- }));
4814
- return {
4815
- ...state,
4816
- layout: {
4817
- ...layout,
4818
- activeGroupId: groupId,
4819
- groups: updatedGroups
4820
- }
4821
- };
4822
- };
4823
-
4824
4844
  const getActiveTabId = state => {
4825
4845
  const {
4826
4846
  layout
@@ -5655,14 +5675,6 @@ const openUriWithContext = async (context, options, focus = true, viewletContext
5655
5675
  await openInputWithContext(context, getOpenInputOptions(options, focus, viewletContext));
5656
5676
  };
5657
5677
 
5658
- const parseRawGroupId = rawGroupId => {
5659
- if (!rawGroupId) {
5660
- return undefined;
5661
- }
5662
- const groupId = Number(rawGroupId);
5663
- return Number.isNaN(groupId) ? undefined : groupId;
5664
- };
5665
-
5666
5678
  const focusGroup = (groups, groupId, activeTabId) => {
5667
5679
  return groups.map(group => {
5668
5680
  if (group.id === groupId) {
@@ -7784,11 +7796,6 @@ const handleWorkspaceRefreshWithContext = async (context, refresh = {}) => {
7784
7796
  }
7785
7797
  };
7786
7798
 
7787
- const hasActiveTextEditor = state => {
7788
- const activeTab = getActiveTab(state);
7789
- return activeTab?.tab.editorInput?.type === 'editor';
7790
- };
7791
-
7792
7799
  const getTabs = group => {
7793
7800
  return group.tabs;
7794
7801
  };
@@ -8363,6 +8370,9 @@ const renderEventListeners = () => {
8363
8370
  return [{
8364
8371
  name: HandleClick,
8365
8372
  params: ['handleClick', TargetName]
8373
+ }, {
8374
+ name: HandleFocus,
8375
+ params: ['handleClick', 'event.target.dataset.groupId']
8366
8376
  }, {
8367
8377
  name: HandleClickClose,
8368
8378
  params: ['handleClickCloseTab', 'event.currentTarget.dataset.groupIndex', 'event.currentTarget.dataset.index'],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-area-worker",
3
- "version": "9.64.0",
3
+ "version": "9.64.2",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",