@lvce-editor/main-area-worker 9.53.0 → 9.53.1
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/mainAreaWorkerMain.js +107 -14
- package/package.json +1 -1
|
@@ -5065,6 +5065,17 @@ const handleDragStart = state => {
|
|
|
5065
5065
|
return state;
|
|
5066
5066
|
};
|
|
5067
5067
|
|
|
5068
|
+
const resetPointerDown = state => {
|
|
5069
|
+
if (state.pointerDownGroupIndex === -1 && state.pointerDownTabIndex === -1) {
|
|
5070
|
+
return state;
|
|
5071
|
+
}
|
|
5072
|
+
return {
|
|
5073
|
+
...state,
|
|
5074
|
+
pointerDownGroupIndex: -1,
|
|
5075
|
+
pointerDownTabIndex: -1
|
|
5076
|
+
};
|
|
5077
|
+
};
|
|
5078
|
+
|
|
5068
5079
|
const openUrisWithContext = async (context, uris, reuseExisting = true) => {
|
|
5069
5080
|
for (const uri of uris) {
|
|
5070
5081
|
await openUriWithContext(context, {
|
|
@@ -5257,6 +5268,81 @@ const applyDropAction = async (context, action, splitDirection, targetGroupId) =
|
|
|
5257
5268
|
}
|
|
5258
5269
|
};
|
|
5259
5270
|
|
|
5271
|
+
const moveTabToGroup = (state, sourceGroupId, targetGroupId, tabId, targetIndex) => {
|
|
5272
|
+
const {
|
|
5273
|
+
layout
|
|
5274
|
+
} = state;
|
|
5275
|
+
const {
|
|
5276
|
+
groups
|
|
5277
|
+
} = layout;
|
|
5278
|
+
const sourceGroup = groups.find(group => group.id === sourceGroupId);
|
|
5279
|
+
const hasTargetGroup = groups.some(group => group.id === targetGroupId);
|
|
5280
|
+
if (!sourceGroup || !hasTargetGroup || sourceGroupId === targetGroupId) {
|
|
5281
|
+
return state;
|
|
5282
|
+
}
|
|
5283
|
+
const tabToMove = sourceGroup.tabs.find(tab => tab.id === tabId);
|
|
5284
|
+
if (!tabToMove) {
|
|
5285
|
+
return state;
|
|
5286
|
+
}
|
|
5287
|
+
const updatedGroups = groups.map(group => {
|
|
5288
|
+
if (group.id === sourceGroupId) {
|
|
5289
|
+
const newTabs = group.tabs.filter(tab => tab.id !== tabId);
|
|
5290
|
+
let newActiveTabId = group.activeTabId;
|
|
5291
|
+
if (group.activeTabId === tabId) {
|
|
5292
|
+
if (newTabs.length > 0) {
|
|
5293
|
+
const removedIndex = group.tabs.findIndex(tab => tab.id === tabId);
|
|
5294
|
+
newActiveTabId = newTabs[Math.min(removedIndex, newTabs.length - 1)].id;
|
|
5295
|
+
} else {
|
|
5296
|
+
newActiveTabId = -1;
|
|
5297
|
+
}
|
|
5298
|
+
}
|
|
5299
|
+
return {
|
|
5300
|
+
...group,
|
|
5301
|
+
activeTabId: newActiveTabId,
|
|
5302
|
+
isEmpty: newTabs.length === 0,
|
|
5303
|
+
tabs: newTabs
|
|
5304
|
+
};
|
|
5305
|
+
}
|
|
5306
|
+
if (group.id === targetGroupId) {
|
|
5307
|
+
const insertIndex = group.tabs.length ;
|
|
5308
|
+
const newTabs = [...group.tabs];
|
|
5309
|
+
newTabs.splice(insertIndex, 0, tabToMove);
|
|
5310
|
+
return {
|
|
5311
|
+
...group,
|
|
5312
|
+
activeTabId: tabId,
|
|
5313
|
+
isEmpty: newTabs.length === 0,
|
|
5314
|
+
tabs: newTabs
|
|
5315
|
+
};
|
|
5316
|
+
}
|
|
5317
|
+
return group;
|
|
5318
|
+
});
|
|
5319
|
+
return {
|
|
5320
|
+
...state,
|
|
5321
|
+
layout: {
|
|
5322
|
+
...layout,
|
|
5323
|
+
activeGroupId: targetGroupId,
|
|
5324
|
+
groups: updatedGroups
|
|
5325
|
+
}
|
|
5326
|
+
};
|
|
5327
|
+
};
|
|
5328
|
+
|
|
5329
|
+
const getOpenTabCount = state => {
|
|
5330
|
+
return state.layout.groups.reduce((count, group) => count + group.tabs.length, 0);
|
|
5331
|
+
};
|
|
5332
|
+
const applyTabDrop = (state, sourceGroupId, tabId, splitDirection, targetGroupId) => {
|
|
5333
|
+
if (targetGroupId === undefined) {
|
|
5334
|
+
return state;
|
|
5335
|
+
}
|
|
5336
|
+
if (splitDirection === None) {
|
|
5337
|
+
return moveTabToGroup(state, sourceGroupId, targetGroupId, tabId);
|
|
5338
|
+
}
|
|
5339
|
+
if (getOpenTabCount(state) === 1) {
|
|
5340
|
+
return state;
|
|
5341
|
+
}
|
|
5342
|
+
const splitState = splitForDrop(state, splitDirection, targetGroupId);
|
|
5343
|
+
return moveTabToGroup(splitState, sourceGroupId, splitState.layout.activeGroupId, tabId);
|
|
5344
|
+
};
|
|
5345
|
+
|
|
5260
5346
|
const getDropAction = async uris => {
|
|
5261
5347
|
for (const uri of uris) {
|
|
5262
5348
|
if (uri.endsWith('/') || (await isDirectoryEditorInput({
|
|
@@ -5281,11 +5367,21 @@ const getDropAction = async uris => {
|
|
|
5281
5367
|
};
|
|
5282
5368
|
};
|
|
5283
5369
|
|
|
5370
|
+
const normalizeUri = uri => {
|
|
5371
|
+
return uri.startsWith('/') ? `file://${uri}` : uri;
|
|
5372
|
+
};
|
|
5284
5373
|
const handleDrop = async (context, dropIdOrItemIds) => {
|
|
5374
|
+
const initialState = context.getState();
|
|
5375
|
+
const {
|
|
5376
|
+
pointerDownGroupIndex,
|
|
5377
|
+
pointerDownTabIndex
|
|
5378
|
+
} = initialState;
|
|
5379
|
+
const sourceGroup = initialState.layout.groups[pointerDownGroupIndex];
|
|
5380
|
+
const draggedTab = sourceGroup?.tabs[pointerDownTabIndex];
|
|
5285
5381
|
const {
|
|
5286
5382
|
splitDirection = None,
|
|
5287
5383
|
targetGroupId
|
|
5288
|
-
} =
|
|
5384
|
+
} = initialState.dragOverlay ?? {};
|
|
5289
5385
|
await context.updateState(handleDragLeave);
|
|
5290
5386
|
const {
|
|
5291
5387
|
platform
|
|
@@ -5300,6 +5396,10 @@ const handleDrop = async (context, dropIdOrItemIds) => {
|
|
|
5300
5396
|
} = await getDroppedItems(dropIdOrItemIds, isElectron);
|
|
5301
5397
|
uris = droppedUris;
|
|
5302
5398
|
}
|
|
5399
|
+
if (draggedTab?.uri && uris.length === 1 && normalizeUri(uris[0]) === normalizeUri(draggedTab.uri)) {
|
|
5400
|
+
await context.updateState(state => resetPointerDown(applyTabDrop(state, sourceGroup.id, draggedTab.id, splitDirection, targetGroupId)));
|
|
5401
|
+
return;
|
|
5402
|
+
}
|
|
5303
5403
|
const actions = await getDropAction(uris);
|
|
5304
5404
|
await applyDropAction(context, actions, splitDirection, targetGroupId);
|
|
5305
5405
|
};
|
|
@@ -7556,6 +7656,9 @@ const renderTabIcon = tab => {
|
|
|
7556
7656
|
if (tab.uri?.startsWith(SearchEditorScheme)) {
|
|
7557
7657
|
return renderMaskIcon(MaskIconSearch);
|
|
7558
7658
|
}
|
|
7659
|
+
if (!tab.icon) {
|
|
7660
|
+
return [];
|
|
7661
|
+
}
|
|
7559
7662
|
return [{
|
|
7560
7663
|
childCount: 0,
|
|
7561
7664
|
className: TabIcon,
|
|
@@ -7566,6 +7669,7 @@ const renderTabIcon = tab => {
|
|
|
7566
7669
|
};
|
|
7567
7670
|
const renderTab = (tab, isActive, tabIndex, groupIndex) => {
|
|
7568
7671
|
const closeButtonNodes = renderTabActions(tab.isDirty, tabIndex, groupIndex);
|
|
7672
|
+
const tabIconNodes = renderTabIcon(tab);
|
|
7569
7673
|
let className = MainTab;
|
|
7570
7674
|
if (isActive) {
|
|
7571
7675
|
className = mergeClassNames(className, MainTabSelected);
|
|
@@ -7578,7 +7682,7 @@ const renderTab = (tab, isActive, tabIndex, groupIndex) => {
|
|
|
7578
7682
|
}
|
|
7579
7683
|
return [{
|
|
7580
7684
|
'aria-selected': isActive,
|
|
7581
|
-
childCount:
|
|
7685
|
+
childCount: 2 + (tabIconNodes.length > 0 ? 1 : 0),
|
|
7582
7686
|
className,
|
|
7583
7687
|
'data-groupIndex': groupIndex,
|
|
7584
7688
|
'data-index': tabIndex,
|
|
@@ -7594,7 +7698,7 @@ const renderTab = (tab, isActive, tabIndex, groupIndex) => {
|
|
|
7594
7698
|
tabIndex: isActive ? 0 : -1,
|
|
7595
7699
|
title: tab.uriTitle || tab.uri || tab.title,
|
|
7596
7700
|
type: Div
|
|
7597
|
-
}, ...
|
|
7701
|
+
}, ...tabIconNodes, tabTitleNode, text(tab.title), ...closeButtonNodes];
|
|
7598
7702
|
};
|
|
7599
7703
|
|
|
7600
7704
|
const getTabsVirtualDom = (group, groupIndex, tabsChildCount) => {
|
|
@@ -8186,17 +8290,6 @@ const reopenEditorWith = async (context, preferredEditorId) => {
|
|
|
8186
8290
|
}
|
|
8187
8291
|
};
|
|
8188
8292
|
|
|
8189
|
-
const resetPointerDown = state => {
|
|
8190
|
-
if (state.pointerDownGroupIndex === -1 && state.pointerDownTabIndex === -1) {
|
|
8191
|
-
return state;
|
|
8192
|
-
}
|
|
8193
|
-
return {
|
|
8194
|
-
...state,
|
|
8195
|
-
pointerDownGroupIndex: -1,
|
|
8196
|
-
pointerDownTabIndex: -1
|
|
8197
|
-
};
|
|
8198
|
-
};
|
|
8199
|
-
|
|
8200
8293
|
const resize$1 = (state, dimensions) => {
|
|
8201
8294
|
return {
|
|
8202
8295
|
...state,
|