@lvce-editor/main-area-worker 8.2.0 → 8.4.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 +86 -35
- package/package.json +2 -2
|
@@ -2301,6 +2301,36 @@ const getActiveGroup = (groups, activeGroupId) => {
|
|
|
2301
2301
|
const Left = 'left';
|
|
2302
2302
|
const Right = 'right';
|
|
2303
2303
|
|
|
2304
|
+
const getActiveTab = state => {
|
|
2305
|
+
const {
|
|
2306
|
+
layout
|
|
2307
|
+
} = state;
|
|
2308
|
+
const {
|
|
2309
|
+
groups
|
|
2310
|
+
} = layout;
|
|
2311
|
+
const activeGroup = groups.find(group => group.focused);
|
|
2312
|
+
if (!activeGroup || !activeGroup.activeTabId) {
|
|
2313
|
+
return undefined;
|
|
2314
|
+
}
|
|
2315
|
+
const activeTab = activeGroup.tabs.find(tab => tab.id === activeGroup.activeTabId);
|
|
2316
|
+
if (!activeTab) {
|
|
2317
|
+
return undefined;
|
|
2318
|
+
}
|
|
2319
|
+
return {
|
|
2320
|
+
groupId: activeGroup.id,
|
|
2321
|
+
tab: activeTab
|
|
2322
|
+
};
|
|
2323
|
+
};
|
|
2324
|
+
|
|
2325
|
+
const handleClickTogglePreview = async state => {
|
|
2326
|
+
const activeTabInfo = getActiveTab(state);
|
|
2327
|
+
if (!activeTabInfo || !activeTabInfo.tab.uri) {
|
|
2328
|
+
return state;
|
|
2329
|
+
}
|
|
2330
|
+
await invoke('Layout.showPreview', activeTabInfo.tab.uri);
|
|
2331
|
+
return state;
|
|
2332
|
+
};
|
|
2333
|
+
|
|
2304
2334
|
const splitEditorGroup$1 = (state, groupId, direction) => {
|
|
2305
2335
|
const {
|
|
2306
2336
|
layout
|
|
@@ -2372,6 +2402,8 @@ const handleClickAction = async (state, action, rawGroupId) => {
|
|
|
2372
2402
|
return state;
|
|
2373
2403
|
case 'split-right':
|
|
2374
2404
|
return splitEditorGroup$1(state, activeGroup.id, Right);
|
|
2405
|
+
case 'toggle-preview':
|
|
2406
|
+
return handleClickTogglePreview(state);
|
|
2375
2407
|
default:
|
|
2376
2408
|
return state;
|
|
2377
2409
|
}
|
|
@@ -2678,7 +2710,8 @@ const handleResize = async (state, dimensions) => {
|
|
|
2678
2710
|
// Resize all editor children to their new bounds
|
|
2679
2711
|
const {
|
|
2680
2712
|
layout,
|
|
2681
|
-
tabHeight
|
|
2713
|
+
tabHeight,
|
|
2714
|
+
uid
|
|
2682
2715
|
} = state;
|
|
2683
2716
|
const {
|
|
2684
2717
|
groups
|
|
@@ -2702,6 +2735,7 @@ const handleResize = async (state, dimensions) => {
|
|
|
2702
2735
|
}
|
|
2703
2736
|
}
|
|
2704
2737
|
}
|
|
2738
|
+
allResizeCommands.push(['Viewlet.setBounds', uid, x, y, width, height]);
|
|
2705
2739
|
return allResizeCommands;
|
|
2706
2740
|
};
|
|
2707
2741
|
|
|
@@ -2963,13 +2997,15 @@ const tryRestoreLayout = savedState => {
|
|
|
2963
2997
|
}
|
|
2964
2998
|
|
|
2965
2999
|
// Normalize all tabs to have editorUid: -1 so SelectTab will create viewlets
|
|
3000
|
+
// Mark all restored tabs as not dirty
|
|
2966
3001
|
const normalizedLayout = {
|
|
2967
3002
|
...layout,
|
|
2968
3003
|
groups: layout.groups.map(group => ({
|
|
2969
3004
|
...group,
|
|
2970
3005
|
tabs: group.tabs.map(tab => ({
|
|
2971
3006
|
...tab,
|
|
2972
|
-
editorUid: -1
|
|
3007
|
+
editorUid: -1,
|
|
3008
|
+
isDirty: false
|
|
2973
3009
|
}))
|
|
2974
3010
|
}))
|
|
2975
3011
|
};
|
|
@@ -3134,6 +3170,7 @@ const CopyRelativePath = 'Copy Relative Path';
|
|
|
3134
3170
|
const FindFileReferences = 'Find File References';
|
|
3135
3171
|
const RevealInExplorer = 'Reveal in Explorer';
|
|
3136
3172
|
const SplitEditorGroup = 'Split Editor Group';
|
|
3173
|
+
const TogglePreview = 'Toggle Preview';
|
|
3137
3174
|
|
|
3138
3175
|
const splitEditorGroup = () => {
|
|
3139
3176
|
return i18nString(SplitEditorGroup);
|
|
@@ -3162,6 +3199,9 @@ const copyPath = () => {
|
|
|
3162
3199
|
const copyRelativePath = () => {
|
|
3163
3200
|
return i18nString(CopyRelativePath);
|
|
3164
3201
|
};
|
|
3202
|
+
const togglePreview = () => {
|
|
3203
|
+
return i18nString(TogglePreview);
|
|
3204
|
+
};
|
|
3165
3205
|
|
|
3166
3206
|
const menuEntrySeparator = {
|
|
3167
3207
|
command: '',
|
|
@@ -3971,24 +4011,55 @@ const getTabsVirtualDom = (group, groupIndex, tabsChildCount) => {
|
|
|
3971
4011
|
}, ...group.tabs.flatMap((tab, tabIndex) => renderTab(tab, tab.id === group.activeTabId, tabIndex, groupIndex))];
|
|
3972
4012
|
};
|
|
3973
4013
|
|
|
4014
|
+
const isHtmlFile = tab => {
|
|
4015
|
+
if (!tab || !tab.uri) {
|
|
4016
|
+
return false;
|
|
4017
|
+
}
|
|
4018
|
+
return tab.uri.endsWith('.html');
|
|
4019
|
+
};
|
|
4020
|
+
|
|
3974
4021
|
const renderEditorGroupActions = (group, groupIndex, splitButtonEnabled) => {
|
|
3975
|
-
|
|
4022
|
+
const activeTab = group.tabs.find(tab => tab.id === group.activeTabId);
|
|
4023
|
+
const showTogglePreview = isHtmlFile(activeTab);
|
|
4024
|
+
if (!splitButtonEnabled && !showTogglePreview) {
|
|
3976
4025
|
return [];
|
|
3977
4026
|
}
|
|
4027
|
+
const buttons = [];
|
|
4028
|
+
if (showTogglePreview) {
|
|
4029
|
+
buttons.push({
|
|
4030
|
+
ariaLabel: 'Preview',
|
|
4031
|
+
childCount: 1,
|
|
4032
|
+
className: 'IconButton',
|
|
4033
|
+
'data-action': 'toggle-preview',
|
|
4034
|
+
'data-groupId': String(group.id),
|
|
4035
|
+
name: 'toggle-preview',
|
|
4036
|
+
onClick: HandleClickAction,
|
|
4037
|
+
title: togglePreview(),
|
|
4038
|
+
type: Button$1
|
|
4039
|
+
}, {
|
|
4040
|
+
childCount: 0,
|
|
4041
|
+
className: 'MaskIcon MaskIconPreview',
|
|
4042
|
+
type: Div
|
|
4043
|
+
});
|
|
4044
|
+
}
|
|
4045
|
+
if (splitButtonEnabled) {
|
|
4046
|
+
buttons.push({
|
|
4047
|
+
childCount: 1,
|
|
4048
|
+
className: 'EditorGroupActionButton SplitEditorGroupButton',
|
|
4049
|
+
'data-action': 'split-right',
|
|
4050
|
+
'data-groupId': String(group.id),
|
|
4051
|
+
onClick: HandleClickAction,
|
|
4052
|
+
title: splitEditorGroup(),
|
|
4053
|
+
type: Button$1
|
|
4054
|
+
}, text('split'));
|
|
4055
|
+
}
|
|
3978
4056
|
return [{
|
|
3979
|
-
childCount:
|
|
4057
|
+
childCount: buttons.length / 2,
|
|
4058
|
+
// Each button has 2 nodes (button + text)
|
|
3980
4059
|
className: 'EditorGroupActions',
|
|
3981
4060
|
role: 'toolbar',
|
|
3982
4061
|
type: Div
|
|
3983
|
-
},
|
|
3984
|
-
childCount: 1,
|
|
3985
|
-
className: 'EditorGroupActionButton SplitEditorGroupButton',
|
|
3986
|
-
'data-action': 'split-right',
|
|
3987
|
-
'data-groupId': String(group.id),
|
|
3988
|
-
onClick: HandleClickAction,
|
|
3989
|
-
title: splitEditorGroup(),
|
|
3990
|
-
type: Button$1
|
|
3991
|
-
}, text('split')];
|
|
4062
|
+
}, ...buttons];
|
|
3992
4063
|
};
|
|
3993
4064
|
|
|
3994
4065
|
const renderEditorGroupHeader = (group, groupIndex, splitButtonEnabled) => {
|
|
@@ -4100,34 +4171,13 @@ const renderEventListeners = () => {
|
|
|
4100
4171
|
preventDefault: true
|
|
4101
4172
|
}, {
|
|
4102
4173
|
name: HandleClickAction,
|
|
4103
|
-
params: ['handleClickAction',
|
|
4174
|
+
params: ['handleClickAction', TargetName, 'event.target.dataset.groupId']
|
|
4104
4175
|
}, {
|
|
4105
4176
|
name: HandleHeaderDoubleClick,
|
|
4106
4177
|
params: ['handleHeaderDoubleClick', 'event.target.className', 'event.target.dataset.groupId']
|
|
4107
4178
|
}];
|
|
4108
4179
|
};
|
|
4109
4180
|
|
|
4110
|
-
const getActiveTab = state => {
|
|
4111
|
-
const {
|
|
4112
|
-
layout
|
|
4113
|
-
} = state;
|
|
4114
|
-
const {
|
|
4115
|
-
groups
|
|
4116
|
-
} = layout;
|
|
4117
|
-
const activeGroup = groups.find(group => group.focused);
|
|
4118
|
-
if (!activeGroup || !activeGroup.activeTabId) {
|
|
4119
|
-
return undefined;
|
|
4120
|
-
}
|
|
4121
|
-
const activeTab = activeGroup.tabs.find(tab => tab.id === activeGroup.activeTabId);
|
|
4122
|
-
if (!activeTab) {
|
|
4123
|
-
return undefined;
|
|
4124
|
-
}
|
|
4125
|
-
return {
|
|
4126
|
-
groupId: activeGroup.id,
|
|
4127
|
-
tab: activeTab
|
|
4128
|
-
};
|
|
4129
|
-
};
|
|
4130
|
-
|
|
4131
4181
|
const saveEditor = async editorUid => {
|
|
4132
4182
|
await invoke('Editor.save', editorUid);
|
|
4133
4183
|
};
|
|
@@ -4271,6 +4321,7 @@ const commandMap = {
|
|
|
4271
4321
|
'MainArea.handleClickAction': wrapCommand(handleClickAction),
|
|
4272
4322
|
'MainArea.handleClickCloseTab': wrapCommand(handleClickCloseTab),
|
|
4273
4323
|
'MainArea.handleClickTab': wrapCommand(handleClickTab),
|
|
4324
|
+
'MainArea.handleClickTogglePreview': wrapCommand(handleClickTogglePreview),
|
|
4274
4325
|
'MainArea.handleDoubleClick': wrapCommand(handleDoubleClick),
|
|
4275
4326
|
'MainArea.handleHeaderDoubleClick': wrapCommand(handleHeaderDoubleClick),
|
|
4276
4327
|
'MainArea.handleModifiedStatusChange': wrapCommand(handleModifiedStatusChange),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/main-area-worker",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.4.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": "^7.
|
|
14
|
+
"@lvce-editor/virtual-dom-worker": "^7.2.0"
|
|
15
15
|
}
|
|
16
16
|
}
|