@lvce-editor/main-area-worker 9.50.0 → 9.50.1
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 +97 -44
- package/package.json +1 -1
|
@@ -4768,7 +4768,6 @@ const show2 = async (uid, menuId, x, y, args) => {
|
|
|
4768
4768
|
};
|
|
4769
4769
|
|
|
4770
4770
|
const NoGroupId = -1;
|
|
4771
|
-
const RendererWorkerForwardDelay$1 = 50;
|
|
4772
4771
|
const handleContextMenu = async (state, rawGroupId, x, y) => {
|
|
4773
4772
|
const {
|
|
4774
4773
|
uid
|
|
@@ -4782,15 +4781,6 @@ const handleContextMenu = async (state, rawGroupId, x, y) => {
|
|
|
4782
4781
|
if (Number.isNaN(groupId)) {
|
|
4783
4782
|
return state;
|
|
4784
4783
|
}
|
|
4785
|
-
if (isConnected()) {
|
|
4786
|
-
setTimeout(() => {
|
|
4787
|
-
void show2(uid, Main$1, x, y, {
|
|
4788
|
-
groupId,
|
|
4789
|
-
menuId: Main$1
|
|
4790
|
-
});
|
|
4791
|
-
}, RendererWorkerForwardDelay$1);
|
|
4792
|
-
return state;
|
|
4793
|
-
}
|
|
4794
4784
|
await show2(uid, Main$1, x, y, {
|
|
4795
4785
|
groupId,
|
|
4796
4786
|
menuId: Main$1
|
|
@@ -4832,6 +4822,60 @@ const handleDragLeave = state => {
|
|
|
4832
4822
|
};
|
|
4833
4823
|
};
|
|
4834
4824
|
|
|
4825
|
+
const getChildBounds = (bounds, direction, offset, size) => {
|
|
4826
|
+
if (direction === Horizontal) {
|
|
4827
|
+
return {
|
|
4828
|
+
height: bounds.height,
|
|
4829
|
+
width: bounds.width * size,
|
|
4830
|
+
x: bounds.x + bounds.width * offset,
|
|
4831
|
+
y: bounds.y
|
|
4832
|
+
};
|
|
4833
|
+
}
|
|
4834
|
+
return {
|
|
4835
|
+
height: bounds.height * size,
|
|
4836
|
+
width: bounds.width,
|
|
4837
|
+
x: bounds.x,
|
|
4838
|
+
y: bounds.y + bounds.height * offset
|
|
4839
|
+
};
|
|
4840
|
+
};
|
|
4841
|
+
const getEditorGroupBounds = (layout, width, height) => {
|
|
4842
|
+
const {
|
|
4843
|
+
direction,
|
|
4844
|
+
groups
|
|
4845
|
+
} = layout;
|
|
4846
|
+
const segments = getGroupSegments(groups, direction);
|
|
4847
|
+
const rootBounds = {
|
|
4848
|
+
height,
|
|
4849
|
+
width,
|
|
4850
|
+
x: 0,
|
|
4851
|
+
y: 0
|
|
4852
|
+
};
|
|
4853
|
+
const result = [];
|
|
4854
|
+
let segmentOffset = 0;
|
|
4855
|
+
for (const segment of segments) {
|
|
4856
|
+
const segmentSize = getSegmentSize(segment);
|
|
4857
|
+
const segmentBounds = getChildBounds(rootBounds, direction, segmentOffset / 100, segmentSize / 100);
|
|
4858
|
+
segmentOffset += segmentSize;
|
|
4859
|
+
if (segment.direction === undefined) {
|
|
4860
|
+
result.push({
|
|
4861
|
+
...segmentBounds,
|
|
4862
|
+
group: segment.groups[0]
|
|
4863
|
+
});
|
|
4864
|
+
continue;
|
|
4865
|
+
}
|
|
4866
|
+
let groupOffset = 0;
|
|
4867
|
+
for (const group of segment.groups) {
|
|
4868
|
+
const groupBounds = getChildBounds(segmentBounds, segment.direction, groupOffset / segmentSize, group.size / segmentSize);
|
|
4869
|
+
groupOffset += group.size;
|
|
4870
|
+
result.push({
|
|
4871
|
+
...groupBounds,
|
|
4872
|
+
group
|
|
4873
|
+
});
|
|
4874
|
+
}
|
|
4875
|
+
}
|
|
4876
|
+
return result;
|
|
4877
|
+
};
|
|
4878
|
+
|
|
4835
4879
|
const None = 0;
|
|
4836
4880
|
const Up = 1;
|
|
4837
4881
|
const Down = 2;
|
|
@@ -4906,6 +4950,12 @@ const getSplitDirection = (x, y, width, height) => {
|
|
|
4906
4950
|
const isNotEmpty = group => {
|
|
4907
4951
|
return !group.isEmpty;
|
|
4908
4952
|
};
|
|
4953
|
+
const getContentOffsetY = (targetIsEmpty, hasOpenEditor, tabHeight) => {
|
|
4954
|
+
if (targetIsEmpty !== undefined) {
|
|
4955
|
+
return targetIsEmpty ? 0 : tabHeight;
|
|
4956
|
+
}
|
|
4957
|
+
return hasOpenEditor ? tabHeight : 0;
|
|
4958
|
+
};
|
|
4909
4959
|
const getDragOverlay = (state, eventX, eventY) => {
|
|
4910
4960
|
const {
|
|
4911
4961
|
height,
|
|
@@ -4918,17 +4968,33 @@ const getDragOverlay = (state, eventX, eventY) => {
|
|
|
4918
4968
|
const {
|
|
4919
4969
|
groups
|
|
4920
4970
|
} = layout;
|
|
4971
|
+
const relativeEventX = Math.min(Math.max(eventX - x, 0), width);
|
|
4972
|
+
const relativeEventY = Math.min(Math.max(eventY - y, 0), height);
|
|
4973
|
+
const groupBounds = getEditorGroupBounds(layout, width, height);
|
|
4974
|
+
const target = groupBounds.find(bounds => {
|
|
4975
|
+
return relativeEventX >= bounds.x && relativeEventX <= bounds.x + bounds.width && relativeEventY >= bounds.y && relativeEventY <= bounds.y + bounds.height;
|
|
4976
|
+
});
|
|
4921
4977
|
const hasOpenEditor = groups.some(isNotEmpty);
|
|
4922
|
-
const
|
|
4923
|
-
const
|
|
4924
|
-
const
|
|
4925
|
-
const
|
|
4926
|
-
const
|
|
4927
|
-
|
|
4978
|
+
const targetX = target?.x ?? 0;
|
|
4979
|
+
const targetY = target?.y ?? 0;
|
|
4980
|
+
const targetWidth = target?.width ?? width;
|
|
4981
|
+
const targetHeight = target?.height ?? height;
|
|
4982
|
+
const contentOffsetY = getContentOffsetY(target?.group.isEmpty, hasOpenEditor, tabHeight);
|
|
4983
|
+
const contentY = targetY + contentOffsetY;
|
|
4984
|
+
const contentHeight = Math.max(0, targetHeight - contentOffsetY);
|
|
4985
|
+
const relativeX = relativeEventX - targetX;
|
|
4986
|
+
const relativeY = relativeEventY - contentY;
|
|
4987
|
+
const splitDirection = getSplitDirection(relativeX, relativeY, targetWidth, contentHeight);
|
|
4988
|
+
return {
|
|
4989
|
+
...getOverlay(targetX, contentY, targetWidth, contentHeight, splitDirection),
|
|
4990
|
+
...(target && {
|
|
4991
|
+
targetGroupId: target.group.id
|
|
4992
|
+
})
|
|
4993
|
+
};
|
|
4928
4994
|
};
|
|
4929
4995
|
|
|
4930
4996
|
const isDragOverlayEqual = (oldOverlay, newOverlay) => {
|
|
4931
|
-
return oldOverlay?.x === newOverlay?.x && oldOverlay?.y === newOverlay?.y && oldOverlay?.width === newOverlay?.width && oldOverlay?.height === newOverlay?.height && oldOverlay?.splitDirection === newOverlay?.splitDirection;
|
|
4997
|
+
return oldOverlay?.x === newOverlay?.x && oldOverlay?.y === newOverlay?.y && oldOverlay?.width === newOverlay?.width && oldOverlay?.height === newOverlay?.height && oldOverlay?.splitDirection === newOverlay?.splitDirection && oldOverlay?.targetGroupId === newOverlay?.targetGroupId;
|
|
4932
4998
|
};
|
|
4933
4999
|
|
|
4934
5000
|
const handleDragOver = (state, eventX, eventY) => {
|
|
@@ -5105,27 +5171,29 @@ const splitUp$1 = (state, groupId) => {
|
|
|
5105
5171
|
return splitEditorGroup$1(state, resolvedGroupId, 'up');
|
|
5106
5172
|
};
|
|
5107
5173
|
|
|
5108
|
-
const splitForDrop = (state, splitDirection) => {
|
|
5174
|
+
const splitForDrop = (state, splitDirection, targetGroupId) => {
|
|
5109
5175
|
switch (splitDirection) {
|
|
5110
5176
|
case Down:
|
|
5111
|
-
return splitDown$1(state);
|
|
5177
|
+
return splitDown$1(state, targetGroupId);
|
|
5112
5178
|
case Left:
|
|
5113
|
-
return splitLeft$1(state);
|
|
5179
|
+
return splitLeft$1(state, targetGroupId);
|
|
5114
5180
|
case Right:
|
|
5115
|
-
return splitRight$1(state);
|
|
5181
|
+
return splitRight$1(state, targetGroupId);
|
|
5116
5182
|
case Up:
|
|
5117
|
-
return splitUp$1(state);
|
|
5183
|
+
return splitUp$1(state, targetGroupId);
|
|
5118
5184
|
default:
|
|
5119
5185
|
return state;
|
|
5120
5186
|
}
|
|
5121
5187
|
};
|
|
5122
5188
|
|
|
5123
|
-
const applyDropAction = async (context, action, splitDirection) => {
|
|
5189
|
+
const applyDropAction = async (context, action, splitDirection, targetGroupId) => {
|
|
5124
5190
|
switch (action.command) {
|
|
5125
5191
|
case 'openFiles':
|
|
5126
5192
|
{
|
|
5127
5193
|
if (action.uris.length > 0 && splitDirection !== None) {
|
|
5128
|
-
await context.updateState(state => splitForDrop(state, splitDirection));
|
|
5194
|
+
await context.updateState(state => splitForDrop(state, splitDirection, targetGroupId));
|
|
5195
|
+
} else if (action.uris.length > 0 && targetGroupId !== undefined) {
|
|
5196
|
+
await context.updateState(state => focusEditorGroup(state, targetGroupId));
|
|
5129
5197
|
}
|
|
5130
5198
|
await openUrisWithContext(context, action.uris, splitDirection === None);
|
|
5131
5199
|
break;
|
|
@@ -5164,7 +5232,10 @@ const getDropAction = async uris => {
|
|
|
5164
5232
|
};
|
|
5165
5233
|
|
|
5166
5234
|
const handleDrop = async (context, dropIdOrItemIds) => {
|
|
5167
|
-
const
|
|
5235
|
+
const {
|
|
5236
|
+
splitDirection = None,
|
|
5237
|
+
targetGroupId
|
|
5238
|
+
} = context.getState().dragOverlay ?? {};
|
|
5168
5239
|
await context.updateState(handleDragLeave);
|
|
5169
5240
|
const {
|
|
5170
5241
|
platform
|
|
@@ -5180,7 +5251,7 @@ const handleDrop = async (context, dropIdOrItemIds) => {
|
|
|
5180
5251
|
uris = droppedUris;
|
|
5181
5252
|
}
|
|
5182
5253
|
const actions = await getDropAction(uris);
|
|
5183
|
-
await applyDropAction(context, actions, splitDirection);
|
|
5254
|
+
await applyDropAction(context, actions, splitDirection, targetGroupId);
|
|
5184
5255
|
};
|
|
5185
5256
|
|
|
5186
5257
|
const EditorGroupHeader = 'EditorGroupHeader';
|
|
@@ -5402,8 +5473,6 @@ const handleIconThemeChange = async state => {
|
|
|
5402
5473
|
};
|
|
5403
5474
|
};
|
|
5404
5475
|
|
|
5405
|
-
const RendererWorkerCallbackDelay = 50;
|
|
5406
|
-
const commandsWithDeferredRender = new Set(['handleContextMenu', 'handleTabContextMenu']);
|
|
5407
5476
|
const handleMessagePort = async (port, viewletCommandMap, setAsRendererProcessFallback = true) => {
|
|
5408
5477
|
const executeViewletCommand = async (uid, command, ...args) => {
|
|
5409
5478
|
const fn = viewletCommandMap[`MainArea.${command}`];
|
|
@@ -5411,12 +5480,6 @@ const handleMessagePort = async (port, viewletCommandMap, setAsRendererProcessFa
|
|
|
5411
5480
|
throw new TypeError(`Viewlet command not found: ${command}`);
|
|
5412
5481
|
}
|
|
5413
5482
|
await fn(uid, ...args);
|
|
5414
|
-
if (commandsWithDeferredRender.has(command)) {
|
|
5415
|
-
setTimeout(() => {
|
|
5416
|
-
void invoke$1('Viewlet.requestRender', uid);
|
|
5417
|
-
}, RendererWorkerCallbackDelay);
|
|
5418
|
-
return;
|
|
5419
|
-
}
|
|
5420
5483
|
await invoke$1('Viewlet.requestRender', uid);
|
|
5421
5484
|
};
|
|
5422
5485
|
const rpc = await create$8({
|
|
@@ -5801,7 +5864,6 @@ const handleSashPointerUp = async state => {
|
|
|
5801
5864
|
};
|
|
5802
5865
|
};
|
|
5803
5866
|
|
|
5804
|
-
const RendererWorkerForwardDelay = 50;
|
|
5805
5867
|
const handleTabContextMenu = async (state, button, x, y, groupIndexRaw = '', tabIndexRaw = '') => {
|
|
5806
5868
|
number(x);
|
|
5807
5869
|
number(y);
|
|
@@ -5816,15 +5878,6 @@ const handleTabContextMenu = async (state, button, x, y, groupIndexRaw = '', tab
|
|
|
5816
5878
|
groupId: group.id,
|
|
5817
5879
|
tabId: tab.id
|
|
5818
5880
|
} : {};
|
|
5819
|
-
if (isConnected()) {
|
|
5820
|
-
setTimeout(() => {
|
|
5821
|
-
void show2(uid, Tab, x, y, {
|
|
5822
|
-
menuId: Tab,
|
|
5823
|
-
...target
|
|
5824
|
-
});
|
|
5825
|
-
}, RendererWorkerForwardDelay);
|
|
5826
|
-
return state;
|
|
5827
|
-
}
|
|
5828
5881
|
await show2(uid, Tab, x, y, {
|
|
5829
5882
|
menuId: Tab,
|
|
5830
5883
|
...target
|