@lvce-editor/main-area-worker 1.6.0 → 1.7.0
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 +48 -10
- package/package.json +1 -1
|
@@ -1256,8 +1256,44 @@ const handleClickCloseTab = (state, groupId, tabId) => {
|
|
|
1256
1256
|
};
|
|
1257
1257
|
|
|
1258
1258
|
const handleClickTab = async (state, groupIndex, index) => {
|
|
1259
|
-
|
|
1260
|
-
|
|
1259
|
+
const {
|
|
1260
|
+
layout
|
|
1261
|
+
} = state;
|
|
1262
|
+
const {
|
|
1263
|
+
groups
|
|
1264
|
+
} = layout;
|
|
1265
|
+
|
|
1266
|
+
// Validate indexes
|
|
1267
|
+
if (groupIndex < 0 || groupIndex >= groups.length) {
|
|
1268
|
+
return state;
|
|
1269
|
+
}
|
|
1270
|
+
const group = groups[groupIndex];
|
|
1271
|
+
if (index < 0 || index >= group.tabs.length) {
|
|
1272
|
+
return state;
|
|
1273
|
+
}
|
|
1274
|
+
const tab = group.tabs[index];
|
|
1275
|
+
const groupId = group.id;
|
|
1276
|
+
const tabId = tab.id;
|
|
1277
|
+
|
|
1278
|
+
// Return same state if this group and tab are already active
|
|
1279
|
+
if (layout.activeGroupId === groupId && group.activeTabId === tabId) {
|
|
1280
|
+
return state;
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
// Update the groups array with the new active tab and active group
|
|
1284
|
+
const updatedGroups = groups.map((g, i) => ({
|
|
1285
|
+
...g,
|
|
1286
|
+
activeTabId: i === groupIndex ? tabId : g.activeTabId,
|
|
1287
|
+
focused: i === groupIndex
|
|
1288
|
+
}));
|
|
1289
|
+
return {
|
|
1290
|
+
...state,
|
|
1291
|
+
layout: {
|
|
1292
|
+
...layout,
|
|
1293
|
+
activeGroupId: groupId,
|
|
1294
|
+
groups: updatedGroups
|
|
1295
|
+
}
|
|
1296
|
+
};
|
|
1261
1297
|
};
|
|
1262
1298
|
|
|
1263
1299
|
const id = 7201;
|
|
@@ -1360,10 +1396,12 @@ const HandleClick = 11;
|
|
|
1360
1396
|
const HandleClickClose = 12;
|
|
1361
1397
|
const HandleClickTab = 13;
|
|
1362
1398
|
|
|
1363
|
-
const renderTab = (tab, isActive) => {
|
|
1399
|
+
const renderTab = (tab, isActive, tabIndex, groupIndex) => {
|
|
1364
1400
|
return [{
|
|
1365
1401
|
childCount: 2,
|
|
1366
|
-
className: isActive ? 'MainTab
|
|
1402
|
+
className: isActive ? 'MainTab MainTabSelected' : 'MainTab',
|
|
1403
|
+
'data-group-index': groupIndex,
|
|
1404
|
+
'data-index': tabIndex,
|
|
1367
1405
|
onClick: HandleClickTab,
|
|
1368
1406
|
type: Div
|
|
1369
1407
|
}, {
|
|
@@ -1378,21 +1416,21 @@ const renderTab = (tab, isActive) => {
|
|
|
1378
1416
|
}, text('×')];
|
|
1379
1417
|
};
|
|
1380
1418
|
|
|
1381
|
-
const renderTabBar = group => {
|
|
1419
|
+
const renderTabBar = (group, groupIndex) => {
|
|
1382
1420
|
return [{
|
|
1383
1421
|
childCount: group.tabs.length,
|
|
1384
1422
|
className: 'MainTabs',
|
|
1385
1423
|
type: Div
|
|
1386
|
-
}, ...group.tabs.flatMap(tab => renderTab(tab, tab.id === group.activeTabId))];
|
|
1424
|
+
}, ...group.tabs.flatMap((tab, tabIndex) => renderTab(tab, tab.id === group.activeTabId, tabIndex, groupIndex))];
|
|
1387
1425
|
};
|
|
1388
1426
|
|
|
1389
|
-
const renderEditorGroup = group => {
|
|
1427
|
+
const renderEditorGroup = (group, groupIndex) => {
|
|
1390
1428
|
const activeTab = group.tabs.find(tab => tab.id === group.activeTabId);
|
|
1391
1429
|
return [{
|
|
1392
1430
|
childCount: 2,
|
|
1393
1431
|
className: 'EditorGroup',
|
|
1394
1432
|
type: Div
|
|
1395
|
-
}, ...renderTabBar(group), {
|
|
1433
|
+
}, ...renderTabBar(group, groupIndex), {
|
|
1396
1434
|
childCount: activeTab ? 1 : 1,
|
|
1397
1435
|
className: 'EditorContainer',
|
|
1398
1436
|
type: Div
|
|
@@ -1408,7 +1446,7 @@ const getMainAreaVirtualDom = layout => {
|
|
|
1408
1446
|
childCount: layout.groups.length,
|
|
1409
1447
|
className: CSS_CLASSES.EDITOR_GROUPS_CONTAINER,
|
|
1410
1448
|
type: Div
|
|
1411
|
-
}, ...layout.groups.flatMap(renderEditorGroup)];
|
|
1449
|
+
}, ...layout.groups.flatMap((group, groupIndex) => renderEditorGroup(group, groupIndex))];
|
|
1412
1450
|
};
|
|
1413
1451
|
|
|
1414
1452
|
const renderItems = (oldState, newState) => {
|
|
@@ -1459,7 +1497,7 @@ const renderEventListeners = () => {
|
|
|
1459
1497
|
name: HandleClickClose,
|
|
1460
1498
|
params: ['handleClickCloseTab', 'event.target.dataset.groupIndex', 'event.target.dataset.index']
|
|
1461
1499
|
}, {
|
|
1462
|
-
name:
|
|
1500
|
+
name: HandleClickTab,
|
|
1463
1501
|
params: ['handleClickTab', 'event.target.dataset.groupIndex', 'event.target.dataset.index']
|
|
1464
1502
|
}];
|
|
1465
1503
|
};
|