@lvce-editor/main-area-worker 9.3.0 → 9.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 +90 -41
- package/package.json +1 -1
|
@@ -1716,6 +1716,8 @@ const Main$1 = 24;
|
|
|
1716
1716
|
const Separator = 1;
|
|
1717
1717
|
const None = 0;
|
|
1718
1718
|
|
|
1719
|
+
const Electron = 2;
|
|
1720
|
+
|
|
1719
1721
|
const ClipBoardWorker = 3400;
|
|
1720
1722
|
const ExtensionHostWorker = 44;
|
|
1721
1723
|
const IconThemeWorker = 7009;
|
|
@@ -3459,8 +3461,7 @@ const handleResize = async (state, dimensions) => {
|
|
|
3459
3461
|
// Resize all editor children to their new bounds
|
|
3460
3462
|
const {
|
|
3461
3463
|
layout,
|
|
3462
|
-
tabHeight
|
|
3463
|
-
uid
|
|
3464
|
+
tabHeight
|
|
3464
3465
|
} = state;
|
|
3465
3466
|
const {
|
|
3466
3467
|
groups
|
|
@@ -3484,7 +3485,6 @@ const handleResize = async (state, dimensions) => {
|
|
|
3484
3485
|
}
|
|
3485
3486
|
}
|
|
3486
3487
|
}
|
|
3487
|
-
allResizeCommands.push(['Viewlet.setBounds', uid, x, y, width, height]);
|
|
3488
3488
|
return allResizeCommands;
|
|
3489
3489
|
};
|
|
3490
3490
|
|
|
@@ -3992,7 +3992,7 @@ const splitRight$1 = () => {
|
|
|
3992
3992
|
const splitEditorGroup = () => {
|
|
3993
3993
|
return i18nString(SplitEditorGroup);
|
|
3994
3994
|
};
|
|
3995
|
-
const newWindow = () => {
|
|
3995
|
+
const newWindow$1 = () => {
|
|
3996
3996
|
return i18nString(NewWindow);
|
|
3997
3997
|
};
|
|
3998
3998
|
const close = () => {
|
|
@@ -4075,7 +4075,18 @@ const getArgs = groupId => {
|
|
|
4075
4075
|
}
|
|
4076
4076
|
return [groupId];
|
|
4077
4077
|
};
|
|
4078
|
-
const
|
|
4078
|
+
const getNewWindowMenuEntries = state => {
|
|
4079
|
+
if (state.platform !== Electron) {
|
|
4080
|
+
return [];
|
|
4081
|
+
}
|
|
4082
|
+
return [menuEntrySeparator, {
|
|
4083
|
+
command: 'MainArea.newWindow',
|
|
4084
|
+
flags: None,
|
|
4085
|
+
id: 'newWindow',
|
|
4086
|
+
label: newWindow$1()
|
|
4087
|
+
}];
|
|
4088
|
+
};
|
|
4089
|
+
const getMenuEntries$2 = (state, groupId) => {
|
|
4079
4090
|
const groupArgs = getArgs(groupId);
|
|
4080
4091
|
const entries = [{
|
|
4081
4092
|
args: [QuickPick, 'file'],
|
|
@@ -4107,12 +4118,7 @@ const getMenuEntries$2 = groupId => {
|
|
|
4107
4118
|
flags: None,
|
|
4108
4119
|
id: 'splitRight',
|
|
4109
4120
|
label: splitRight$1()
|
|
4110
|
-
},
|
|
4111
|
-
command: 'Main.newWindow',
|
|
4112
|
-
flags: None,
|
|
4113
|
-
id: 'newWindow',
|
|
4114
|
-
label: newWindow()
|
|
4115
|
-
}];
|
|
4121
|
+
}, ...getNewWindowMenuEntries(state)];
|
|
4116
4122
|
if (!hasTargetGroup(groupId)) {
|
|
4117
4123
|
return entries;
|
|
4118
4124
|
}
|
|
@@ -4263,7 +4269,7 @@ const getMenuEntries$1 = state => {
|
|
|
4263
4269
|
const getMenuEntries = async (state, props) => {
|
|
4264
4270
|
switch (props.menuId) {
|
|
4265
4271
|
case Main$1:
|
|
4266
|
-
return getMenuEntries$2(props.groupId);
|
|
4272
|
+
return getMenuEntries$2(state, props.groupId);
|
|
4267
4273
|
case Tab:
|
|
4268
4274
|
return getMenuEntries$1(state);
|
|
4269
4275
|
default:
|
|
@@ -4271,6 +4277,11 @@ const getMenuEntries = async (state, props) => {
|
|
|
4271
4277
|
}
|
|
4272
4278
|
};
|
|
4273
4279
|
|
|
4280
|
+
const newWindow = async state => {
|
|
4281
|
+
await invoke('Main.newWindow');
|
|
4282
|
+
return state;
|
|
4283
|
+
};
|
|
4284
|
+
|
|
4274
4285
|
const openUris = async (state, uris) => {
|
|
4275
4286
|
if (uris.length === 0) {
|
|
4276
4287
|
return state;
|
|
@@ -4299,19 +4310,54 @@ const refresh = state => {
|
|
|
4299
4310
|
};
|
|
4300
4311
|
};
|
|
4301
4312
|
|
|
4302
|
-
const
|
|
4313
|
+
const getEditorGroupCss = layout => {
|
|
4314
|
+
const groupSizeVariable = layout.direction === Vertical ? '--EditorGroupHeight' : '--EditorGroupWidth';
|
|
4315
|
+
return layout.groups.map(group => {
|
|
4316
|
+
return `.EditorGroup[data-groupId="${group.id}"] {
|
|
4317
|
+
${groupSizeVariable}: ${group.size}%;
|
|
4318
|
+
}`;
|
|
4319
|
+
});
|
|
4320
|
+
};
|
|
4321
|
+
const getSashCss = layout => {
|
|
4322
|
+
if (layout.groups.length <= 1) {
|
|
4323
|
+
return [];
|
|
4324
|
+
}
|
|
4325
|
+
const sashPositionVariable = layout.direction === Horizontal ? '--SashLeft' : '--SashTop';
|
|
4326
|
+
const rules = [];
|
|
4327
|
+
let sashOffset = 0;
|
|
4328
|
+
for (let i = 1; i < layout.groups.length; i++) {
|
|
4329
|
+
sashOffset += layout.groups[i - 1].size;
|
|
4330
|
+
const beforeGroupId = layout.groups[i - 1].id;
|
|
4331
|
+
const afterGroupId = layout.groups[i].id;
|
|
4332
|
+
const sashId = create(beforeGroupId, afterGroupId);
|
|
4333
|
+
rules.push(`.Sash[data-sashId="${sashId}"] {
|
|
4334
|
+
${sashPositionVariable}: ${sashOffset}%;
|
|
4335
|
+
}`);
|
|
4336
|
+
}
|
|
4337
|
+
return rules;
|
|
4338
|
+
};
|
|
4339
|
+
const getCss = layout => {
|
|
4303
4340
|
const rules = [`.MainArea {
|
|
4304
4341
|
}`, `.editor-groups-container {
|
|
4305
4342
|
overflow: auto;
|
|
4306
4343
|
}`, `.EditorGroup {
|
|
4307
4344
|
min-width: 250px;
|
|
4345
|
+
width: var(--EditorGroupWidth, auto);
|
|
4346
|
+
height: var(--EditorGroupHeight, auto);
|
|
4347
|
+
}`, `.SashVertical {
|
|
4348
|
+
left: var(--SashLeft);
|
|
4349
|
+
}`, `.SashHorizontal {
|
|
4350
|
+
top: var(--SashTop);
|
|
4308
4351
|
}`];
|
|
4352
|
+
if (layout) {
|
|
4353
|
+
rules.push(...getEditorGroupCss(layout), ...getSashCss(layout));
|
|
4354
|
+
}
|
|
4309
4355
|
const css = rules.join('\n');
|
|
4310
4356
|
return css;
|
|
4311
4357
|
};
|
|
4312
4358
|
|
|
4313
4359
|
const renderCss = (oldState, newState) => {
|
|
4314
|
-
const css = getCss();
|
|
4360
|
+
const css = getCss(newState.layout);
|
|
4315
4361
|
return [SetCss, newState.uid, css];
|
|
4316
4362
|
};
|
|
4317
4363
|
|
|
@@ -4625,6 +4671,25 @@ const HandleSashPointerDown = 16;
|
|
|
4625
4671
|
const HandleSashPointerMove = 17;
|
|
4626
4672
|
const HandleSashPointerUp = 18;
|
|
4627
4673
|
|
|
4674
|
+
const MIN_GROUP_WIDTH_PX = 250;
|
|
4675
|
+
const getSashOffset = (layout, groupIndex, width) => {
|
|
4676
|
+
const {
|
|
4677
|
+
direction,
|
|
4678
|
+
groups
|
|
4679
|
+
} = layout;
|
|
4680
|
+
const percentOffset = groups.slice(0, groupIndex).reduce((total, group) => total + group.size, 0);
|
|
4681
|
+
if (direction !== Horizontal || !width || !Number.isFinite(width)) {
|
|
4682
|
+
return `${percentOffset}%`;
|
|
4683
|
+
}
|
|
4684
|
+
const effectiveGroupSizes = groups.map(group => Math.max(group.size / 100 * width, MIN_GROUP_WIDTH_PX));
|
|
4685
|
+
const hasOverflowingGroups = effectiveGroupSizes.some((size, index) => size !== groups[index].size / 100 * width);
|
|
4686
|
+
if (!hasOverflowingGroups) {
|
|
4687
|
+
return `${percentOffset}%`;
|
|
4688
|
+
}
|
|
4689
|
+
const pixelOffset = effectiveGroupSizes.slice(0, groupIndex).reduce((total, size) => total + size, 0);
|
|
4690
|
+
return `${pixelOffset}px`;
|
|
4691
|
+
};
|
|
4692
|
+
|
|
4628
4693
|
const renderContent = content => {
|
|
4629
4694
|
return [{
|
|
4630
4695
|
childCount: 1,
|
|
@@ -4899,6 +4964,7 @@ const renderEditorGroup = (group, groupIndex, splitButtonEnabled = false, sizePr
|
|
|
4899
4964
|
return [{
|
|
4900
4965
|
childCount: 2,
|
|
4901
4966
|
className: EditorGroup,
|
|
4967
|
+
'data-groupId': String(group.id),
|
|
4902
4968
|
style,
|
|
4903
4969
|
type: Div
|
|
4904
4970
|
}, ...renderEditorGroupHeader(group, groupIndex, splitButtonEnabled), {
|
|
@@ -4928,7 +4994,7 @@ const renderSash = (direction, sashId, style) => {
|
|
|
4928
4994
|
}];
|
|
4929
4995
|
};
|
|
4930
4996
|
|
|
4931
|
-
const renderSingleEditorGroup = (layout, splitButtonEnabled, sizeProperty) => {
|
|
4997
|
+
const renderSingleEditorGroup = (layout, splitButtonEnabled, sizeProperty = 'width') => {
|
|
4932
4998
|
return [{
|
|
4933
4999
|
childCount: 1,
|
|
4934
5000
|
className: Main,
|
|
@@ -4936,24 +5002,6 @@ const renderSingleEditorGroup = (layout, splitButtonEnabled, sizeProperty) => {
|
|
|
4936
5002
|
}, ...renderEditorGroup(layout.groups[0], 0, splitButtonEnabled, sizeProperty)];
|
|
4937
5003
|
};
|
|
4938
5004
|
|
|
4939
|
-
const MIN_GROUP_WIDTH_PX = 250;
|
|
4940
|
-
const getSashOffset = (layout, groupIndex, width) => {
|
|
4941
|
-
const {
|
|
4942
|
-
direction,
|
|
4943
|
-
groups
|
|
4944
|
-
} = layout;
|
|
4945
|
-
const percentOffset = groups.slice(0, groupIndex).reduce((total, group) => total + group.size, 0);
|
|
4946
|
-
if (direction !== Horizontal || !width || !Number.isFinite(width)) {
|
|
4947
|
-
return `${percentOffset}%`;
|
|
4948
|
-
}
|
|
4949
|
-
const effectiveGroupSizes = groups.map(group => Math.max(group.size / 100 * width, MIN_GROUP_WIDTH_PX));
|
|
4950
|
-
const hasOverflowingGroups = effectiveGroupSizes.some((size, index) => size !== groups[index].size / 100 * width);
|
|
4951
|
-
if (!hasOverflowingGroups) {
|
|
4952
|
-
return `${percentOffset}%`;
|
|
4953
|
-
}
|
|
4954
|
-
const pixelOffset = effectiveGroupSizes.slice(0, groupIndex).reduce((total, size) => total + size, 0);
|
|
4955
|
-
return `${pixelOffset}px`;
|
|
4956
|
-
};
|
|
4957
5005
|
const getMainAreaVirtualDom = (layout, splitButtonEnabled = false, width = 0) => {
|
|
4958
5006
|
const {
|
|
4959
5007
|
direction,
|
|
@@ -5128,18 +5176,18 @@ const save = async state => {
|
|
|
5128
5176
|
});
|
|
5129
5177
|
};
|
|
5130
5178
|
|
|
5179
|
+
const getFilteredGroups = groups => {
|
|
5180
|
+
return groups.map(group => ({
|
|
5181
|
+
...group,
|
|
5182
|
+
tabs: group.tabs.filter(tab => !tab.uri?.startsWith('untitled://'))
|
|
5183
|
+
})).filter(group => group.tabs.length > 0);
|
|
5184
|
+
};
|
|
5185
|
+
|
|
5131
5186
|
const saveState = state => {
|
|
5132
5187
|
const {
|
|
5133
5188
|
layout
|
|
5134
5189
|
} = state;
|
|
5135
|
-
|
|
5136
|
-
// Filter out untitled editors from tabs
|
|
5137
|
-
const filteredGroups = layout.groups.map(group => ({
|
|
5138
|
-
...group,
|
|
5139
|
-
tabs: group.tabs.filter(tab => !tab.uri?.startsWith('untitled://'))
|
|
5140
|
-
}))
|
|
5141
|
-
// Remove groups that become empty after filtering
|
|
5142
|
-
.filter(group => group.tabs.length > 0);
|
|
5190
|
+
const filteredGroups = getFilteredGroups(layout.groups);
|
|
5143
5191
|
|
|
5144
5192
|
// Update activeGroupId if it points to a removed group
|
|
5145
5193
|
const {
|
|
@@ -5332,6 +5380,7 @@ const commandMap = {
|
|
|
5332
5380
|
'MainArea.initialize': initialize,
|
|
5333
5381
|
'MainArea.loadContent': wrapCommand(loadContent),
|
|
5334
5382
|
'MainArea.newFile': wrapCommand(newFile),
|
|
5383
|
+
'MainArea.newWindow': wrapCommand(newWindow),
|
|
5335
5384
|
'MainArea.openInput': wrapCommand(openInput),
|
|
5336
5385
|
'MainArea.openUri': wrapCommand(openUri),
|
|
5337
5386
|
'MainArea.openUris': wrapCommand(openUris),
|