@lvce-editor/main-area-worker 8.10.0 → 8.12.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 +27 -14
- package/package.json +1 -1
|
@@ -2848,6 +2848,19 @@ const retryOpen = async state => {
|
|
|
2848
2848
|
return openUri(state, tab.uri);
|
|
2849
2849
|
};
|
|
2850
2850
|
|
|
2851
|
+
const rebalanceGroupSizes = groups => {
|
|
2852
|
+
const groupCount = groups.length;
|
|
2853
|
+
if (groupCount === 0) {
|
|
2854
|
+
return [];
|
|
2855
|
+
}
|
|
2856
|
+
const evenSize = Number((100 / groupCount).toFixed(6));
|
|
2857
|
+
const assignedSize = Number((evenSize * (groupCount - 1)).toFixed(6));
|
|
2858
|
+
const lastSize = Number((100 - assignedSize).toFixed(6));
|
|
2859
|
+
return groups.map((group, index) => ({
|
|
2860
|
+
...group,
|
|
2861
|
+
size: index === groupCount - 1 ? lastSize : evenSize
|
|
2862
|
+
}));
|
|
2863
|
+
};
|
|
2851
2864
|
const splitEditorGroup$1 = (state, groupId, direction) => {
|
|
2852
2865
|
const {
|
|
2853
2866
|
layout
|
|
@@ -2887,12 +2900,13 @@ const splitEditorGroup$1 = (state, groupId, direction) => {
|
|
|
2887
2900
|
const sourceIndex = updatedGroups.findIndex(group => group.id === groupId);
|
|
2888
2901
|
reorderedGroups = [...updatedGroups.slice(0, sourceIndex), newGroup, ...updatedGroups.slice(sourceIndex)];
|
|
2889
2902
|
}
|
|
2903
|
+
const resizedGroups = rebalanceGroupSizes(reorderedGroups);
|
|
2890
2904
|
return {
|
|
2891
2905
|
...state,
|
|
2892
2906
|
layout: {
|
|
2893
2907
|
activeGroupId: newGroupId,
|
|
2894
2908
|
direction: newLayoutDirection,
|
|
2895
|
-
groups:
|
|
2909
|
+
groups: resizedGroups
|
|
2896
2910
|
}
|
|
2897
2911
|
};
|
|
2898
2912
|
};
|
|
@@ -3191,8 +3205,8 @@ const parse = sashId => {
|
|
|
3191
3205
|
if (!beforeRaw || !afterRaw) {
|
|
3192
3206
|
return undefined;
|
|
3193
3207
|
}
|
|
3194
|
-
const beforeGroupId = Number.
|
|
3195
|
-
const afterGroupId = Number.
|
|
3208
|
+
const beforeGroupId = Number.parseFloat(beforeRaw);
|
|
3209
|
+
const afterGroupId = Number.parseFloat(afterRaw);
|
|
3196
3210
|
if (!Number.isFinite(beforeGroupId) || !Number.isFinite(afterGroupId)) {
|
|
3197
3211
|
return undefined;
|
|
3198
3212
|
}
|
|
@@ -4371,8 +4385,6 @@ const renderSash = (direction, sashId, style) => {
|
|
|
4371
4385
|
className: direction === 'horizontal' ? 'Sash SashVertical' : 'Sash SashHorizontal',
|
|
4372
4386
|
'data-sashId': sashId,
|
|
4373
4387
|
onPointerDown: HandleSashPointerDown,
|
|
4374
|
-
onPointerMove: HandleSashPointerMove,
|
|
4375
|
-
onPointerUp: HandleSashPointerUp,
|
|
4376
4388
|
style,
|
|
4377
4389
|
type: Div
|
|
4378
4390
|
}];
|
|
@@ -4387,18 +4399,19 @@ const renderSingleEditorGroup = (layout, splitButtonEnabled, sizeProperty) => {
|
|
|
4387
4399
|
};
|
|
4388
4400
|
|
|
4389
4401
|
const getMainAreaVirtualDom = (layout, splitButtonEnabled = false) => {
|
|
4390
|
-
const
|
|
4391
|
-
|
|
4402
|
+
const {
|
|
4403
|
+
direction,
|
|
4404
|
+
groups
|
|
4405
|
+
} = layout;
|
|
4406
|
+
const sizeProperty = direction === 'vertical' ? 'height' : 'width';
|
|
4407
|
+
if (groups.length === 1) {
|
|
4392
4408
|
return renderSingleEditorGroup(layout, splitButtonEnabled, sizeProperty);
|
|
4393
4409
|
}
|
|
4394
4410
|
const children = [];
|
|
4395
|
-
const isSplit =
|
|
4396
|
-
const directionClassName = isSplit ?
|
|
4411
|
+
const isSplit = groups.length > 1;
|
|
4412
|
+
const directionClassName = isSplit ? direction === 'horizontal' ? EditorGroupsVertical : EditorGroupsHorizontal : '';
|
|
4397
4413
|
const editorGroupsContainerClassName = directionClassName ? `${EDITOR_GROUPS_CONTAINER} ${directionClassName}` : EDITOR_GROUPS_CONTAINER;
|
|
4398
4414
|
let sashOffset = 0;
|
|
4399
|
-
const {
|
|
4400
|
-
groups
|
|
4401
|
-
} = layout;
|
|
4402
4415
|
for (let i = 0; i < groups.length; i++) {
|
|
4403
4416
|
sashOffset += groups[i].size;
|
|
4404
4417
|
if (i > 0) {
|
|
@@ -4406,8 +4419,8 @@ const getMainAreaVirtualDom = (layout, splitButtonEnabled = false) => {
|
|
|
4406
4419
|
const beforeGroupId = groups[i - 1].id;
|
|
4407
4420
|
const afterGroupId = groups[i].id;
|
|
4408
4421
|
const sashId = create(beforeGroupId, afterGroupId);
|
|
4409
|
-
const style =
|
|
4410
|
-
children.push(...renderSash(
|
|
4422
|
+
const style = direction === 'horizontal' ? `left:${sashOffset - groups[i].size}%;` : `top:${sashOffset - groups[i].size}%;`;
|
|
4423
|
+
children.push(...renderSash(direction, sashId, style));
|
|
4411
4424
|
}
|
|
4412
4425
|
children.push(...renderEditorGroup(groups[i], i, splitButtonEnabled, sizeProperty));
|
|
4413
4426
|
}
|