@lvce-editor/main-area-worker 8.12.0 → 8.13.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 +76 -38
- package/package.json +1 -1
|
@@ -273,9 +273,12 @@ const getGroupById = (state, groupId) => {
|
|
|
273
273
|
};
|
|
274
274
|
|
|
275
275
|
const closeTabsRight = (state, groupId) => {
|
|
276
|
+
const {
|
|
277
|
+
layout
|
|
278
|
+
} = state;
|
|
276
279
|
const {
|
|
277
280
|
groups
|
|
278
|
-
} =
|
|
281
|
+
} = layout;
|
|
279
282
|
const group = getGroupById(state, groupId);
|
|
280
283
|
if (!group) {
|
|
281
284
|
return state;
|
|
@@ -1707,7 +1710,7 @@ const create$2 = (uid, uri, x, y, width, height, platform, assetDir, tabHeight =
|
|
|
1707
1710
|
};
|
|
1708
1711
|
|
|
1709
1712
|
const isEqual$1 = (oldState, newState) => {
|
|
1710
|
-
return
|
|
1713
|
+
return false;
|
|
1711
1714
|
};
|
|
1712
1715
|
|
|
1713
1716
|
const isEqual = (oldState, newState) => {
|
|
@@ -2287,10 +2290,13 @@ const closeEditorGroup$1 = (state, groupId) => {
|
|
|
2287
2290
|
if (Number.isNaN(groupId)) {
|
|
2288
2291
|
return state;
|
|
2289
2292
|
}
|
|
2293
|
+
const {
|
|
2294
|
+
layout
|
|
2295
|
+
} = state;
|
|
2290
2296
|
const {
|
|
2291
2297
|
activeGroupId,
|
|
2292
2298
|
groups
|
|
2293
|
-
} =
|
|
2299
|
+
} = layout;
|
|
2294
2300
|
const groupIndex = getGroupIndexById(state, groupId);
|
|
2295
2301
|
if (groupIndex === -1 || groups.length <= 1) {
|
|
2296
2302
|
return state;
|
|
@@ -2912,13 +2918,20 @@ const splitEditorGroup$1 = (state, groupId, direction) => {
|
|
|
2912
2918
|
};
|
|
2913
2919
|
|
|
2914
2920
|
const handleClickAction = async (state, action, rawGroupId) => {
|
|
2921
|
+
const {
|
|
2922
|
+
layout
|
|
2923
|
+
} = state;
|
|
2924
|
+
const {
|
|
2925
|
+
activeGroupId,
|
|
2926
|
+
groups
|
|
2927
|
+
} = layout;
|
|
2915
2928
|
if (!action) {
|
|
2916
2929
|
return state;
|
|
2917
2930
|
}
|
|
2918
|
-
if (
|
|
2931
|
+
if (activeGroupId === undefined) {
|
|
2919
2932
|
return state;
|
|
2920
2933
|
}
|
|
2921
|
-
const activeGroup = getActiveGroup(
|
|
2934
|
+
const activeGroup = getActiveGroup(groups, activeGroupId);
|
|
2922
2935
|
if (!activeGroup) {
|
|
2923
2936
|
return state;
|
|
2924
2937
|
}
|
|
@@ -3249,16 +3262,27 @@ const handleSashPointerDown = async (state, sashId, clientX, clientY) => {
|
|
|
3249
3262
|
};
|
|
3250
3263
|
};
|
|
3251
3264
|
|
|
3252
|
-
const
|
|
3265
|
+
const MIN_GROUP_WIDTH_PX = 250;
|
|
3253
3266
|
const clamp = (value, min, max) => {
|
|
3254
3267
|
return Math.min(max, Math.max(min, value));
|
|
3255
3268
|
};
|
|
3256
3269
|
const round = value => {
|
|
3257
3270
|
return Math.round(value * 100) / 100;
|
|
3258
3271
|
};
|
|
3272
|
+
const getMinGroupSizePercent = axisSize => {
|
|
3273
|
+
if (!axisSize) {
|
|
3274
|
+
return 10;
|
|
3275
|
+
}
|
|
3276
|
+
const minPercent = MIN_GROUP_WIDTH_PX / axisSize * 100;
|
|
3277
|
+
// Ensure minimum is at least 10%, matching the CSS 250px constraint on typical widths
|
|
3278
|
+
return Math.max(minPercent, 10);
|
|
3279
|
+
};
|
|
3259
3280
|
const handleSashPointerMove = async (state, clientX, clientY) => {
|
|
3260
3281
|
const {
|
|
3261
|
-
|
|
3282
|
+
height,
|
|
3283
|
+
layout,
|
|
3284
|
+
sashDrag,
|
|
3285
|
+
width
|
|
3262
3286
|
} = state;
|
|
3263
3287
|
if (!sashDrag) {
|
|
3264
3288
|
return state;
|
|
@@ -3266,16 +3290,26 @@ const handleSashPointerMove = async (state, clientX, clientY) => {
|
|
|
3266
3290
|
if (!Number.isFinite(clientX) || !Number.isFinite(clientY)) {
|
|
3267
3291
|
return state;
|
|
3268
3292
|
}
|
|
3269
|
-
const
|
|
3293
|
+
const {
|
|
3294
|
+
direction,
|
|
3295
|
+
groups
|
|
3296
|
+
} = layout;
|
|
3297
|
+
const axisSize = direction === 'horizontal' ? width : height;
|
|
3270
3298
|
if (!axisSize) {
|
|
3271
3299
|
return state;
|
|
3272
3300
|
}
|
|
3273
|
-
const deltaPx =
|
|
3301
|
+
const deltaPx = direction === 'horizontal' ? clientX - sashDrag.startClientX : clientY - sashDrag.startClientY;
|
|
3274
3302
|
const deltaPercent = deltaPx / axisSize * 100;
|
|
3275
3303
|
const totalResizableSize = sashDrag.beforeSize + sashDrag.afterSize;
|
|
3276
|
-
|
|
3304
|
+
let minGroupSize = getMinGroupSizePercent(axisSize);
|
|
3305
|
+
|
|
3306
|
+
// If the minimum size makes it impossible to fit two groups, relax the constraint
|
|
3307
|
+
if (2 * minGroupSize > totalResizableSize) {
|
|
3308
|
+
minGroupSize = totalResizableSize / 2;
|
|
3309
|
+
}
|
|
3310
|
+
const beforeSize = clamp(sashDrag.beforeSize + deltaPercent, minGroupSize, totalResizableSize - minGroupSize);
|
|
3277
3311
|
const afterSize = totalResizableSize - beforeSize;
|
|
3278
|
-
const
|
|
3312
|
+
const newGroups = groups.map(group => {
|
|
3279
3313
|
if (group.id === sashDrag.beforeGroupId) {
|
|
3280
3314
|
return {
|
|
3281
3315
|
...group,
|
|
@@ -3293,8 +3327,8 @@ const handleSashPointerMove = async (state, clientX, clientY) => {
|
|
|
3293
3327
|
return {
|
|
3294
3328
|
...state,
|
|
3295
3329
|
layout: {
|
|
3296
|
-
...
|
|
3297
|
-
groups
|
|
3330
|
+
...layout,
|
|
3331
|
+
groups: newGroups
|
|
3298
3332
|
}
|
|
3299
3333
|
};
|
|
3300
3334
|
};
|
|
@@ -3514,7 +3548,10 @@ const createViewlets = async (layout, viewletModuleIds, bounds) => {
|
|
|
3514
3548
|
const getViewletModuleIds = async layout => {
|
|
3515
3549
|
const viewletModuleIds = {};
|
|
3516
3550
|
for (const group of layout.groups) {
|
|
3517
|
-
const
|
|
3551
|
+
const {
|
|
3552
|
+
tabs
|
|
3553
|
+
} = group;
|
|
3554
|
+
const activeTab = tabs.find(tab => tab.id === group.activeTabId);
|
|
3518
3555
|
if (activeTab && activeTab.uri) {
|
|
3519
3556
|
const viewletModuleId = await getViewletModuleId(activeTab.uri);
|
|
3520
3557
|
if (viewletModuleId) {
|
|
@@ -3789,26 +3826,9 @@ const refresh = state => {
|
|
|
3789
3826
|
const getCss = () => {
|
|
3790
3827
|
const rules = [`.MainArea {
|
|
3791
3828
|
}`, `.editor-groups-container {
|
|
3792
|
-
|
|
3793
|
-
}`, `.
|
|
3794
|
-
|
|
3795
|
-
z-index: 1;
|
|
3796
|
-
}`, `.SashVertical {
|
|
3797
|
-
top: 0;
|
|
3798
|
-
bottom: 0;
|
|
3799
|
-
width: 0;
|
|
3800
|
-
cursor: col-resize;
|
|
3801
|
-
}`, `.SashVertical:hover {
|
|
3802
|
-
width: 4px;
|
|
3803
|
-
margin-left: -2px;
|
|
3804
|
-
}`, `.SashHorizontal {
|
|
3805
|
-
left: 0;
|
|
3806
|
-
right: 0;
|
|
3807
|
-
height: 0;
|
|
3808
|
-
cursor: row-resize;
|
|
3809
|
-
}`, `.SashHorizontal:hover {
|
|
3810
|
-
height: 4px;
|
|
3811
|
-
margin-top: -2px;
|
|
3829
|
+
overflow: auto;
|
|
3830
|
+
}`, `.EditorGroup {
|
|
3831
|
+
min-width: 250px;
|
|
3812
3832
|
}`];
|
|
3813
3833
|
const css = rules.join('\n');
|
|
3814
3834
|
return css;
|
|
@@ -4350,13 +4370,25 @@ const renderEmptyGroupCloseButton = (group, groupIndex) => {
|
|
|
4350
4370
|
}, text('✕')];
|
|
4351
4371
|
};
|
|
4352
4372
|
|
|
4353
|
-
const
|
|
4373
|
+
const renderWaterMark = () => {
|
|
4354
4374
|
return [{
|
|
4355
4375
|
childCount: 1,
|
|
4376
|
+
className: 'WaterMarkWrapper',
|
|
4377
|
+
type: Div
|
|
4378
|
+
}, {
|
|
4379
|
+
childCount: 0,
|
|
4380
|
+
className: 'WaterMark',
|
|
4381
|
+
type: Div
|
|
4382
|
+
}];
|
|
4383
|
+
};
|
|
4384
|
+
|
|
4385
|
+
const renderEmptyEditorGroup = (group, groupIndex, style) => {
|
|
4386
|
+
return [{
|
|
4387
|
+
childCount: 2,
|
|
4356
4388
|
className: EditorGroup,
|
|
4357
4389
|
style,
|
|
4358
4390
|
type: Div
|
|
4359
|
-
}, ...renderEmptyGroupCloseButton(group)];
|
|
4391
|
+
}, ...renderEmptyGroupCloseButton(group), ...renderWaterMark()];
|
|
4360
4392
|
};
|
|
4361
4393
|
|
|
4362
4394
|
const renderEditorGroup = (group, groupIndex, splitButtonEnabled = false, sizeProperty = 'width') => {
|
|
@@ -4379,10 +4411,13 @@ const renderEditorGroup = (group, groupIndex, splitButtonEnabled = false, sizePr
|
|
|
4379
4411
|
}, ...renderEditor(activeTab)];
|
|
4380
4412
|
};
|
|
4381
4413
|
|
|
4414
|
+
const getSashClassName = direction => {
|
|
4415
|
+
return direction === 'horizontal' ? 'Sash SashVertical' : 'Sash SashHorizontal';
|
|
4416
|
+
};
|
|
4382
4417
|
const renderSash = (direction, sashId, style) => {
|
|
4383
4418
|
return [{
|
|
4384
4419
|
childCount: 0,
|
|
4385
|
-
className: direction
|
|
4420
|
+
className: getSashClassName(direction),
|
|
4386
4421
|
'data-sashId': sashId,
|
|
4387
4422
|
onPointerDown: HandleSashPointerDown,
|
|
4388
4423
|
style,
|
|
@@ -4412,6 +4447,7 @@ const getMainAreaVirtualDom = (layout, splitButtonEnabled = false) => {
|
|
|
4412
4447
|
const directionClassName = isSplit ? direction === 'horizontal' ? EditorGroupsVertical : EditorGroupsHorizontal : '';
|
|
4413
4448
|
const editorGroupsContainerClassName = directionClassName ? `${EDITOR_GROUPS_CONTAINER} ${directionClassName}` : EDITOR_GROUPS_CONTAINER;
|
|
4414
4449
|
let sashOffset = 0;
|
|
4450
|
+
let childCount = 0;
|
|
4415
4451
|
for (let i = 0; i < groups.length; i++) {
|
|
4416
4452
|
sashOffset += groups[i].size;
|
|
4417
4453
|
if (i > 0) {
|
|
@@ -4421,15 +4457,17 @@ const getMainAreaVirtualDom = (layout, splitButtonEnabled = false) => {
|
|
|
4421
4457
|
const sashId = create(beforeGroupId, afterGroupId);
|
|
4422
4458
|
const style = direction === 'horizontal' ? `left:${sashOffset - groups[i].size}%;` : `top:${sashOffset - groups[i].size}%;`;
|
|
4423
4459
|
children.push(...renderSash(direction, sashId, style));
|
|
4460
|
+
childCount++;
|
|
4424
4461
|
}
|
|
4425
4462
|
children.push(...renderEditorGroup(groups[i], i, splitButtonEnabled, sizeProperty));
|
|
4463
|
+
childCount++;
|
|
4426
4464
|
}
|
|
4427
4465
|
return [{
|
|
4428
4466
|
childCount: 1,
|
|
4429
4467
|
className: Main,
|
|
4430
4468
|
type: Div
|
|
4431
4469
|
}, {
|
|
4432
|
-
childCount
|
|
4470
|
+
childCount,
|
|
4433
4471
|
className: editorGroupsContainerClassName,
|
|
4434
4472
|
role: None$1,
|
|
4435
4473
|
type: Div
|