@lvce-editor/main-area-worker 8.7.0 → 8.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 +79 -10
- package/package.json +1 -1
|
@@ -1746,7 +1746,7 @@ const createViewlet = async (viewletModuleId, editorUid, tabId, bounds, uri) =>
|
|
|
1746
1746
|
|
|
1747
1747
|
const handleAttach = async command => {
|
|
1748
1748
|
// TODO find a better way to append editors
|
|
1749
|
-
const parentNodeSelector = '.editor-groups-container';
|
|
1749
|
+
const parentNodeSelector = '.editor-groups-container, .EditorGroup';
|
|
1750
1750
|
await invoke('Layout.attachViewlet', parentNodeSelector, command.instanceId);
|
|
1751
1751
|
};
|
|
1752
1752
|
|
|
@@ -2273,7 +2273,7 @@ const handleClick = async (state, name) => {
|
|
|
2273
2273
|
return state;
|
|
2274
2274
|
};
|
|
2275
2275
|
|
|
2276
|
-
const closeEditorGroup = (state, groupId) => {
|
|
2276
|
+
const closeEditorGroup$1 = (state, groupId) => {
|
|
2277
2277
|
const {
|
|
2278
2278
|
layout
|
|
2279
2279
|
} = state;
|
|
@@ -2915,7 +2915,7 @@ const handleClickAction = async (state, action, rawGroupId) => {
|
|
|
2915
2915
|
if (rawGroupId) {
|
|
2916
2916
|
const groupId = Number.parseInt(rawGroupId, 10);
|
|
2917
2917
|
if (!Number.isNaN(groupId)) {
|
|
2918
|
-
return closeEditorGroup(state, groupId);
|
|
2918
|
+
return closeEditorGroup$1(state, groupId);
|
|
2919
2919
|
}
|
|
2920
2920
|
}
|
|
2921
2921
|
return state;
|
|
@@ -2972,7 +2972,10 @@ const handleDoubleClick = async state => {
|
|
|
2972
2972
|
};
|
|
2973
2973
|
|
|
2974
2974
|
const EditorGroupHeader = 'EditorGroupHeader';
|
|
2975
|
+
const EmptyGroupCloseButton = 'EmptyGroupCloseButton';
|
|
2975
2976
|
const EditorGroup = 'EditorGroup';
|
|
2977
|
+
const EditorGroupsHorizontal = 'EditorGroupsHorizontal';
|
|
2978
|
+
const EditorGroupsVertical = 'EditorGroupsVertical';
|
|
2976
2979
|
const EditorContainer = 'EditorContainer';
|
|
2977
2980
|
const EditorGroupActions = 'EditorGroupActions';
|
|
2978
2981
|
const EditorGroupActionButton = 'EditorGroupActionButton';
|
|
@@ -3619,6 +3622,7 @@ const i18nString = (key, placeholders = emptyObject) => {
|
|
|
3619
3622
|
};
|
|
3620
3623
|
|
|
3621
3624
|
const Close = 'Close';
|
|
3625
|
+
const CloseEditorGroup = 'Close Editor Group';
|
|
3622
3626
|
const CloseAll = 'Close All';
|
|
3623
3627
|
const CloseOthers = 'Close Others';
|
|
3624
3628
|
const CloseToTheRight = 'Close To The Right';
|
|
@@ -3635,6 +3639,9 @@ const splitEditorGroup = () => {
|
|
|
3635
3639
|
const close = () => {
|
|
3636
3640
|
return i18nString(Close);
|
|
3637
3641
|
};
|
|
3642
|
+
const closeEditorGroup = () => {
|
|
3643
|
+
return i18nString(CloseEditorGroup);
|
|
3644
|
+
};
|
|
3638
3645
|
const closeOthers = () => {
|
|
3639
3646
|
return i18nString(CloseOthers);
|
|
3640
3647
|
};
|
|
@@ -3754,6 +3761,27 @@ const refresh = state => {
|
|
|
3754
3761
|
|
|
3755
3762
|
const getCss = () => {
|
|
3756
3763
|
const rules = [`.MainArea {
|
|
3764
|
+
}`, `.editor-groups-container {
|
|
3765
|
+
position: relative;
|
|
3766
|
+
}`, `.Sash {
|
|
3767
|
+
position: absolute;
|
|
3768
|
+
z-index: 1;
|
|
3769
|
+
}`, `.SashVertical {
|
|
3770
|
+
top: 0;
|
|
3771
|
+
bottom: 0;
|
|
3772
|
+
width: 0;
|
|
3773
|
+
cursor: col-resize;
|
|
3774
|
+
}`, `.SashVertical:hover {
|
|
3775
|
+
width: 4px;
|
|
3776
|
+
margin-left: -2px;
|
|
3777
|
+
}`, `.SashHorizontal {
|
|
3778
|
+
left: 0;
|
|
3779
|
+
right: 0;
|
|
3780
|
+
height: 0;
|
|
3781
|
+
cursor: row-resize;
|
|
3782
|
+
}`, `.SashHorizontal:hover {
|
|
3783
|
+
height: 4px;
|
|
3784
|
+
margin-top: -2px;
|
|
3757
3785
|
}`];
|
|
3758
3786
|
const css = rules.join('\n');
|
|
3759
3787
|
return css;
|
|
@@ -4283,9 +4311,35 @@ const renderEditorGroupHeader = (group, groupIndex, splitButtonEnabled) => {
|
|
|
4283
4311
|
}, ...getTabsVirtualDom(group, groupIndex, tabsChildCount), ...actions];
|
|
4284
4312
|
};
|
|
4285
4313
|
|
|
4286
|
-
const
|
|
4314
|
+
const renderEmptyGroupCloseButton = (group, groupIndex) => {
|
|
4315
|
+
return [{
|
|
4316
|
+
childCount: 1,
|
|
4317
|
+
className: EmptyGroupCloseButton,
|
|
4318
|
+
'data-groupId': String(group.id),
|
|
4319
|
+
name: 'close-group',
|
|
4320
|
+
onClick: HandleClickAction,
|
|
4321
|
+
title: closeEditorGroup(),
|
|
4322
|
+
type: Button$2
|
|
4323
|
+
}, text('✕')];
|
|
4324
|
+
};
|
|
4325
|
+
|
|
4326
|
+
const renderEmptyEditorGroup = (group, groupIndex, style) => {
|
|
4327
|
+
return [{
|
|
4328
|
+
childCount: 1,
|
|
4329
|
+
className: EditorGroup,
|
|
4330
|
+
style,
|
|
4331
|
+
type: Div
|
|
4332
|
+
}, ...renderEmptyGroupCloseButton(group)];
|
|
4333
|
+
};
|
|
4334
|
+
|
|
4335
|
+
const renderEditorGroup = (group, groupIndex, splitButtonEnabled = false, sizeProperty = 'width') => {
|
|
4287
4336
|
const activeTab = group.tabs.find(tab => tab.id === group.activeTabId);
|
|
4288
|
-
const style =
|
|
4337
|
+
const style = `${sizeProperty}:${group.size}%;`;
|
|
4338
|
+
const hasTabs = group.tabs.length > 0;
|
|
4339
|
+
const hasEmptyGroupCloseButton = !hasTabs;
|
|
4340
|
+
if (hasEmptyGroupCloseButton) {
|
|
4341
|
+
return renderEmptyEditorGroup(group, groupIndex, style);
|
|
4342
|
+
}
|
|
4289
4343
|
return [{
|
|
4290
4344
|
childCount: 2,
|
|
4291
4345
|
className: EditorGroup,
|
|
@@ -4298,29 +4352,44 @@ const renderEditorGroup = (group, groupIndex, splitButtonEnabled = false, direct
|
|
|
4298
4352
|
}, ...renderEditor(activeTab)];
|
|
4299
4353
|
};
|
|
4300
4354
|
|
|
4301
|
-
const renderSash = (direction, sashId) => {
|
|
4355
|
+
const renderSash = (direction, sashId, style) => {
|
|
4302
4356
|
return {
|
|
4303
4357
|
childCount: 0,
|
|
4304
|
-
className: direction === '
|
|
4358
|
+
className: direction === 'horizontal' ? 'Sash SashVertical' : 'Sash SashHorizontal',
|
|
4305
4359
|
'data-sashId': sashId,
|
|
4306
4360
|
onPointerDown: HandleSashPointerDown,
|
|
4307
4361
|
onPointerMove: HandleSashPointerMove,
|
|
4308
4362
|
onPointerUp: HandleSashPointerUp,
|
|
4363
|
+
style,
|
|
4309
4364
|
type: Div
|
|
4310
4365
|
};
|
|
4311
4366
|
};
|
|
4312
4367
|
|
|
4313
4368
|
const getMainAreaVirtualDom = (layout, splitButtonEnabled = false) => {
|
|
4369
|
+
const sizeProperty = layout.direction === 'vertical' ? 'height' : 'width';
|
|
4370
|
+
if (layout.groups.length === 1) {
|
|
4371
|
+
return [{
|
|
4372
|
+
childCount: 1,
|
|
4373
|
+
className: Main,
|
|
4374
|
+
type: Div
|
|
4375
|
+
}, ...renderEditorGroup(layout.groups[0], 0, splitButtonEnabled, sizeProperty)];
|
|
4376
|
+
}
|
|
4314
4377
|
const children = [];
|
|
4378
|
+
const isSplit = layout.groups.length > 1;
|
|
4379
|
+
const directionClassName = isSplit ? layout.direction === 'horizontal' ? EditorGroupsVertical : EditorGroupsHorizontal : '';
|
|
4380
|
+
const editorGroupsContainerClassName = directionClassName ? `${EDITOR_GROUPS_CONTAINER} ${directionClassName}` : EDITOR_GROUPS_CONTAINER;
|
|
4381
|
+
let sashOffset = 0;
|
|
4315
4382
|
for (let i = 0; i < layout.groups.length; i++) {
|
|
4383
|
+
sashOffset += layout.groups[i].size;
|
|
4316
4384
|
if (i > 0) {
|
|
4317
4385
|
// Insert sash between groups
|
|
4318
4386
|
const beforeGroupId = layout.groups[i - 1].id;
|
|
4319
4387
|
const afterGroupId = layout.groups[i].id;
|
|
4320
4388
|
const sashId = create(beforeGroupId, afterGroupId);
|
|
4321
|
-
|
|
4389
|
+
const style = layout.direction === 'horizontal' ? `left:${sashOffset - layout.groups[i].size}%;` : `top:${sashOffset - layout.groups[i].size}%;`;
|
|
4390
|
+
children.push(renderSash(layout.direction, sashId, style));
|
|
4322
4391
|
}
|
|
4323
|
-
children.push(...renderEditorGroup(layout.groups[i], i, splitButtonEnabled,
|
|
4392
|
+
children.push(...renderEditorGroup(layout.groups[i], i, splitButtonEnabled, sizeProperty));
|
|
4324
4393
|
}
|
|
4325
4394
|
return [{
|
|
4326
4395
|
childCount: 1,
|
|
@@ -4328,7 +4397,7 @@ const getMainAreaVirtualDom = (layout, splitButtonEnabled = false) => {
|
|
|
4328
4397
|
type: Div
|
|
4329
4398
|
}, {
|
|
4330
4399
|
childCount: children.length,
|
|
4331
|
-
className:
|
|
4400
|
+
className: editorGroupsContainerClassName,
|
|
4332
4401
|
role: None$1,
|
|
4333
4402
|
type: Div
|
|
4334
4403
|
}, ...children];
|