@lvce-editor/main-area-worker 1.8.0 → 1.9.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 +46 -21
- package/package.json +2 -2
|
@@ -96,12 +96,6 @@ const object = value => {
|
|
|
96
96
|
throw new AssertionError('expected value to be of type object');
|
|
97
97
|
}
|
|
98
98
|
};
|
|
99
|
-
const number = value => {
|
|
100
|
-
const type = getType(value);
|
|
101
|
-
if (type !== Number$1) {
|
|
102
|
-
throw new AssertionError('expected value to be of type number');
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
99
|
|
|
106
100
|
const isMessagePort = value => {
|
|
107
101
|
return value && value instanceof MessagePort;
|
|
@@ -1250,9 +1244,40 @@ const handleClick = async (state, name) => {
|
|
|
1250
1244
|
return state;
|
|
1251
1245
|
};
|
|
1252
1246
|
|
|
1253
|
-
const
|
|
1254
|
-
|
|
1255
|
-
|
|
1247
|
+
const closeTab = (state, groupId, tabId) => {
|
|
1248
|
+
const groups = state.layout.groups.map(group => {
|
|
1249
|
+
if (group.id === groupId) {
|
|
1250
|
+
const newTabs = group.tabs.filter(tab => tab.id !== tabId);
|
|
1251
|
+
let newActiveTabId = group.activeTabId;
|
|
1252
|
+
if (group.activeTabId === tabId) {
|
|
1253
|
+
const tabIndex = group.tabs.findIndex(tab => tab.id === tabId);
|
|
1254
|
+
if (newTabs.length > 0) {
|
|
1255
|
+
newActiveTabId = newTabs[Math.min(tabIndex, newTabs.length - 1)].id;
|
|
1256
|
+
} else {
|
|
1257
|
+
newActiveTabId = undefined;
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
return {
|
|
1261
|
+
...group,
|
|
1262
|
+
activeTabId: newActiveTabId,
|
|
1263
|
+
tabs: newTabs
|
|
1264
|
+
};
|
|
1265
|
+
}
|
|
1266
|
+
return group;
|
|
1267
|
+
});
|
|
1268
|
+
return {
|
|
1269
|
+
...state,
|
|
1270
|
+
layout: {
|
|
1271
|
+
...state.layout,
|
|
1272
|
+
groups
|
|
1273
|
+
}
|
|
1274
|
+
};
|
|
1275
|
+
};
|
|
1276
|
+
|
|
1277
|
+
const handleClickCloseTab = (state, rawGroupId, rawTabId) => {
|
|
1278
|
+
const groupId = Number.parseInt(rawGroupId);
|
|
1279
|
+
const tabId = Number.parseInt(rawTabId);
|
|
1280
|
+
return closeTab(state, groupId, tabId);
|
|
1256
1281
|
};
|
|
1257
1282
|
|
|
1258
1283
|
const selectTab = async (state, groupIndex, index) => {
|
|
@@ -1327,7 +1352,7 @@ const initialize = async () => {
|
|
|
1327
1352
|
set$2(rpc);
|
|
1328
1353
|
};
|
|
1329
1354
|
|
|
1330
|
-
const
|
|
1355
|
+
const getTabs = async () => {
|
|
1331
1356
|
const tabs = [{
|
|
1332
1357
|
content: '',
|
|
1333
1358
|
editorType: 'text',
|
|
@@ -1341,6 +1366,11 @@ const loadContent = async state => {
|
|
|
1341
1366
|
isDirty: false,
|
|
1342
1367
|
title: 'tab 2'
|
|
1343
1368
|
}];
|
|
1369
|
+
return tabs;
|
|
1370
|
+
};
|
|
1371
|
+
|
|
1372
|
+
const loadContent = async state => {
|
|
1373
|
+
const tabs = await getTabs();
|
|
1344
1374
|
return {
|
|
1345
1375
|
...state,
|
|
1346
1376
|
layout: {
|
|
@@ -1421,6 +1451,8 @@ const renderTab = (tab, isActive, tabIndex, groupIndex) => {
|
|
|
1421
1451
|
}, text(tab.isDirty ? `*${tab.title}` : tab.title), {
|
|
1422
1452
|
childCount: 1,
|
|
1423
1453
|
className: 'EditorTabCloseButton',
|
|
1454
|
+
'data-groupIndex': groupIndex,
|
|
1455
|
+
'data-index': tabIndex,
|
|
1424
1456
|
onClick: HandleClickClose,
|
|
1425
1457
|
type: Button
|
|
1426
1458
|
}, text('×')];
|
|
@@ -1519,19 +1551,12 @@ const resize = (state, dimensions) => {
|
|
|
1519
1551
|
};
|
|
1520
1552
|
};
|
|
1521
1553
|
|
|
1522
|
-
const saveState =
|
|
1523
|
-
number(uid);
|
|
1524
|
-
const value = get(uid);
|
|
1554
|
+
const saveState = state => {
|
|
1525
1555
|
const {
|
|
1526
|
-
|
|
1527
|
-
} =
|
|
1528
|
-
const {
|
|
1529
|
-
statusBarItemsLeft,
|
|
1530
|
-
statusBarItemsRight
|
|
1531
|
-
} = newState;
|
|
1556
|
+
layout
|
|
1557
|
+
} = state;
|
|
1532
1558
|
return {
|
|
1533
|
-
|
|
1534
|
-
itemsRight: statusBarItemsRight
|
|
1559
|
+
layout
|
|
1535
1560
|
};
|
|
1536
1561
|
};
|
|
1537
1562
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/main-area-worker",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "Main Area Worker",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -11,6 +11,6 @@
|
|
|
11
11
|
"type": "module",
|
|
12
12
|
"main": "dist/mainAreaWorkerMain.js",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@lvce-editor/virtual-dom-worker": "^5.
|
|
14
|
+
"@lvce-editor/virtual-dom-worker": "^5.1.0"
|
|
15
15
|
}
|
|
16
16
|
}
|