@lvce-editor/main-area-worker 9.44.1 → 9.44.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.
@@ -2723,7 +2723,7 @@ const getGroupById = (state, groupId) => {
2723
2723
  return groups.find(group => group.id === groupId);
2724
2724
  };
2725
2725
 
2726
- const closeTabsRight = (state, groupId) => {
2726
+ const closeTabsRight = (state, groupId, tabId) => {
2727
2727
  const {
2728
2728
  layout
2729
2729
  } = state;
@@ -2743,28 +2743,30 @@ const closeTabsRight = (state, groupId) => {
2743
2743
  activeTabId,
2744
2744
  tabs
2745
2745
  } = group;
2746
- if (activeTabId === -1) {
2746
+ const targetTabId = tabId ?? activeTabId;
2747
+ if (targetTabId === -1) {
2747
2748
  return state;
2748
2749
  }
2749
- const activeTabIndex = tabs.findIndex(tab => tab.id === activeTabId);
2750
- if (activeTabIndex === -1) {
2750
+ const targetTabIndex = tabs.findIndex(tab => tab.id === targetTabId);
2751
+ if (targetTabIndex === -1) {
2751
2752
  return state;
2752
2753
  }
2753
- const newTabs = tabs.slice(0, activeTabIndex + 1);
2754
+ const newTabs = tabs.slice(0, targetTabIndex + 1);
2754
2755
  if (newTabs.length === tabs.length) {
2755
2756
  return state;
2756
2757
  }
2757
2758
  const groupIndex = groups.findIndex(g => g.id === targetGroupId);
2758
- const closedTabs = tabs.slice(activeTabIndex + 1).map((tab, index) => ({
2759
+ const closedTabs = tabs.slice(targetTabIndex + 1).map((tab, index) => ({
2759
2760
  group,
2760
2761
  groupIndex,
2761
2762
  tab,
2762
- tabIndex: activeTabIndex + index + 1
2763
+ tabIndex: targetTabIndex + index + 1
2763
2764
  }));
2764
2765
  const newGroups = groups.map(g => {
2765
2766
  if (g.id === targetGroupId) {
2766
2767
  return {
2767
2768
  ...g,
2769
+ activeTabId: newTabs.some(tab => tab.id === activeTabId) ? activeTabId : targetTabId,
2768
2770
  isEmpty: newTabs.length === 0,
2769
2771
  tabs: newTabs
2770
2772
  };
@@ -5780,14 +5782,23 @@ const handleSashPointerUp = async state => {
5780
5782
  };
5781
5783
  };
5782
5784
 
5783
- const handleTabContextMenu = async (state, button, x, y) => {
5785
+ const handleTabContextMenu = async (state, button, x, y, groupIndexRaw = '', tabIndexRaw = '') => {
5784
5786
  number(x);
5785
5787
  number(y);
5786
5788
  const {
5787
5789
  uid
5788
5790
  } = state;
5791
+ const groupIndex = Number.parseInt(groupIndexRaw);
5792
+ const tabIndex = Number.parseInt(tabIndexRaw);
5793
+ const group = state.layout.groups[groupIndex];
5794
+ const tab = group?.tabs[tabIndex];
5795
+ const target = group && tab ? {
5796
+ groupId: group.id,
5797
+ tabId: tab.id
5798
+ } : {};
5789
5799
  await show2(uid, Tab, x, y, {
5790
- menuId: Tab
5800
+ menuId: Tab,
5801
+ ...target
5791
5802
  });
5792
5803
  return state;
5793
5804
  };
@@ -6430,15 +6441,14 @@ const getMenuEntries$2 = (state, groupId) => {
6430
6441
  }];
6431
6442
  };
6432
6443
 
6433
- // TODO should pass tab uri as argument or tab index
6434
- const getMenuEntries$1 = state => {
6444
+ const getMenuEntries$1 = (state, groupId, tabId) => {
6435
6445
  const {
6436
6446
  layout
6437
6447
  } = state;
6438
6448
  const {
6439
6449
  activeGroupId
6440
6450
  } = layout;
6441
- const group = findGroupById(state, activeGroupId || 0);
6451
+ const group = findGroupById(state, groupId ?? activeGroupId);
6442
6452
  if (!group) {
6443
6453
  return [];
6444
6454
  }
@@ -6446,7 +6456,7 @@ const getMenuEntries$1 = state => {
6446
6456
  activeTabId,
6447
6457
  tabs
6448
6458
  } = group;
6449
- const tab = tabs.find(t => t.id === activeTabId);
6459
+ const tab = tabs.find(t => t.id === (tabId ?? activeTabId));
6450
6460
  if (!tab) {
6451
6461
  return [];
6452
6462
  }
@@ -6464,6 +6474,7 @@ const getMenuEntries$1 = state => {
6464
6474
  id: 'tabCloseOthers',
6465
6475
  label: closeOthers()
6466
6476
  }, {
6477
+ args: [group.id, tab.id],
6467
6478
  command: 'Main.closeTabsRight',
6468
6479
  flags: None$1,
6469
6480
  id: 'tabCloseToTheRight',
@@ -6560,7 +6571,7 @@ const getMenuEntries = async (state, props) => {
6560
6571
  case Main$1:
6561
6572
  return getMenuEntries$2(state, props.groupId);
6562
6573
  case Tab:
6563
- return getMenuEntries$1(state);
6574
+ return getMenuEntries$1(state, props.groupId, props.tabId);
6564
6575
  default:
6565
6576
  return [];
6566
6577
  }
@@ -7731,7 +7742,7 @@ const renderEventListeners = () => {
7731
7742
  preventDefault: true
7732
7743
  }, {
7733
7744
  name: HandleTabContextMenu,
7734
- params: ['handleTabContextMenu', Button$1, ClientX, ClientY],
7745
+ params: ['handleTabContextMenu', Button$1, ClientX, ClientY, 'event.target.dataset.groupIndex', 'event.target.dataset.index'],
7735
7746
  preventDefault: true
7736
7747
  }, {
7737
7748
  name: HandleClickAction,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-area-worker",
3
- "version": "9.44.1",
3
+ "version": "9.44.2",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",