@lvce-editor/main-area-worker 8.2.0 → 8.3.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 +80 -33
- 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
|
}
|
|
@@ -3134,6 +3166,7 @@ const CopyRelativePath = 'Copy Relative Path';
|
|
|
3134
3166
|
const FindFileReferences = 'Find File References';
|
|
3135
3167
|
const RevealInExplorer = 'Reveal in Explorer';
|
|
3136
3168
|
const SplitEditorGroup = 'Split Editor Group';
|
|
3169
|
+
const TogglePreview = 'Toggle Preview';
|
|
3137
3170
|
|
|
3138
3171
|
const splitEditorGroup = () => {
|
|
3139
3172
|
return i18nString(SplitEditorGroup);
|
|
@@ -3162,6 +3195,9 @@ const copyPath = () => {
|
|
|
3162
3195
|
const copyRelativePath = () => {
|
|
3163
3196
|
return i18nString(CopyRelativePath);
|
|
3164
3197
|
};
|
|
3198
|
+
const togglePreview = () => {
|
|
3199
|
+
return i18nString(TogglePreview);
|
|
3200
|
+
};
|
|
3165
3201
|
|
|
3166
3202
|
const menuEntrySeparator = {
|
|
3167
3203
|
command: '',
|
|
@@ -3971,24 +4007,55 @@ const getTabsVirtualDom = (group, groupIndex, tabsChildCount) => {
|
|
|
3971
4007
|
}, ...group.tabs.flatMap((tab, tabIndex) => renderTab(tab, tab.id === group.activeTabId, tabIndex, groupIndex))];
|
|
3972
4008
|
};
|
|
3973
4009
|
|
|
4010
|
+
const isHtmlFile = tab => {
|
|
4011
|
+
if (!tab || !tab.uri) {
|
|
4012
|
+
return false;
|
|
4013
|
+
}
|
|
4014
|
+
return tab.uri.endsWith('.html');
|
|
4015
|
+
};
|
|
4016
|
+
|
|
3974
4017
|
const renderEditorGroupActions = (group, groupIndex, splitButtonEnabled) => {
|
|
3975
|
-
|
|
4018
|
+
const activeTab = group.tabs.find(tab => tab.id === group.activeTabId);
|
|
4019
|
+
const showTogglePreview = isHtmlFile(activeTab);
|
|
4020
|
+
if (!splitButtonEnabled && !showTogglePreview) {
|
|
3976
4021
|
return [];
|
|
3977
4022
|
}
|
|
4023
|
+
const buttons = [];
|
|
4024
|
+
if (showTogglePreview) {
|
|
4025
|
+
buttons.push({
|
|
4026
|
+
ariaLabel: 'Preview',
|
|
4027
|
+
childCount: 1,
|
|
4028
|
+
className: 'IconButton',
|
|
4029
|
+
'data-action': 'toggle-preview',
|
|
4030
|
+
'data-groupId': String(group.id),
|
|
4031
|
+
name: 'toggle-preview',
|
|
4032
|
+
onClick: HandleClickAction,
|
|
4033
|
+
title: togglePreview(),
|
|
4034
|
+
type: Button$1
|
|
4035
|
+
}, {
|
|
4036
|
+
childCount: 0,
|
|
4037
|
+
className: 'MaskIcon MaskIconPreview',
|
|
4038
|
+
type: Div
|
|
4039
|
+
});
|
|
4040
|
+
}
|
|
4041
|
+
if (splitButtonEnabled) {
|
|
4042
|
+
buttons.push({
|
|
4043
|
+
childCount: 1,
|
|
4044
|
+
className: 'EditorGroupActionButton SplitEditorGroupButton',
|
|
4045
|
+
'data-action': 'split-right',
|
|
4046
|
+
'data-groupId': String(group.id),
|
|
4047
|
+
onClick: HandleClickAction,
|
|
4048
|
+
title: splitEditorGroup(),
|
|
4049
|
+
type: Button$1
|
|
4050
|
+
}, text('split'));
|
|
4051
|
+
}
|
|
3978
4052
|
return [{
|
|
3979
|
-
childCount:
|
|
4053
|
+
childCount: buttons.length / 2,
|
|
4054
|
+
// Each button has 2 nodes (button + text)
|
|
3980
4055
|
className: 'EditorGroupActions',
|
|
3981
4056
|
role: 'toolbar',
|
|
3982
4057
|
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')];
|
|
4058
|
+
}, ...buttons];
|
|
3992
4059
|
};
|
|
3993
4060
|
|
|
3994
4061
|
const renderEditorGroupHeader = (group, groupIndex, splitButtonEnabled) => {
|
|
@@ -4100,34 +4167,13 @@ const renderEventListeners = () => {
|
|
|
4100
4167
|
preventDefault: true
|
|
4101
4168
|
}, {
|
|
4102
4169
|
name: HandleClickAction,
|
|
4103
|
-
params: ['handleClickAction',
|
|
4170
|
+
params: ['handleClickAction', TargetName, 'event.target.dataset.groupId']
|
|
4104
4171
|
}, {
|
|
4105
4172
|
name: HandleHeaderDoubleClick,
|
|
4106
4173
|
params: ['handleHeaderDoubleClick', 'event.target.className', 'event.target.dataset.groupId']
|
|
4107
4174
|
}];
|
|
4108
4175
|
};
|
|
4109
4176
|
|
|
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
4177
|
const saveEditor = async editorUid => {
|
|
4132
4178
|
await invoke('Editor.save', editorUid);
|
|
4133
4179
|
};
|
|
@@ -4271,6 +4317,7 @@ const commandMap = {
|
|
|
4271
4317
|
'MainArea.handleClickAction': wrapCommand(handleClickAction),
|
|
4272
4318
|
'MainArea.handleClickCloseTab': wrapCommand(handleClickCloseTab),
|
|
4273
4319
|
'MainArea.handleClickTab': wrapCommand(handleClickTab),
|
|
4320
|
+
'MainArea.handleClickTogglePreview': wrapCommand(handleClickTogglePreview),
|
|
4274
4321
|
'MainArea.handleDoubleClick': wrapCommand(handleDoubleClick),
|
|
4275
4322
|
'MainArea.handleHeaderDoubleClick': wrapCommand(handleHeaderDoubleClick),
|
|
4276
4323
|
'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.3.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
|
}
|