@lvce-editor/main-area-worker 9.8.0 → 9.9.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 +304 -95
- package/package.json +1 -1
|
@@ -2479,6 +2479,14 @@ const RetryOpen = 'retry-open';
|
|
|
2479
2479
|
const SplitRight$1 = 'split-right';
|
|
2480
2480
|
const TogglePreview$1 = 'toggle-preview';
|
|
2481
2481
|
|
|
2482
|
+
const parseRawGroupId = rawGroupId => {
|
|
2483
|
+
if (!rawGroupId) {
|
|
2484
|
+
return undefined;
|
|
2485
|
+
}
|
|
2486
|
+
const groupId = Number.parseFloat(rawGroupId);
|
|
2487
|
+
return Number.isNaN(groupId) ? undefined : groupId;
|
|
2488
|
+
};
|
|
2489
|
+
|
|
2482
2490
|
const getBasename$1 = uri => {
|
|
2483
2491
|
const lastSlashIndex = uri.lastIndexOf('/');
|
|
2484
2492
|
if (lastSlashIndex === -1) {
|
|
@@ -3128,6 +3136,39 @@ const retryOpen = async state => {
|
|
|
3128
3136
|
return openUri(state, tab.uri);
|
|
3129
3137
|
};
|
|
3130
3138
|
|
|
3139
|
+
const getSegmentSize = segment => {
|
|
3140
|
+
return segment.groups.reduce((total, group) => total + group.size, 0);
|
|
3141
|
+
};
|
|
3142
|
+
const getGroupSegments = (groups, parentDirection) => {
|
|
3143
|
+
const segments = [];
|
|
3144
|
+
let index = 0;
|
|
3145
|
+
while (index < groups.length) {
|
|
3146
|
+
const group = groups[index];
|
|
3147
|
+
if (group.direction !== undefined && group.direction !== parentDirection) {
|
|
3148
|
+
const startIndex = index;
|
|
3149
|
+
const nestedGroups = [group];
|
|
3150
|
+
index++;
|
|
3151
|
+
while (index < groups.length && groups[index].direction === group.direction) {
|
|
3152
|
+
nestedGroups.push(groups[index]);
|
|
3153
|
+
index++;
|
|
3154
|
+
}
|
|
3155
|
+
segments.push({
|
|
3156
|
+
direction: group.direction,
|
|
3157
|
+
groups: nestedGroups,
|
|
3158
|
+
startIndex
|
|
3159
|
+
});
|
|
3160
|
+
continue;
|
|
3161
|
+
}
|
|
3162
|
+
segments.push({
|
|
3163
|
+
direction: undefined,
|
|
3164
|
+
groups: [group],
|
|
3165
|
+
startIndex: index
|
|
3166
|
+
});
|
|
3167
|
+
index++;
|
|
3168
|
+
}
|
|
3169
|
+
return segments;
|
|
3170
|
+
};
|
|
3171
|
+
|
|
3131
3172
|
const rebalanceGroupSizes = groups => {
|
|
3132
3173
|
const groupCount = groups.length;
|
|
3133
3174
|
if (groupCount === 0) {
|
|
@@ -3141,6 +3182,111 @@ const rebalanceGroupSizes = groups => {
|
|
|
3141
3182
|
size: index === groupCount - 1 ? lastSize : evenSize
|
|
3142
3183
|
}));
|
|
3143
3184
|
};
|
|
3185
|
+
const isTrailingSplit = direction => {
|
|
3186
|
+
return direction === Right || direction === 'down';
|
|
3187
|
+
};
|
|
3188
|
+
const getSplitLayoutDirection = direction => {
|
|
3189
|
+
return direction === Left || direction === Right ? Horizontal : Vertical;
|
|
3190
|
+
};
|
|
3191
|
+
const createNextState = (state, activeGroupId, groups) => {
|
|
3192
|
+
return {
|
|
3193
|
+
...state,
|
|
3194
|
+
layout: {
|
|
3195
|
+
activeGroupId,
|
|
3196
|
+
direction: state.layout.direction,
|
|
3197
|
+
groups
|
|
3198
|
+
}
|
|
3199
|
+
};
|
|
3200
|
+
};
|
|
3201
|
+
const splitOnlyGroup = (state, groups, groupId, newGroupId, direction, splitLayoutDirection, baseNewGroup) => {
|
|
3202
|
+
const updatedGroups = groups.map(group => {
|
|
3203
|
+
if (group.id === groupId) {
|
|
3204
|
+
return {
|
|
3205
|
+
...group,
|
|
3206
|
+
direction: undefined,
|
|
3207
|
+
focused: false,
|
|
3208
|
+
size: 50
|
|
3209
|
+
};
|
|
3210
|
+
}
|
|
3211
|
+
return group;
|
|
3212
|
+
});
|
|
3213
|
+
const newGroup = {
|
|
3214
|
+
...baseNewGroup,
|
|
3215
|
+
direction: undefined,
|
|
3216
|
+
size: 50
|
|
3217
|
+
};
|
|
3218
|
+
const reorderedGroups = isTrailingSplit(direction) ? [...updatedGroups, newGroup] : [newGroup, ...updatedGroups];
|
|
3219
|
+
return {
|
|
3220
|
+
...state,
|
|
3221
|
+
layout: {
|
|
3222
|
+
activeGroupId: newGroupId,
|
|
3223
|
+
direction: splitLayoutDirection,
|
|
3224
|
+
groups: reorderedGroups
|
|
3225
|
+
}
|
|
3226
|
+
};
|
|
3227
|
+
};
|
|
3228
|
+
const splitWithinMatchingNestedDirection = (state, groups, sourceGroup, groupId, newGroupId, direction, splitLayoutDirection, baseNewGroup) => {
|
|
3229
|
+
const sourceIndex = groups.findIndex(group => group.id === groupId);
|
|
3230
|
+
const updatedGroups = groups.map(group => {
|
|
3231
|
+
if (group.id === groupId) {
|
|
3232
|
+
return {
|
|
3233
|
+
...group,
|
|
3234
|
+
focused: false,
|
|
3235
|
+
size: Number((group.size / 2).toFixed(6))
|
|
3236
|
+
};
|
|
3237
|
+
}
|
|
3238
|
+
return group;
|
|
3239
|
+
});
|
|
3240
|
+
const newGroup = {
|
|
3241
|
+
...baseNewGroup,
|
|
3242
|
+
direction: splitLayoutDirection,
|
|
3243
|
+
size: Number((sourceGroup.size / 2).toFixed(6))
|
|
3244
|
+
};
|
|
3245
|
+
const insertIndex = isTrailingSplit(direction) ? sourceIndex + 1 : sourceIndex;
|
|
3246
|
+
const reorderedGroups = [...updatedGroups.slice(0, insertIndex), newGroup, ...updatedGroups.slice(insertIndex)];
|
|
3247
|
+
return createNextState(state, newGroupId, reorderedGroups);
|
|
3248
|
+
};
|
|
3249
|
+
const splitStandaloneSourceIntoNestedDirection = (state, groups, sourceGroup, groupId, newGroupId, direction, splitLayoutDirection, baseNewGroup) => {
|
|
3250
|
+
const sourceIndex = groups.findIndex(group => group.id === groupId);
|
|
3251
|
+
const halfSize = Number((sourceGroup.size / 2).toFixed(6));
|
|
3252
|
+
const updatedSourceGroup = {
|
|
3253
|
+
...sourceGroup,
|
|
3254
|
+
direction: splitLayoutDirection,
|
|
3255
|
+
focused: false,
|
|
3256
|
+
size: halfSize
|
|
3257
|
+
};
|
|
3258
|
+
const newGroup = {
|
|
3259
|
+
...baseNewGroup,
|
|
3260
|
+
direction: splitLayoutDirection,
|
|
3261
|
+
size: Number((sourceGroup.size - halfSize).toFixed(6))
|
|
3262
|
+
};
|
|
3263
|
+
const replacementGroups = isTrailingSplit(direction) ? [updatedSourceGroup, newGroup] : [newGroup, updatedSourceGroup];
|
|
3264
|
+
const reorderedGroups = [...groups.slice(0, sourceIndex), ...replacementGroups, ...groups.slice(sourceIndex + 1)];
|
|
3265
|
+
return createNextState(state, newGroupId, reorderedGroups);
|
|
3266
|
+
};
|
|
3267
|
+
const splitAtRootLevel = (state, groups, groupId, newGroupId, direction, baseNewGroup) => {
|
|
3268
|
+
const updatedGroups = groups.map(group => {
|
|
3269
|
+
if (group.id === groupId) {
|
|
3270
|
+
return {
|
|
3271
|
+
...group,
|
|
3272
|
+
direction: undefined,
|
|
3273
|
+
focused: false,
|
|
3274
|
+
size: 50
|
|
3275
|
+
};
|
|
3276
|
+
}
|
|
3277
|
+
return group;
|
|
3278
|
+
});
|
|
3279
|
+
const newGroup = {
|
|
3280
|
+
...baseNewGroup,
|
|
3281
|
+
direction: undefined,
|
|
3282
|
+
size: 50
|
|
3283
|
+
};
|
|
3284
|
+
const reorderedGroups = isTrailingSplit(direction) ? [...updatedGroups, newGroup] : (() => {
|
|
3285
|
+
const sourceIndex = updatedGroups.findIndex(group => group.id === groupId);
|
|
3286
|
+
return [...updatedGroups.slice(0, sourceIndex), newGroup, ...updatedGroups.slice(sourceIndex)];
|
|
3287
|
+
})();
|
|
3288
|
+
return createNextState(state, newGroupId, rebalanceGroupSizes(reorderedGroups));
|
|
3289
|
+
};
|
|
3144
3290
|
const splitEditorGroup$1 = (state, groupId, direction) => {
|
|
3145
3291
|
const {
|
|
3146
3292
|
layout
|
|
@@ -3153,42 +3299,30 @@ const splitEditorGroup$1 = (state, groupId, direction) => {
|
|
|
3153
3299
|
return state;
|
|
3154
3300
|
}
|
|
3155
3301
|
const newGroupId = create$1();
|
|
3156
|
-
const
|
|
3157
|
-
const
|
|
3158
|
-
const updatedGroups = groups.map(group => {
|
|
3159
|
-
if (group.id === groupId) {
|
|
3160
|
-
return {
|
|
3161
|
-
...group,
|
|
3162
|
-
focused: false,
|
|
3163
|
-
size: 50
|
|
3164
|
-
};
|
|
3165
|
-
}
|
|
3166
|
-
return group;
|
|
3167
|
-
});
|
|
3168
|
-
const newGroup = {
|
|
3302
|
+
const splitLayoutDirection = getSplitLayoutDirection(direction);
|
|
3303
|
+
const baseNewGroup = {
|
|
3169
3304
|
activeTabId: undefined,
|
|
3170
3305
|
focused: true,
|
|
3171
3306
|
id: newGroupId,
|
|
3172
3307
|
isEmpty: true,
|
|
3173
|
-
size:
|
|
3308
|
+
size: sourceGroup.size / 2,
|
|
3174
3309
|
tabs: []
|
|
3175
3310
|
};
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
reorderedGroups = [...updatedGroups, newGroup];
|
|
3179
|
-
} else {
|
|
3180
|
-
const sourceIndex = updatedGroups.findIndex(group => group.id === groupId);
|
|
3181
|
-
reorderedGroups = [...updatedGroups.slice(0, sourceIndex), newGroup, ...updatedGroups.slice(sourceIndex)];
|
|
3311
|
+
if (groups.length === 1) {
|
|
3312
|
+
return splitOnlyGroup(state, groups, groupId, newGroupId, direction, splitLayoutDirection, baseNewGroup);
|
|
3182
3313
|
}
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3314
|
+
if (sourceGroup.direction === splitLayoutDirection) {
|
|
3315
|
+
return splitWithinMatchingNestedDirection(state, groups, sourceGroup, groupId, newGroupId, direction, splitLayoutDirection, baseNewGroup);
|
|
3316
|
+
}
|
|
3317
|
+
if (splitLayoutDirection !== layout.direction && sourceGroup.direction === undefined) {
|
|
3318
|
+
return splitStandaloneSourceIntoNestedDirection(state, groups, sourceGroup, groupId, newGroupId, direction, splitLayoutDirection, baseNewGroup);
|
|
3319
|
+
}
|
|
3320
|
+
const segments = getGroupSegments(groups, layout.direction);
|
|
3321
|
+
const hasNestedSegments = segments.some(segment => segment.direction !== undefined);
|
|
3322
|
+
if (splitLayoutDirection === layout.direction && !hasNestedSegments) {
|
|
3323
|
+
return splitAtRootLevel(state, groups, groupId, newGroupId, direction, baseNewGroup);
|
|
3324
|
+
}
|
|
3325
|
+
return createNextState(state, newGroupId, groups);
|
|
3192
3326
|
};
|
|
3193
3327
|
|
|
3194
3328
|
const handleClickAction = async (state, action, rawGroupId) => {
|
|
@@ -3211,11 +3345,13 @@ const handleClickAction = async (state, action, rawGroupId) => {
|
|
|
3211
3345
|
}
|
|
3212
3346
|
switch (action) {
|
|
3213
3347
|
case CloseGroup:
|
|
3214
|
-
|
|
3215
|
-
const groupId =
|
|
3348
|
+
{
|
|
3349
|
+
const groupId = parseRawGroupId(rawGroupId);
|
|
3350
|
+
if (groupId === undefined) {
|
|
3351
|
+
return state;
|
|
3352
|
+
}
|
|
3216
3353
|
return closeEditorGroup$1(state, groupId);
|
|
3217
3354
|
}
|
|
3218
|
-
return state;
|
|
3219
3355
|
case RetryOpen:
|
|
3220
3356
|
return retryOpen(state);
|
|
3221
3357
|
case SplitRight$1:
|
|
@@ -4394,26 +4530,70 @@ const getEditorGroupCss = layout => {
|
|
|
4394
4530
|
});
|
|
4395
4531
|
};
|
|
4396
4532
|
|
|
4397
|
-
const
|
|
4533
|
+
const MIN_GROUP_WIDTH_PX = 250;
|
|
4534
|
+
const getSashOffset = (layout, groupIndex, width) => {
|
|
4535
|
+
const {
|
|
4536
|
+
direction,
|
|
4537
|
+
groups
|
|
4538
|
+
} = layout;
|
|
4539
|
+
const percentOffset = groups.slice(0, groupIndex).reduce((total, group) => total + group.size, 0);
|
|
4540
|
+
if (direction !== Horizontal || !width || !Number.isFinite(width)) {
|
|
4541
|
+
return `${percentOffset}%`;
|
|
4542
|
+
}
|
|
4543
|
+
const effectiveGroupSizes = groups.map(group => Math.max(group.size / 100 * width, MIN_GROUP_WIDTH_PX));
|
|
4544
|
+
const hasOverflowingGroups = effectiveGroupSizes.some((size, index) => size !== groups[index].size / 100 * width);
|
|
4545
|
+
if (!hasOverflowingGroups) {
|
|
4546
|
+
return `${percentOffset}%`;
|
|
4547
|
+
}
|
|
4548
|
+
const pixelOffset = effectiveGroupSizes.slice(0, groupIndex).reduce((total, size) => total + size, 0);
|
|
4549
|
+
return `${pixelOffset}px`;
|
|
4550
|
+
};
|
|
4551
|
+
|
|
4552
|
+
const escapeCssAttributeValue = value => {
|
|
4553
|
+
return value.replaceAll('\\', '\\\\').replaceAll('"', '\\"');
|
|
4554
|
+
};
|
|
4555
|
+
const getSashCss = (layout, width = 0) => {
|
|
4398
4556
|
if (layout.groups.length <= 1) {
|
|
4399
4557
|
return [];
|
|
4400
4558
|
}
|
|
4401
|
-
const sashPositionVariable = layout.direction === Horizontal ? '--SashLeft' : '--SashTop';
|
|
4402
4559
|
const rules = [];
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4560
|
+
const segments = getGroupSegments(layout.groups, layout.direction);
|
|
4561
|
+
const sashPositionProperty = layout.direction === Horizontal ? 'left' : 'top';
|
|
4562
|
+
let segmentOffset = 0;
|
|
4563
|
+
for (let i = 1; i < segments.length; i++) {
|
|
4564
|
+
segmentOffset += getSegmentSize(segments[i - 1]);
|
|
4565
|
+
const beforeGroupId = segments[i - 1].groups.at(-1)?.id || 0;
|
|
4566
|
+
const afterGroupId = segments[i].groups[0].id;
|
|
4408
4567
|
const sashId = create(beforeGroupId, afterGroupId);
|
|
4409
|
-
|
|
4410
|
-
|
|
4568
|
+
const escapedSashId = escapeCssAttributeValue(sashId);
|
|
4569
|
+
const sashOffset = segments.some(segment => segment.direction !== undefined) || layout.direction !== Horizontal || !width ? `${segmentOffset}%` : getSashOffset(layout, i, width);
|
|
4570
|
+
rules.push(`[data-sashId="${escapedSashId}"] {
|
|
4571
|
+
${sashPositionProperty}: ${sashOffset};
|
|
4572
|
+
}`);
|
|
4573
|
+
}
|
|
4574
|
+
for (const segment of segments) {
|
|
4575
|
+
if (segment.direction === undefined || segment.groups.length <= 1) {
|
|
4576
|
+
continue;
|
|
4577
|
+
}
|
|
4578
|
+
const nestedProperty = segment.direction === Horizontal ? 'left' : 'top';
|
|
4579
|
+
const segmentSize = getSegmentSize(segment);
|
|
4580
|
+
let nestedOffset = 0;
|
|
4581
|
+
for (let i = 1; i < segment.groups.length; i++) {
|
|
4582
|
+
nestedOffset += segment.groups[i - 1].size;
|
|
4583
|
+
const beforeGroupId = segment.groups[i - 1].id;
|
|
4584
|
+
const afterGroupId = segment.groups[i].id;
|
|
4585
|
+
const sashId = create(beforeGroupId, afterGroupId);
|
|
4586
|
+
const escapedSashId = escapeCssAttributeValue(sashId);
|
|
4587
|
+
const relativeOffset = Number((nestedOffset / segmentSize * 100).toFixed(6));
|
|
4588
|
+
rules.push(`[data-sashId="${escapedSashId}"] {
|
|
4589
|
+
${nestedProperty}: ${relativeOffset}%;
|
|
4411
4590
|
}`);
|
|
4591
|
+
}
|
|
4412
4592
|
}
|
|
4413
4593
|
return rules;
|
|
4414
4594
|
};
|
|
4415
4595
|
|
|
4416
|
-
const getCss = layout => {
|
|
4596
|
+
const getCss = (layout, width = 0) => {
|
|
4417
4597
|
const rules = [`.MainArea {
|
|
4418
4598
|
}`, `.editor-groups-container {
|
|
4419
4599
|
overflow: auto;
|
|
@@ -4421,20 +4601,16 @@ const getCss = layout => {
|
|
|
4421
4601
|
min-width: 250px;
|
|
4422
4602
|
width: var(--EditorGroupWidth, auto);
|
|
4423
4603
|
/*height: var(--EditorGroupHeight, auto);*/
|
|
4424
|
-
}`, `.MainArea .SashVertical {
|
|
4425
|
-
left: var(--SashLeft);
|
|
4426
|
-
}`, `.MainArea .SashHorizontal {
|
|
4427
|
-
top: var(--SashTop);
|
|
4428
4604
|
}`];
|
|
4429
4605
|
if (layout) {
|
|
4430
|
-
rules.push(...getEditorGroupCss(layout), ...getSashCss(layout));
|
|
4606
|
+
rules.push(...getEditorGroupCss(layout), ...getSashCss(layout, width));
|
|
4431
4607
|
}
|
|
4432
4608
|
const css = rules.join('\n');
|
|
4433
4609
|
return css;
|
|
4434
4610
|
};
|
|
4435
4611
|
|
|
4436
4612
|
const renderCss = (oldState, newState) => {
|
|
4437
|
-
const css = getCss(newState.layout);
|
|
4613
|
+
const css = getCss(newState.layout, newState.width);
|
|
4438
4614
|
return [SetCss, newState.uid, css];
|
|
4439
4615
|
};
|
|
4440
4616
|
|
|
@@ -4748,25 +4924,6 @@ const HandleSashPointerDown = 16;
|
|
|
4748
4924
|
const HandleSashPointerMove = 17;
|
|
4749
4925
|
const HandleSashPointerUp = 18;
|
|
4750
4926
|
|
|
4751
|
-
const MIN_GROUP_WIDTH_PX = 250;
|
|
4752
|
-
const getSashOffset = (layout, groupIndex, width) => {
|
|
4753
|
-
const {
|
|
4754
|
-
direction,
|
|
4755
|
-
groups
|
|
4756
|
-
} = layout;
|
|
4757
|
-
const percentOffset = groups.slice(0, groupIndex).reduce((total, group) => total + group.size, 0);
|
|
4758
|
-
if (direction !== Horizontal || !width || !Number.isFinite(width)) {
|
|
4759
|
-
return `${percentOffset}%`;
|
|
4760
|
-
}
|
|
4761
|
-
const effectiveGroupSizes = groups.map(group => Math.max(group.size / 100 * width, MIN_GROUP_WIDTH_PX));
|
|
4762
|
-
const hasOverflowingGroups = effectiveGroupSizes.some((size, index) => size !== groups[index].size / 100 * width);
|
|
4763
|
-
if (!hasOverflowingGroups) {
|
|
4764
|
-
return `${percentOffset}%`;
|
|
4765
|
-
}
|
|
4766
|
-
const pixelOffset = effectiveGroupSizes.slice(0, groupIndex).reduce((total, size) => total + size, 0);
|
|
4767
|
-
return `${pixelOffset}px`;
|
|
4768
|
-
};
|
|
4769
|
-
|
|
4770
4927
|
const renderContent = content => {
|
|
4771
4928
|
return [{
|
|
4772
4929
|
childCount: 1,
|
|
@@ -5002,7 +5159,11 @@ const renderEmptyGroupCloseButton = (group, groupIndex) => {
|
|
|
5002
5159
|
onClick: HandleClickAction,
|
|
5003
5160
|
title: closeEditorGroup(),
|
|
5004
5161
|
type: Button$2
|
|
5005
|
-
},
|
|
5162
|
+
}, {
|
|
5163
|
+
childCount: 0,
|
|
5164
|
+
className: MaskIconClose,
|
|
5165
|
+
type: Div
|
|
5166
|
+
}];
|
|
5006
5167
|
};
|
|
5007
5168
|
|
|
5008
5169
|
const renderWaterMark = groupId => {
|
|
@@ -5056,14 +5217,13 @@ const getSashClassName = direction => {
|
|
|
5056
5217
|
return direction === Horizontal ? 'Sash SashVertical' : 'Sash SashHorizontal';
|
|
5057
5218
|
};
|
|
5058
5219
|
|
|
5059
|
-
const renderSash = (direction, sashId
|
|
5220
|
+
const renderSash = (direction, sashId) => {
|
|
5060
5221
|
return [{
|
|
5061
5222
|
childCount: 1,
|
|
5062
5223
|
className: getSashClassName(direction),
|
|
5063
5224
|
'data-sashId': sashId,
|
|
5064
5225
|
onPointerDown: HandleSashPointerDown,
|
|
5065
5226
|
role: 'none',
|
|
5066
|
-
style,
|
|
5067
5227
|
type: Button$2
|
|
5068
5228
|
}, {
|
|
5069
5229
|
childCount: 0,
|
|
@@ -5086,19 +5246,81 @@ const getDirectionClassName = (direction, isSplit) => {
|
|
|
5086
5246
|
}
|
|
5087
5247
|
return direction === Horizontal ? EditorGroupsVertical : EditorGroupsHorizontal;
|
|
5088
5248
|
};
|
|
5089
|
-
const
|
|
5249
|
+
const getContainerClassName = (direction, childCount) => {
|
|
5250
|
+
const directionClassName = getDirectionClassName(direction, childCount > 1);
|
|
5251
|
+
return directionClassName ? `${EDITOR_GROUPS_CONTAINER} ${directionClassName}` : EDITOR_GROUPS_CONTAINER;
|
|
5252
|
+
};
|
|
5253
|
+
const getSizeProperty = direction => {
|
|
5254
|
+
return direction === Vertical ? 'height' : 'width';
|
|
5255
|
+
};
|
|
5256
|
+
const renderSegmentChildren = (direction, groups, splitButtonEnabled) => {
|
|
5257
|
+
const segments = getGroupSegments(groups, direction);
|
|
5258
|
+
const children = [];
|
|
5259
|
+
let childCount = 0;
|
|
5260
|
+
const sizeProperty = getSizeProperty(direction);
|
|
5261
|
+
for (let i = 0; i < segments.length; i++) {
|
|
5262
|
+
const segment = segments[i];
|
|
5263
|
+
if (i > 0) {
|
|
5264
|
+
const previousSegment = segments[i - 1];
|
|
5265
|
+
const beforeGroupId = previousSegment.groups.at(-1)?.id || 0;
|
|
5266
|
+
const afterGroupId = segment.groups[0].id;
|
|
5267
|
+
const sashId = create(beforeGroupId, afterGroupId);
|
|
5268
|
+
children.push(...renderSash(direction, sashId));
|
|
5269
|
+
childCount++;
|
|
5270
|
+
}
|
|
5271
|
+
if (segment.direction === undefined) {
|
|
5272
|
+
children.push(...renderEditorGroup(segment.groups[0], segment.startIndex, splitButtonEnabled, sizeProperty));
|
|
5273
|
+
childCount++;
|
|
5274
|
+
continue;
|
|
5275
|
+
}
|
|
5276
|
+
const nestedDirection = segment.direction;
|
|
5277
|
+
const nestedSizeProperty = getSizeProperty(nestedDirection);
|
|
5278
|
+
const nestedChildCount = segment.groups.length + segment.groups.length - 1;
|
|
5279
|
+
const nestedChildren = [];
|
|
5280
|
+
let nestedCount = 0;
|
|
5281
|
+
const segmentSize = getSegmentSize(segment);
|
|
5282
|
+
for (let j = 0; j < segment.groups.length; j++) {
|
|
5283
|
+
if (j > 0) {
|
|
5284
|
+
const beforeGroupId = segment.groups[j - 1].id;
|
|
5285
|
+
const afterGroupId = segment.groups[j].id;
|
|
5286
|
+
const sashId = create(beforeGroupId, afterGroupId);
|
|
5287
|
+
nestedChildren.push(...renderSash(nestedDirection, sashId));
|
|
5288
|
+
nestedCount++;
|
|
5289
|
+
}
|
|
5290
|
+
const group = segment.groups[j];
|
|
5291
|
+
const normalizedSize = Number((group.size / segmentSize * 100).toFixed(6));
|
|
5292
|
+
nestedChildren.push(...renderEditorGroup({
|
|
5293
|
+
...group,
|
|
5294
|
+
size: normalizedSize
|
|
5295
|
+
}, segment.startIndex + j, splitButtonEnabled, nestedSizeProperty));
|
|
5296
|
+
nestedCount++;
|
|
5297
|
+
}
|
|
5298
|
+
children.push({
|
|
5299
|
+
childCount: nestedChildCount,
|
|
5300
|
+
className: getContainerClassName(nestedDirection, segment.groups.length),
|
|
5301
|
+
role: None$1,
|
|
5302
|
+
style: `${sizeProperty}:${segmentSize}%;`,
|
|
5303
|
+
type: Div
|
|
5304
|
+
});
|
|
5305
|
+
children.push(...nestedChildren);
|
|
5306
|
+
childCount++;
|
|
5307
|
+
childCount += nestedCount;
|
|
5308
|
+
}
|
|
5309
|
+
return {
|
|
5310
|
+
childCount,
|
|
5311
|
+
children
|
|
5312
|
+
};
|
|
5313
|
+
};
|
|
5314
|
+
const getMainAreaVirtualDom = (layout, splitButtonEnabled = false) => {
|
|
5090
5315
|
const {
|
|
5091
5316
|
direction,
|
|
5092
5317
|
groups
|
|
5093
5318
|
} = layout;
|
|
5094
|
-
const sizeProperty = direction
|
|
5319
|
+
const sizeProperty = getSizeProperty(direction);
|
|
5095
5320
|
if (groups.length === 1) {
|
|
5096
5321
|
return renderSingleEditorGroup(layout, splitButtonEnabled, sizeProperty);
|
|
5097
5322
|
}
|
|
5098
|
-
const
|
|
5099
|
-
const isSplit = groups.length > 1;
|
|
5100
|
-
const directionClassName = getDirectionClassName(direction, isSplit);
|
|
5101
|
-
const editorGroupsContainerClassName = directionClassName ? `${EDITOR_GROUPS_CONTAINER} ${directionClassName}` : EDITOR_GROUPS_CONTAINER;
|
|
5323
|
+
const editorGroupsContainerClassName = getContainerClassName(direction, groups.length);
|
|
5102
5324
|
if (groups.length === 0) {
|
|
5103
5325
|
return [{
|
|
5104
5326
|
childCount: 1,
|
|
@@ -5113,22 +5335,10 @@ const getMainAreaVirtualDom = (layout, splitButtonEnabled = false, width = 0) =>
|
|
|
5113
5335
|
type: Div
|
|
5114
5336
|
}];
|
|
5115
5337
|
}
|
|
5116
|
-
|
|
5117
|
-
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
const beforeGroupId = groups[i - 1].id;
|
|
5121
|
-
const afterGroupId = groups[i].id;
|
|
5122
|
-
const sashId = create(beforeGroupId, afterGroupId);
|
|
5123
|
-
const offset = getSashOffset(layout, i, width);
|
|
5124
|
-
const style = direction === Horizontal ? `left:${offset};` : `top:${offset};`;
|
|
5125
|
-
children.push(...renderSash(direction, sashId, style));
|
|
5126
|
-
childCount++;
|
|
5127
|
-
}
|
|
5128
|
-
const editorGroupDom = renderEditorGroup(groups[i], i, splitButtonEnabled, sizeProperty);
|
|
5129
|
-
children.push(...editorGroupDom);
|
|
5130
|
-
childCount++;
|
|
5131
|
-
}
|
|
5338
|
+
const {
|
|
5339
|
+
childCount,
|
|
5340
|
+
children
|
|
5341
|
+
} = renderSegmentChildren(direction, groups, splitButtonEnabled);
|
|
5132
5342
|
return [{
|
|
5133
5343
|
childCount: 1,
|
|
5134
5344
|
className: Main,
|
|
@@ -5146,13 +5356,12 @@ const renderItems = (oldState, newState) => {
|
|
|
5146
5356
|
initial,
|
|
5147
5357
|
layout,
|
|
5148
5358
|
splitButtonEnabled,
|
|
5149
|
-
uid
|
|
5150
|
-
width
|
|
5359
|
+
uid
|
|
5151
5360
|
} = newState;
|
|
5152
5361
|
if (initial) {
|
|
5153
5362
|
return [SetDom2, uid, []];
|
|
5154
5363
|
}
|
|
5155
|
-
const dom = getMainAreaVirtualDom(layout, splitButtonEnabled
|
|
5364
|
+
const dom = getMainAreaVirtualDom(layout, splitButtonEnabled);
|
|
5156
5365
|
return [SetDom2, uid, dom];
|
|
5157
5366
|
};
|
|
5158
5367
|
|