@lvce-editor/main-area-worker 9.28.2 → 9.29.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 +61 -9
- package/package.json +1 -1
|
@@ -2261,7 +2261,10 @@ const closeTabAndSave = async (state, groupId, tabId) => {
|
|
|
2261
2261
|
}
|
|
2262
2262
|
if (tab.editorUid !== -1 && tab.isDirty) {
|
|
2263
2263
|
const editorState = await saveEditor(tab.editorUid);
|
|
2264
|
-
if (
|
|
2264
|
+
if (editorState?.modified !== false) {
|
|
2265
|
+
return state;
|
|
2266
|
+
}
|
|
2267
|
+
if (tab.uri) {
|
|
2265
2268
|
await handleModifiedStatusChange$1(tab.uri, false);
|
|
2266
2269
|
}
|
|
2267
2270
|
}
|
|
@@ -3673,6 +3676,7 @@ const ensureActiveGroup = (state, uri, preview = false, title = getLabel(uri), e
|
|
|
3673
3676
|
...tab,
|
|
3674
3677
|
editorInput,
|
|
3675
3678
|
editorType,
|
|
3679
|
+
editorUid: create$2(),
|
|
3676
3680
|
errorMessage: '',
|
|
3677
3681
|
icon: '',
|
|
3678
3682
|
isDirty: false,
|
|
@@ -3922,6 +3926,18 @@ const updateTabIcon = async (context, readyState, tabId) => {
|
|
|
3922
3926
|
}
|
|
3923
3927
|
};
|
|
3924
3928
|
|
|
3929
|
+
const getExistingTabState = (state, existingTab, preview) => {
|
|
3930
|
+
const focusedState = focusEditorGroup(state, existingTab.groupId);
|
|
3931
|
+
const pinnedState = !preview && existingTab.tab.isPreview ? updateTab(focusedState, existingTab.tab.id, {
|
|
3932
|
+
isPreview: false
|
|
3933
|
+
}) : focusedState;
|
|
3934
|
+
return switchTab(pinnedState, existingTab.groupId, existingTab.tab.id);
|
|
3935
|
+
};
|
|
3936
|
+
const getActivePreviewEditorUid = state => {
|
|
3937
|
+
const activeGroup = state.layout.activeGroupId === undefined ? state.layout.groups.find(group => group.focused) : state.layout.groups.find(group => group.id === state.layout.activeGroupId);
|
|
3938
|
+
const activeTab = activeGroup?.tabs.find(tab => tab.id === activeGroup.activeTabId);
|
|
3939
|
+
return activeTab?.isPreview ? activeTab.editorUid : -1;
|
|
3940
|
+
};
|
|
3925
3941
|
const openInputWithContext = async (context, options) => {
|
|
3926
3942
|
const state = context.getState();
|
|
3927
3943
|
object(state);
|
|
@@ -3937,17 +3953,20 @@ const openInputWithContext = async (context, options) => {
|
|
|
3937
3953
|
const existingTab = findTabByUri(currentState, uri);
|
|
3938
3954
|
const shouldRetryExistingTab = !!existingTab && existingTab.tab.loadingState === 'error';
|
|
3939
3955
|
if (existingTab && !shouldRetryExistingTab) {
|
|
3940
|
-
const
|
|
3941
|
-
const switchedState = switchTab(focusedState, existingTab.groupId, existingTab.tab.id);
|
|
3956
|
+
const switchedState = getExistingTabState(currentState, existingTab, preview);
|
|
3942
3957
|
await context.updateState(() => switchedState);
|
|
3943
3958
|
return;
|
|
3944
3959
|
}
|
|
3960
|
+
const replacedEditorUid = getActivePreviewEditorUid(currentState);
|
|
3945
3961
|
const previousTabId = getActiveTabId(currentState);
|
|
3946
3962
|
const {
|
|
3947
3963
|
stateWithTab,
|
|
3948
3964
|
tabId
|
|
3949
3965
|
} = getStateWithTab(currentState, editorInput, existingTab, shouldRetryExistingTab, uri, preview, title, editorType);
|
|
3950
3966
|
await context.updateState(() => stateWithTab);
|
|
3967
|
+
if (replacedEditorUid !== -1) {
|
|
3968
|
+
await disposeEditors([replacedEditorUid]);
|
|
3969
|
+
}
|
|
3951
3970
|
if (await isDirectoryEditorInput(editorInput)) {
|
|
3952
3971
|
const latestState = context.getState();
|
|
3953
3972
|
const errorState = updateTab(latestState, tabId, {
|
|
@@ -4370,9 +4389,19 @@ const handleContextMenu = async (state, rawGroupId, x, y) => {
|
|
|
4370
4389
|
return state;
|
|
4371
4390
|
};
|
|
4372
4391
|
|
|
4373
|
-
const handleDoubleClick =
|
|
4374
|
-
|
|
4375
|
-
|
|
4392
|
+
const handleDoubleClick = (state, groupIndexRaw, indexRaw) => {
|
|
4393
|
+
if (!groupIndexRaw || !indexRaw) {
|
|
4394
|
+
return state;
|
|
4395
|
+
}
|
|
4396
|
+
const groupIndex = Number.parseInt(groupIndexRaw);
|
|
4397
|
+
const tabIndex = Number.parseInt(indexRaw);
|
|
4398
|
+
const tab = state.layout.groups[groupIndex]?.tabs[tabIndex];
|
|
4399
|
+
if (!tab?.isPreview) {
|
|
4400
|
+
return state;
|
|
4401
|
+
}
|
|
4402
|
+
return updateTab(state, tab.id, {
|
|
4403
|
+
isPreview: false
|
|
4404
|
+
});
|
|
4376
4405
|
};
|
|
4377
4406
|
|
|
4378
4407
|
const EditorGroupHeader = 'EditorGroupHeader';
|
|
@@ -4593,7 +4622,8 @@ const handleModifiedStatusChange = (state, uri, newStatus) => {
|
|
|
4593
4622
|
if (tab.uri === uri) {
|
|
4594
4623
|
return {
|
|
4595
4624
|
...tab,
|
|
4596
|
-
isDirty: newStatus
|
|
4625
|
+
isDirty: newStatus,
|
|
4626
|
+
isPreview: newStatus ? false : tab.isPreview
|
|
4597
4627
|
};
|
|
4598
4628
|
}
|
|
4599
4629
|
return tab;
|
|
@@ -4810,6 +4840,15 @@ const handleUriChange = async (state, oldUri, newUri) => {
|
|
|
4810
4840
|
groups
|
|
4811
4841
|
} = layout;
|
|
4812
4842
|
const newTitle = getLabel(newUri);
|
|
4843
|
+
const editorUriUpdates = [];
|
|
4844
|
+
for (const group of groups) {
|
|
4845
|
+
for (const tab of group.tabs) {
|
|
4846
|
+
if (tab.uri === oldUri && tab.editorType === 'text' && tab.editorUid !== -1) {
|
|
4847
|
+
editorUriUpdates.push(invoke('Editor.handleUriChange', tab.editorUid, newUri));
|
|
4848
|
+
}
|
|
4849
|
+
}
|
|
4850
|
+
}
|
|
4851
|
+
await Promise.all(editorUriUpdates);
|
|
4813
4852
|
const updatedGroups = groups.map(group => {
|
|
4814
4853
|
return {
|
|
4815
4854
|
...group,
|
|
@@ -5954,6 +5993,7 @@ const HandleHeaderDoubleClick = 15;
|
|
|
5954
5993
|
const HandleSashPointerDown = 16;
|
|
5955
5994
|
const HandleSashPointerMove = 17;
|
|
5956
5995
|
const HandleSashPointerUp = 18;
|
|
5996
|
+
const HandleDoubleClick = 19;
|
|
5957
5997
|
|
|
5958
5998
|
const renderContent = content => {
|
|
5959
5999
|
return [{
|
|
@@ -6120,6 +6160,7 @@ const renderTab = (tab, isActive, tabIndex, groupIndex) => {
|
|
|
6120
6160
|
'data-groupIndex': groupIndex,
|
|
6121
6161
|
'data-index': tabIndex,
|
|
6122
6162
|
onContextMenu: HandleTabContextMenu,
|
|
6163
|
+
onDblClick: HandleDoubleClick,
|
|
6123
6164
|
onMouseDown: HandleClickTab,
|
|
6124
6165
|
role: 'tab',
|
|
6125
6166
|
title: tab.uriTitle || tab.uri || tab.title,
|
|
@@ -6481,6 +6522,9 @@ const renderEventListeners = () => {
|
|
|
6481
6522
|
}, {
|
|
6482
6523
|
name: HandleClickTab,
|
|
6483
6524
|
params: ['handleClickTab', 'event.target.dataset.groupIndex', 'event.target.dataset.index', Button$1]
|
|
6525
|
+
}, {
|
|
6526
|
+
name: HandleDoubleClick,
|
|
6527
|
+
params: ['handleDoubleClick', 'event.target.dataset.groupIndex', 'event.target.dataset.index']
|
|
6484
6528
|
}, {
|
|
6485
6529
|
name: HandleContextMenu,
|
|
6486
6530
|
params: ['handleContextMenu', 'event.target.dataset.groupId', ClientX, ClientY],
|
|
@@ -6604,6 +6648,14 @@ const reopenEditorWith = async context => {
|
|
|
6604
6648
|
}
|
|
6605
6649
|
};
|
|
6606
6650
|
|
|
6651
|
+
const settingsUri = 'app://settings.json';
|
|
6652
|
+
const saveEditorAndHandleSettingsChange = async tab => {
|
|
6653
|
+
const editorState = await saveEditor(tab.editorUid);
|
|
6654
|
+
if (!editorState?.modified && tab.uri === settingsUri) {
|
|
6655
|
+
await invoke('Layout.handleSettingsChanged');
|
|
6656
|
+
}
|
|
6657
|
+
return editorState;
|
|
6658
|
+
};
|
|
6607
6659
|
const getLatestStoredState = (uid, fallbackState, referenceTabId, referenceTabUri, allowMissingReference = false) => {
|
|
6608
6660
|
const stateFromStore = get(uid);
|
|
6609
6661
|
if (!stateFromStore) {
|
|
@@ -6639,10 +6691,10 @@ const save = async state => {
|
|
|
6639
6691
|
return currentState;
|
|
6640
6692
|
}
|
|
6641
6693
|
if (!tab.isDirty) {
|
|
6642
|
-
await
|
|
6694
|
+
await saveEditorAndHandleSettingsChange(tab);
|
|
6643
6695
|
return getLatestStoredState(state.uid, currentState, tab.id, tab.uri);
|
|
6644
6696
|
}
|
|
6645
|
-
const editorState = await
|
|
6697
|
+
const editorState = await saveEditorAndHandleSettingsChange(tab);
|
|
6646
6698
|
const latestState = getLatestStoredState(state.uid, currentState, tab.id, tab.uri);
|
|
6647
6699
|
if (editorState?.modified) {
|
|
6648
6700
|
return latestState;
|