@lvce-editor/main-area-worker 5.0.0 → 5.2.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 +21 -44
- package/package.json +1 -1
|
@@ -1357,14 +1357,8 @@ const handleAttach = async command => {
|
|
|
1357
1357
|
await invoke('Layout.attachViewlet', parentNodeSelector, command.instanceId);
|
|
1358
1358
|
};
|
|
1359
1359
|
|
|
1360
|
-
let counter = 0;
|
|
1361
1360
|
const create = () => {
|
|
1362
|
-
return
|
|
1363
|
-
};
|
|
1364
|
-
const setMinId = minId => {
|
|
1365
|
-
if (minId > counter) {
|
|
1366
|
-
counter = minId;
|
|
1367
|
-
}
|
|
1361
|
+
return Math.random();
|
|
1368
1362
|
};
|
|
1369
1363
|
|
|
1370
1364
|
const updateTab = (state, tabId, updates) => {
|
|
@@ -1944,21 +1938,6 @@ const initialize = async () => {
|
|
|
1944
1938
|
set$2(rpc);
|
|
1945
1939
|
};
|
|
1946
1940
|
|
|
1947
|
-
const getMaxIdFromLayout = layout => {
|
|
1948
|
-
let maxId = 0;
|
|
1949
|
-
for (const group of layout.groups) {
|
|
1950
|
-
if (group.id > maxId) {
|
|
1951
|
-
maxId = group.id;
|
|
1952
|
-
}
|
|
1953
|
-
for (const tab of group.tabs) {
|
|
1954
|
-
if (tab.id > maxId) {
|
|
1955
|
-
maxId = tab.id;
|
|
1956
|
-
}
|
|
1957
|
-
}
|
|
1958
|
-
}
|
|
1959
|
-
return maxId;
|
|
1960
|
-
};
|
|
1961
|
-
|
|
1962
1941
|
const isValidTab = tab => {
|
|
1963
1942
|
return tab && typeof tab.id === 'number' && typeof tab.title === 'string' && typeof tab.content === 'string' && typeof tab.isDirty === 'boolean' && (tab.editorType === 'text' || tab.editorType === 'custom') && (tab.editorType !== 'custom' || typeof tab.customEditorId === 'string');
|
|
1964
1943
|
};
|
|
@@ -2129,6 +2108,19 @@ const loadFileIcons = async state => {
|
|
|
2129
2108
|
}
|
|
2130
2109
|
};
|
|
2131
2110
|
|
|
2111
|
+
const createViewlets = async (layout, viewletModuleIds, bounds) => {
|
|
2112
|
+
const editorUids = {};
|
|
2113
|
+
for (const group of layout.groups) {
|
|
2114
|
+
const activeTab = group.tabs.find(tab => tab.id === group.activeTabId);
|
|
2115
|
+
if (activeTab && viewletModuleIds[activeTab.id]) {
|
|
2116
|
+
const editorUid = activeTab.editorUid === -1 ? create() : activeTab.editorUid;
|
|
2117
|
+
editorUids[activeTab.id] = editorUid;
|
|
2118
|
+
await createViewlet(viewletModuleIds[activeTab.id], editorUid, activeTab.id, bounds, activeTab.uri);
|
|
2119
|
+
}
|
|
2120
|
+
}
|
|
2121
|
+
return editorUids;
|
|
2122
|
+
};
|
|
2123
|
+
|
|
2132
2124
|
const getViewletModuleId = async uri => {
|
|
2133
2125
|
// Query RendererWorker for viewlet module ID (optional, may fail in tests)
|
|
2134
2126
|
let viewletModuleId;
|
|
@@ -2141,9 +2133,6 @@ const getViewletModuleId = async uri => {
|
|
|
2141
2133
|
return viewletModuleId;
|
|
2142
2134
|
};
|
|
2143
2135
|
|
|
2144
|
-
const TAB_HEIGHT = 35;
|
|
2145
|
-
|
|
2146
|
-
// Get viewlet module IDs for active tabs in each group
|
|
2147
2136
|
const getViewletModuleIds = async layout => {
|
|
2148
2137
|
const viewletModuleIds = {};
|
|
2149
2138
|
for (const group of layout.groups) {
|
|
@@ -2158,21 +2147,6 @@ const getViewletModuleIds = async layout => {
|
|
|
2158
2147
|
return viewletModuleIds;
|
|
2159
2148
|
};
|
|
2160
2149
|
|
|
2161
|
-
// Create viewlets for the active tabs
|
|
2162
|
-
const createViewlets = async (layout, viewletModuleIds, bounds) => {
|
|
2163
|
-
const editorUids = {};
|
|
2164
|
-
for (const group of layout.groups) {
|
|
2165
|
-
const activeTab = group.tabs.find(tab => tab.id === group.activeTabId);
|
|
2166
|
-
if (activeTab && viewletModuleIds[activeTab.id]) {
|
|
2167
|
-
const editorUid = activeTab.editorUid === -1 ? create() : activeTab.editorUid;
|
|
2168
|
-
editorUids[activeTab.id] = editorUid;
|
|
2169
|
-
await createViewlet(viewletModuleIds[activeTab.id], editorUid, activeTab.id, bounds, activeTab.uri);
|
|
2170
|
-
}
|
|
2171
|
-
}
|
|
2172
|
-
return editorUids;
|
|
2173
|
-
};
|
|
2174
|
-
|
|
2175
|
-
// Update tabs with editor UIDs
|
|
2176
2150
|
const updateTabs = (state, editorUids) => {
|
|
2177
2151
|
const updatedGroups = state.layout.groups.map(group => {
|
|
2178
2152
|
return {
|
|
@@ -2196,6 +2170,8 @@ const updateTabs = (state, editorUids) => {
|
|
|
2196
2170
|
}
|
|
2197
2171
|
};
|
|
2198
2172
|
};
|
|
2173
|
+
|
|
2174
|
+
const TAB_HEIGHT = 35;
|
|
2199
2175
|
const restoreAndCreateEditors = async (state, restoredLayout) => {
|
|
2200
2176
|
let newState = {
|
|
2201
2177
|
...state,
|
|
@@ -2232,9 +2208,6 @@ const restoreAndCreateEditors = async (state, restoredLayout) => {
|
|
|
2232
2208
|
const loadContent = async (state, savedState) => {
|
|
2233
2209
|
const restoredLayout = tryRestoreLayout(savedState);
|
|
2234
2210
|
if (restoredLayout) {
|
|
2235
|
-
const maxId = getMaxIdFromLayout(restoredLayout);
|
|
2236
|
-
setMinId(maxId);
|
|
2237
|
-
|
|
2238
2211
|
// Restore and create editors
|
|
2239
2212
|
const editorState = await restoreAndCreateEditors(state, restoredLayout);
|
|
2240
2213
|
|
|
@@ -2819,7 +2792,11 @@ const renderTab = (tab, isActive, tabIndex, groupIndex) => {
|
|
|
2819
2792
|
'data-index': tabIndex,
|
|
2820
2793
|
onClick: HandleClickClose,
|
|
2821
2794
|
type: Button
|
|
2822
|
-
},
|
|
2795
|
+
}, {
|
|
2796
|
+
childCount: 0,
|
|
2797
|
+
className: 'MaskIcon MaskIconClose',
|
|
2798
|
+
type: Div
|
|
2799
|
+
}];
|
|
2823
2800
|
};
|
|
2824
2801
|
|
|
2825
2802
|
const renderTabBar = (group, groupIndex) => {
|