@lvce-editor/main-area-worker 9.50.0 → 9.51.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.
@@ -1680,8 +1680,11 @@ const VirtualDomElements = {
1680
1680
  const Button$1 = 'event.button';
1681
1681
  const ClientX = 'event.clientX';
1682
1682
  const ClientY = 'event.clientY';
1683
+ const DeltaMode = 'event.deltaMode';
1684
+ const DeltaY = 'event.deltaY';
1683
1685
  const DropId = 'event.dropId';
1684
1686
  const EventTargetClassName = 'event.target.className';
1687
+ const Key = 'event.key';
1685
1688
  const TargetName = 'event.target.name';
1686
1689
 
1687
1690
  const Tab = 13;
@@ -2825,6 +2828,10 @@ const create$1 = (uid, uri, x, y, width, height, platform, assetDir, tabHeight =
2825
2828
  set$1(uid, state, state);
2826
2829
  };
2827
2830
 
2831
+ const isEqual$3 = (oldState, newState) => {
2832
+ return oldState.layout === newState.layout && oldState.width === newState.width;
2833
+ };
2834
+
2828
2835
  const isEqual$2 = (oldState, newState) => {
2829
2836
  return false;
2830
2837
  };
@@ -2842,12 +2849,13 @@ const RenderCss = 10;
2842
2849
  const RenderIncremental = 11;
2843
2850
  const RenderPendingViewletUpdate = 12;
2844
2851
  const RenderDragData = 13;
2852
+ const RenderActiveTabVisibility = 14;
2845
2853
 
2846
2854
  const isPendingViewletUpdateEqual = (oldState, newState) => {
2847
2855
  return newState.pendingViewletUpdate === undefined;
2848
2856
  };
2849
- const modules = [isEqual, isEqual$2, isPendingViewletUpdateEqual, isEqual$1];
2850
- const numbers = [RenderIncremental, RenderCss, RenderPendingViewletUpdate, RenderDragData];
2857
+ const modules = [isEqual, isEqual$2, isPendingViewletUpdateEqual, isEqual$1, isEqual$3];
2858
+ const numbers = [RenderIncremental, RenderCss, RenderPendingViewletUpdate, RenderDragData, RenderActiveTabVisibility];
2851
2859
 
2852
2860
  const diff = (oldState, newState) => {
2853
2861
  const diffResult = [];
@@ -3203,19 +3211,137 @@ const findTabById = (state, tabId) => {
3203
3211
  return undefined;
3204
3212
  };
3205
3213
 
3206
- const getSelectedTabBounds = state => {
3214
+ const getSegmentSize = segment => {
3215
+ return segment.groups.reduce((total, group) => total + group.size, 0);
3216
+ };
3217
+ const getGroupSegments = (groups, parentDirection) => {
3218
+ const segments = [];
3219
+ let index = 0;
3220
+ while (index < groups.length) {
3221
+ const group = groups[index];
3222
+ if (group.direction !== parentDirection) {
3223
+ const startIndex = index;
3224
+ const nestedGroups = [group];
3225
+ const {
3226
+ segmentId
3227
+ } = group;
3228
+ index++;
3229
+ while (index < groups.length && groups[index].direction === group.direction && groups[index].segmentId === segmentId) {
3230
+ nestedGroups.push(groups[index]);
3231
+ index++;
3232
+ }
3233
+ segments.push({
3234
+ direction: nestedGroups.length === 1 ? undefined : group.direction,
3235
+ groups: nestedGroups,
3236
+ startIndex
3237
+ });
3238
+ continue;
3239
+ }
3240
+ segments.push({
3241
+ direction: undefined,
3242
+ groups: [group],
3243
+ startIndex: index
3244
+ });
3245
+ index++;
3246
+ }
3247
+ return segments;
3248
+ };
3249
+
3250
+ const getChildBounds = (bounds, direction, offset, size) => {
3251
+ if (direction === Horizontal) {
3252
+ return {
3253
+ height: bounds.height,
3254
+ width: bounds.width * size,
3255
+ x: bounds.x + bounds.width * offset,
3256
+ y: bounds.y
3257
+ };
3258
+ }
3259
+ return {
3260
+ height: bounds.height * size,
3261
+ width: bounds.width,
3262
+ x: bounds.x,
3263
+ y: bounds.y + bounds.height * offset
3264
+ };
3265
+ };
3266
+ const getEditorGroupBoundsFromRoot = (layout, rootBounds) => {
3207
3267
  const {
3268
+ direction,
3269
+ groups
3270
+ } = layout;
3271
+ const segments = getGroupSegments(groups, direction);
3272
+ const result = [];
3273
+ let segmentOffset = 0;
3274
+ for (const segment of segments) {
3275
+ const segmentSize = getSegmentSize(segment);
3276
+ const segmentBounds = getChildBounds(rootBounds, direction, segmentOffset / 100, segmentSize / 100);
3277
+ segmentOffset += segmentSize;
3278
+ if (segment.direction === undefined) {
3279
+ result.push({
3280
+ ...segmentBounds,
3281
+ group: segment.groups[0]
3282
+ });
3283
+ continue;
3284
+ }
3285
+ let groupOffset = 0;
3286
+ for (const group of segment.groups) {
3287
+ const groupBounds = getChildBounds(segmentBounds, segment.direction, groupOffset / segmentSize, group.size / segmentSize);
3288
+ groupOffset += group.size;
3289
+ result.push({
3290
+ ...groupBounds,
3291
+ group
3292
+ });
3293
+ }
3294
+ }
3295
+ return result;
3296
+ };
3297
+ const getEditorGroupBounds = (layout, width, height) => {
3298
+ return getEditorGroupBoundsFromRoot(layout, {
3208
3299
  height,
3300
+ width,
3301
+ x: 0,
3302
+ y: 0
3303
+ });
3304
+ };
3305
+ const getEditorGroupContentBounds = (layout, bounds, tabHeight) => {
3306
+ return getEditorGroupBoundsFromRoot(layout, bounds).map(({
3307
+ group,
3308
+ ...groupBounds
3309
+ }) => ({
3310
+ ...groupBounds,
3311
+ groupId: group.id,
3312
+ height: groupBounds.height - tabHeight,
3313
+ y: groupBounds.y + tabHeight
3314
+ }));
3315
+ };
3316
+
3317
+ const getSelectedTabBounds = (state, groupId = state.layout.activeGroupId) => {
3318
+ const {
3319
+ height,
3320
+ layout,
3209
3321
  tabHeight,
3210
3322
  width,
3211
3323
  x,
3212
3324
  y
3213
3325
  } = state;
3214
- return {
3215
- height: height - tabHeight,
3326
+ const bounds = getEditorGroupContentBounds(layout, {
3327
+ height,
3216
3328
  width,
3217
3329
  x,
3218
- y: y + tabHeight
3330
+ y
3331
+ }, tabHeight).find(item => item.groupId === groupId);
3332
+ if (!bounds) {
3333
+ return {
3334
+ height: height - tabHeight,
3335
+ width,
3336
+ x,
3337
+ y: y + tabHeight
3338
+ };
3339
+ }
3340
+ return {
3341
+ height: bounds.height,
3342
+ width: bounds.width,
3343
+ x: bounds.x,
3344
+ y: bounds.y
3219
3345
  };
3220
3346
  };
3221
3347
 
@@ -3301,7 +3427,7 @@ const maybeCreateViewletForSelectedTab = async (state, newState, groupIndex, ind
3301
3427
  if (!viewletModuleId) {
3302
3428
  return undefined;
3303
3429
  }
3304
- const bounds = getSelectedTabBounds(newState);
3430
+ const bounds = getSelectedTabBounds(newState, newState.layout.groups[groupIndex].id);
3305
3431
  let stateWithViewlet = createViewletForTab(newState, tabId);
3306
3432
  set$1(uid, state, stateWithViewlet);
3307
3433
  if (switchCommands.length > 0) {
@@ -4131,12 +4257,8 @@ const openInputWithContext = async (context, options) => {
4131
4257
  await context.updateState(() => unsupportedState);
4132
4258
  return;
4133
4259
  }
4134
- const bounds = {
4135
- height: stateAfterModuleId.height - stateAfterModuleId.tabHeight,
4136
- width: stateAfterModuleId.width,
4137
- x: stateAfterModuleId.x,
4138
- y: stateAfterModuleId.y + stateAfterModuleId.tabHeight
4139
- };
4260
+ const tabLocation = findTabById(stateAfterModuleId, tabId);
4261
+ const bounds = getSelectedTabBounds(stateAfterModuleId, tabLocation?.groupId);
4140
4262
  const stateWithViewlet = createViewletForTab(stateAfterModuleId, tabId, viewletModuleId, bounds);
4141
4263
  let intermediateState = stateWithViewlet;
4142
4264
  const {
@@ -4468,42 +4590,6 @@ const retryOpen = async state => {
4468
4590
  return openUri(state, tab.uri);
4469
4591
  };
4470
4592
 
4471
- const getSegmentSize = segment => {
4472
- return segment.groups.reduce((total, group) => total + group.size, 0);
4473
- };
4474
- const getGroupSegments = (groups, parentDirection) => {
4475
- const segments = [];
4476
- let index = 0;
4477
- while (index < groups.length) {
4478
- const group = groups[index];
4479
- if (group.direction !== parentDirection) {
4480
- const startIndex = index;
4481
- const nestedGroups = [group];
4482
- const {
4483
- segmentId
4484
- } = group;
4485
- index++;
4486
- while (index < groups.length && groups[index].direction === group.direction && groups[index].segmentId === segmentId) {
4487
- nestedGroups.push(groups[index]);
4488
- index++;
4489
- }
4490
- segments.push({
4491
- direction: nestedGroups.length === 1 ? undefined : group.direction,
4492
- groups: nestedGroups,
4493
- startIndex
4494
- });
4495
- continue;
4496
- }
4497
- segments.push({
4498
- direction: undefined,
4499
- groups: [group],
4500
- startIndex: index
4501
- });
4502
- index++;
4503
- }
4504
- return segments;
4505
- };
4506
-
4507
4593
  const rebalanceGroupSizes = groups => {
4508
4594
  const groupCount = groups.length;
4509
4595
  if (groupCount === 0) {
@@ -4768,7 +4854,6 @@ const show2 = async (uid, menuId, x, y, args) => {
4768
4854
  };
4769
4855
 
4770
4856
  const NoGroupId = -1;
4771
- const RendererWorkerForwardDelay$1 = 50;
4772
4857
  const handleContextMenu = async (state, rawGroupId, x, y) => {
4773
4858
  const {
4774
4859
  uid
@@ -4782,15 +4867,6 @@ const handleContextMenu = async (state, rawGroupId, x, y) => {
4782
4867
  if (Number.isNaN(groupId)) {
4783
4868
  return state;
4784
4869
  }
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
4870
  await show2(uid, Main$1, x, y, {
4795
4871
  groupId,
4796
4872
  menuId: Main$1
@@ -4906,6 +4982,12 @@ const getSplitDirection = (x, y, width, height) => {
4906
4982
  const isNotEmpty = group => {
4907
4983
  return !group.isEmpty;
4908
4984
  };
4985
+ const getContentOffsetY = (targetIsEmpty, hasOpenEditor, tabHeight) => {
4986
+ if (targetIsEmpty !== undefined) {
4987
+ return targetIsEmpty ? 0 : tabHeight;
4988
+ }
4989
+ return hasOpenEditor ? tabHeight : 0;
4990
+ };
4909
4991
  const getDragOverlay = (state, eventX, eventY) => {
4910
4992
  const {
4911
4993
  height,
@@ -4918,17 +5000,33 @@ const getDragOverlay = (state, eventX, eventY) => {
4918
5000
  const {
4919
5001
  groups
4920
5002
  } = layout;
5003
+ const relativeEventX = Math.min(Math.max(eventX - x, 0), width);
5004
+ const relativeEventY = Math.min(Math.max(eventY - y, 0), height);
5005
+ const groupBounds = getEditorGroupBounds(layout, width, height);
5006
+ const target = groupBounds.find(bounds => {
5007
+ return relativeEventX >= bounds.x && relativeEventX <= bounds.x + bounds.width && relativeEventY >= bounds.y && relativeEventY <= bounds.y + bounds.height;
5008
+ });
4921
5009
  const hasOpenEditor = groups.some(isNotEmpty);
4922
- const contentY = hasOpenEditor ? tabHeight : 0;
4923
- const contentHeight = Math.max(0, height - contentY);
4924
- const relativeX = eventX - x;
4925
- const relativeY = eventY - y - contentY;
4926
- const splitDirection = getSplitDirection(relativeX, relativeY, width, contentHeight);
4927
- return getOverlay(0, contentY, width, contentHeight, splitDirection);
5010
+ const targetX = target?.x ?? 0;
5011
+ const targetY = target?.y ?? 0;
5012
+ const targetWidth = target?.width ?? width;
5013
+ const targetHeight = target?.height ?? height;
5014
+ const contentOffsetY = getContentOffsetY(target?.group.isEmpty, hasOpenEditor, tabHeight);
5015
+ const contentY = targetY + contentOffsetY;
5016
+ const contentHeight = Math.max(0, targetHeight - contentOffsetY);
5017
+ const relativeX = relativeEventX - targetX;
5018
+ const relativeY = relativeEventY - contentY;
5019
+ const splitDirection = getSplitDirection(relativeX, relativeY, targetWidth, contentHeight);
5020
+ return {
5021
+ ...getOverlay(targetX, contentY, targetWidth, contentHeight, splitDirection),
5022
+ ...(target && {
5023
+ targetGroupId: target.group.id
5024
+ })
5025
+ };
4928
5026
  };
4929
5027
 
4930
5028
  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;
5029
+ 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
5030
  };
4933
5031
 
4934
5032
  const handleDragOver = (state, eventX, eventY) => {
@@ -5105,27 +5203,29 @@ const splitUp$1 = (state, groupId) => {
5105
5203
  return splitEditorGroup$1(state, resolvedGroupId, 'up');
5106
5204
  };
5107
5205
 
5108
- const splitForDrop = (state, splitDirection) => {
5206
+ const splitForDrop = (state, splitDirection, targetGroupId) => {
5109
5207
  switch (splitDirection) {
5110
5208
  case Down:
5111
- return splitDown$1(state);
5209
+ return splitDown$1(state, targetGroupId);
5112
5210
  case Left:
5113
- return splitLeft$1(state);
5211
+ return splitLeft$1(state, targetGroupId);
5114
5212
  case Right:
5115
- return splitRight$1(state);
5213
+ return splitRight$1(state, targetGroupId);
5116
5214
  case Up:
5117
- return splitUp$1(state);
5215
+ return splitUp$1(state, targetGroupId);
5118
5216
  default:
5119
5217
  return state;
5120
5218
  }
5121
5219
  };
5122
5220
 
5123
- const applyDropAction = async (context, action, splitDirection) => {
5221
+ const applyDropAction = async (context, action, splitDirection, targetGroupId) => {
5124
5222
  switch (action.command) {
5125
5223
  case 'openFiles':
5126
5224
  {
5127
5225
  if (action.uris.length > 0 && splitDirection !== None) {
5128
- await context.updateState(state => splitForDrop(state, splitDirection));
5226
+ await context.updateState(state => splitForDrop(state, splitDirection, targetGroupId));
5227
+ } else if (action.uris.length > 0 && targetGroupId !== undefined) {
5228
+ await context.updateState(state => focusEditorGroup(state, targetGroupId));
5129
5229
  }
5130
5230
  await openUrisWithContext(context, action.uris, splitDirection === None);
5131
5231
  break;
@@ -5164,7 +5264,10 @@ const getDropAction = async uris => {
5164
5264
  };
5165
5265
 
5166
5266
  const handleDrop = async (context, dropIdOrItemIds) => {
5167
- const splitDirection = context.getState().dragOverlay?.splitDirection ?? None;
5267
+ const {
5268
+ splitDirection = None,
5269
+ targetGroupId
5270
+ } = context.getState().dragOverlay ?? {};
5168
5271
  await context.updateState(handleDragLeave);
5169
5272
  const {
5170
5273
  platform
@@ -5180,7 +5283,7 @@ const handleDrop = async (context, dropIdOrItemIds) => {
5180
5283
  uris = droppedUris;
5181
5284
  }
5182
5285
  const actions = await getDropAction(uris);
5183
- await applyDropAction(context, actions, splitDirection);
5286
+ await applyDropAction(context, actions, splitDirection, targetGroupId);
5184
5287
  };
5185
5288
 
5186
5289
  const EditorGroupHeader = 'EditorGroupHeader';
@@ -5290,14 +5393,7 @@ const newFile = async state => {
5290
5393
  uri: 'untitled:///1'
5291
5394
  };
5292
5395
  const stateWithNewTab = openTab(newState, targetGroupId, newTab);
5293
-
5294
- // Calculate bounds: use main area bounds minus tab height
5295
- const bounds = {
5296
- height: stateWithNewTab.height - stateWithNewTab.tabHeight,
5297
- width: stateWithNewTab.width,
5298
- x: stateWithNewTab.x,
5299
- y: stateWithNewTab.y + stateWithNewTab.tabHeight
5300
- };
5396
+ const bounds = getSelectedTabBounds(stateWithNewTab, targetGroupId);
5301
5397
  const viewletModuleId = EditorText;
5302
5398
  const stateWithViewlet = createViewletForTab(stateWithNewTab, tabId);
5303
5399
  let intermediateState = stateWithViewlet;
@@ -5402,8 +5498,6 @@ const handleIconThemeChange = async state => {
5402
5498
  };
5403
5499
  };
5404
5500
 
5405
- const RendererWorkerCallbackDelay = 50;
5406
- const commandsWithDeferredRender = new Set(['handleContextMenu', 'handleTabContextMenu']);
5407
5501
  const handleMessagePort = async (port, viewletCommandMap, setAsRendererProcessFallback = true) => {
5408
5502
  const executeViewletCommand = async (uid, command, ...args) => {
5409
5503
  const fn = viewletCommandMap[`MainArea.${command}`];
@@ -5411,12 +5505,6 @@ const handleMessagePort = async (port, viewletCommandMap, setAsRendererProcessFa
5411
5505
  throw new TypeError(`Viewlet command not found: ${command}`);
5412
5506
  }
5413
5507
  await fn(uid, ...args);
5414
- if (commandsWithDeferredRender.has(command)) {
5415
- setTimeout(() => {
5416
- void invoke$1('Viewlet.requestRender', uid);
5417
- }, RendererWorkerCallbackDelay);
5418
- return;
5419
- }
5420
5508
  await invoke$1('Viewlet.requestRender', uid);
5421
5509
  };
5422
5510
  const rpc = await create$8({
@@ -5472,13 +5560,6 @@ const resizeChild = async (editorUid, dimensions) => {
5472
5560
  }
5473
5561
  };
5474
5562
  const handleResize = async (state, dimensions) => {
5475
- const {
5476
- height,
5477
- width,
5478
- x,
5479
- y
5480
- } = dimensions;
5481
-
5482
5563
  // Resize all editor children to their new bounds
5483
5564
  const {
5484
5565
  layout,
@@ -5487,20 +5568,24 @@ const handleResize = async (state, dimensions) => {
5487
5568
  const {
5488
5569
  groups
5489
5570
  } = layout;
5490
- const contentHeight = height - tabHeight;
5571
+ const groupBounds = getEditorGroupContentBounds(layout, dimensions, tabHeight);
5491
5572
  const resizePromises = [];
5492
- const tabs = groups.flatMap(group => group.tabs);
5493
- for (const tab of tabs) {
5494
- if (tab.editorUid === -1) {
5573
+ for (const group of groups) {
5574
+ const bounds = groupBounds.find(item => item.groupId === group.id);
5575
+ if (!bounds) {
5495
5576
  continue;
5496
5577
  }
5497
- const resizePromise = resizeChild(tab.editorUid, {
5498
- height: contentHeight,
5499
- width,
5500
- x,
5501
- y: y + tabHeight
5502
- });
5503
- resizePromises.push(resizePromise);
5578
+ const dimensions = {
5579
+ height: bounds.height,
5580
+ width: bounds.width,
5581
+ x: bounds.x,
5582
+ y: bounds.y
5583
+ };
5584
+ for (const tab of group.tabs) {
5585
+ if (tab.editorUid !== -1) {
5586
+ resizePromises.push(resizeChild(tab.editorUid, dimensions));
5587
+ }
5588
+ }
5504
5589
  }
5505
5590
  const resizeCommands = await Promise.all(resizePromises);
5506
5591
  return resizeCommands.flat();
@@ -5801,7 +5886,6 @@ const handleSashPointerUp = async state => {
5801
5886
  };
5802
5887
  };
5803
5888
 
5804
- const RendererWorkerForwardDelay = 50;
5805
5889
  const handleTabContextMenu = async (state, button, x, y, groupIndexRaw = '', tabIndexRaw = '') => {
5806
5890
  number(x);
5807
5891
  number(y);
@@ -5816,15 +5900,6 @@ const handleTabContextMenu = async (state, button, x, y, groupIndexRaw = '', tab
5816
5900
  groupId: group.id,
5817
5901
  tabId: tab.id
5818
5902
  } : {};
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
5903
  await show2(uid, Tab, x, y, {
5829
5904
  menuId: Tab,
5830
5905
  ...target
@@ -5832,6 +5907,77 @@ const handleTabContextMenu = async (state, button, x, y, groupIndexRaw = '', tab
5832
5907
  return state;
5833
5908
  };
5834
5909
 
5910
+ const getFocusIndex = (key, index, tabCount) => {
5911
+ switch (key) {
5912
+ case 'ArrowLeft':
5913
+ return (index + tabCount - 1) % tabCount;
5914
+ case 'ArrowRight':
5915
+ return (index + 1) % tabCount;
5916
+ case 'End':
5917
+ return tabCount - 1;
5918
+ case 'Home':
5919
+ return 0;
5920
+ default:
5921
+ return -1;
5922
+ }
5923
+ };
5924
+ const focusTab = async (state, groupIndex, index) => {
5925
+ const selector = `.${MainTab}[data-group-index="${groupIndex}"][data-index="${index}"]`;
5926
+ if (isConnected()) {
5927
+ await invoke('Viewlet.focusSelector', state.uid, selector);
5928
+ } else {
5929
+ await invoke$1('Viewlet.focusSelector', state.uid, selector);
5930
+ }
5931
+ };
5932
+ const handleTabKeyDown = async (state, groupIndexRaw, indexRaw, key) => {
5933
+ if (!groupIndexRaw || !indexRaw) {
5934
+ return state;
5935
+ }
5936
+ const groupIndex = Number.parseInt(groupIndexRaw);
5937
+ const index = Number.parseInt(indexRaw);
5938
+ const group = state.layout.groups[groupIndex];
5939
+ if (!group || index < 0 || index >= group.tabs.length) {
5940
+ return state;
5941
+ }
5942
+ if ([' ', 'Enter', 'Space'].includes(key)) {
5943
+ return selectTab(state, groupIndex, index);
5944
+ }
5945
+ const focusIndex = getFocusIndex(key, index, group.tabs.length);
5946
+ if (focusIndex === -1) {
5947
+ return state;
5948
+ }
5949
+ await focusTab(state, groupIndex, focusIndex);
5950
+ return state;
5951
+ };
5952
+
5953
+ const getPixelDelta = (state, deltaMode, deltaY) => {
5954
+ switch (deltaMode) {
5955
+ case 1:
5956
+ return deltaY * 16;
5957
+ case 2:
5958
+ return deltaY * state.width;
5959
+ default:
5960
+ return deltaY;
5961
+ }
5962
+ };
5963
+ const handleTabsWheel = async (state, groupIndexRaw, deltaMode, deltaY) => {
5964
+ if (!groupIndexRaw || deltaY === 0) {
5965
+ return state;
5966
+ }
5967
+ const groupIndex = Number.parseInt(groupIndexRaw);
5968
+ if (!state.layout.groups[groupIndex]) {
5969
+ return state;
5970
+ }
5971
+ const selector = `.${MainTabs}[data-group-index="${groupIndex}"]`;
5972
+ const pixelDelta = getPixelDelta(state, deltaMode, deltaY);
5973
+ if (isConnected()) {
5974
+ await invoke('Viewlet.scrollSelectorBy', state.uid, selector, pixelDelta);
5975
+ } else {
5976
+ await invoke$1('Viewlet.scrollSelectorBy', state.uid, selector, pixelDelta);
5977
+ }
5978
+ return state;
5979
+ };
5980
+
5835
5981
  const handleUriChange = async (state, oldUri, newUri) => {
5836
5982
  const {
5837
5983
  homeDirUri,
@@ -6003,7 +6149,10 @@ const tryRestoreLayout = savedState => {
6003
6149
  return normalizedLayout;
6004
6150
  };
6005
6151
 
6006
- const createViewlets = async (layout, viewletModuleIds, bounds) => {
6152
+ const createViewlets = async (state, viewletModuleIds) => {
6153
+ const {
6154
+ layout
6155
+ } = state;
6007
6156
  const {
6008
6157
  groups
6009
6158
  } = layout;
@@ -6014,7 +6163,8 @@ const createViewlets = async (layout, viewletModuleIds, bounds) => {
6014
6163
  if (activeTab && viewletModuleIds[activeTab.id]) {
6015
6164
  const editorUid = activeTab.editorUid === -1 ? create$2() : activeTab.editorUid;
6016
6165
  editorUids[activeTab.id] = editorUid;
6017
- const title = await createViewlet(viewletModuleIds[activeTab.id], editorUid, activeTab.id, bounds, activeTab.uri);
6166
+ const bounds = getSelectedTabBounds(state, group.id);
6167
+ const title = await createViewlet(viewletModuleIds[activeTab.id], editorUid, activeTab.id, bounds, activeTab.uri || '');
6018
6168
  if (title) {
6019
6169
  titles[activeTab.id] = title;
6020
6170
  }
@@ -6088,19 +6238,10 @@ const updateTabs = (state, editorUids) => {
6088
6238
  };
6089
6239
 
6090
6240
  const restoreAndCreateEditors = async (state, restoredLayout) => {
6091
- const {
6092
- tabHeight
6093
- } = state;
6094
6241
  let newState = {
6095
6242
  ...state,
6096
6243
  layout: restoredLayout
6097
6244
  };
6098
- const bounds = {
6099
- height: newState.height - tabHeight,
6100
- width: newState.width,
6101
- x: newState.x,
6102
- y: newState.y + tabHeight
6103
- };
6104
6245
 
6105
6246
  // Get viewlet module IDs for all active tabs
6106
6247
  const viewletModuleIds = await getViewletModuleIds(newState.layout);
@@ -6109,7 +6250,7 @@ const restoreAndCreateEditors = async (state, restoredLayout) => {
6109
6250
  const {
6110
6251
  editorUids,
6111
6252
  titles
6112
- } = await createViewlets(newState.layout, viewletModuleIds, bounds);
6253
+ } = await createViewlets(newState, viewletModuleIds);
6113
6254
 
6114
6255
  // Update tabs with editor UIDs
6115
6256
  newState = updateTabs(newState, editorUids);
@@ -6119,6 +6260,7 @@ const restoreAndCreateEditors = async (state, restoredLayout) => {
6119
6260
  const activeTab = group.tabs.find(tab => tab.id === group.activeTabId);
6120
6261
  if (activeTab && viewletModuleIds[activeTab.id]) {
6121
6262
  const editorUid = editorUids[activeTab.id];
6263
+ getSelectedTabBounds(newState, group.id);
6122
6264
  newState = createViewletForTab(newState, activeTab.id);
6123
6265
  newState = handleViewletReady(newState, editorUid, titles[activeTab.id]);
6124
6266
  }
@@ -6642,6 +6784,24 @@ const refresh = state => {
6642
6784
  };
6643
6785
  };
6644
6786
 
6787
+ const renderActiveTabVisibility = (oldState, newState) => {
6788
+ const {
6789
+ activeGroupId,
6790
+ groups
6791
+ } = newState.layout;
6792
+ const groupIndex = groups.findIndex(group => group.id === activeGroupId);
6793
+ if (groupIndex === -1) {
6794
+ return [];
6795
+ }
6796
+ const group = groups[groupIndex];
6797
+ const tabIndex = group.tabs.findIndex(tab => tab.id === group.activeTabId);
6798
+ if (tabIndex === -1) {
6799
+ return [];
6800
+ }
6801
+ const selector = `.${MainTab}[data-group-index="${groupIndex}"][data-index="${tabIndex}"]`;
6802
+ return ['Viewlet.scrollSelectorIntoView', newState.uid, selector];
6803
+ };
6804
+
6645
6805
  const getDragOverlayCss = dragOverlay => {
6646
6806
  if (!dragOverlay) {
6647
6807
  return [];
@@ -7115,6 +7275,8 @@ const HandleDrop = 25;
7115
7275
  const HandleDragStart = 26;
7116
7276
  const HandleDragEnd = 27;
7117
7277
  const HandleTabMouseUp = 28;
7278
+ const HandleTabKeyDown = 29;
7279
+ const HandleTabsWheel = 30;
7118
7280
 
7119
7281
  const dragOverlayVirtualDom = {
7120
7282
  childCount: 0,
@@ -7343,9 +7505,11 @@ const renderTab = (tab, isActive, tabIndex, groupIndex) => {
7343
7505
  onDblClick: HandleDoubleClick,
7344
7506
  onDragEnd: HandleDragEnd,
7345
7507
  onDragStart: HandleDragStart,
7508
+ onKeyDown: HandleTabKeyDown,
7346
7509
  onMouseDown: HandleClickTab,
7347
7510
  onMouseUp: HandleTabMouseUp,
7348
7511
  role: Tab$1,
7512
+ tabIndex: isActive ? 0 : -1,
7349
7513
  title: tab.uriTitle || tab.uri || tab.title,
7350
7514
  type: Div
7351
7515
  }, ...renderTabIcon(tab), tabTitleNode, text(tab.title), ...closeButtonNodes];
@@ -7355,6 +7519,8 @@ const getTabsVirtualDom = (group, groupIndex, tabsChildCount) => {
7355
7519
  return [{
7356
7520
  childCount: tabsChildCount,
7357
7521
  className: MainTabs,
7522
+ 'data-groupIndex': groupIndex,
7523
+ onWheel: HandleTabsWheel,
7358
7524
  role: TabList,
7359
7525
  type: Div
7360
7526
  }, ...group.tabs.flatMap((tab, tabIndex) => renderTab(tab, tab.id === group.activeTabId, tabIndex, groupIndex))];
@@ -7715,6 +7881,8 @@ const renderPendingViewletUpdate = (oldState, newState) => {
7715
7881
 
7716
7882
  const getRenderer = diffType => {
7717
7883
  switch (diffType) {
7884
+ case RenderActiveTabVisibility:
7885
+ return renderActiveTabVisibility;
7718
7886
  case RenderCss:
7719
7887
  return renderCss;
7720
7888
  case RenderDragData:
@@ -7767,10 +7935,17 @@ const renderEventListeners = () => {
7767
7935
  params: ['handleClick', TargetName]
7768
7936
  }, {
7769
7937
  name: HandleClickClose,
7770
- params: ['handleClickCloseTab', 'event.target.dataset.groupIndex', 'event.target.dataset.index']
7938
+ params: ['handleClickCloseTab', 'event.currentTarget.dataset.groupIndex', 'event.currentTarget.dataset.index'],
7939
+ stopPropagation: true
7771
7940
  }, {
7772
7941
  name: HandleClickTab,
7773
- params: ['handleClickTab', 'event.target.dataset.groupIndex', 'event.target.dataset.index', Button$1]
7942
+ params: ['handleClickTab', 'event.currentTarget.dataset.groupIndex', 'event.currentTarget.dataset.index', Button$1]
7943
+ }, {
7944
+ name: HandleTabKeyDown,
7945
+ params: ['handleTabKeyDown', 'event.currentTarget.dataset.groupIndex', 'event.currentTarget.dataset.index', Key]
7946
+ }, {
7947
+ name: HandleTabsWheel,
7948
+ params: ['handleTabsWheel', 'event.currentTarget.dataset.groupIndex', DeltaMode, DeltaY]
7774
7949
  }, {
7775
7950
  name: HandleDoubleClick,
7776
7951
  params: ['handleDoubleClick', 'event.target.dataset.groupIndex', 'event.target.dataset.index']
@@ -7910,12 +8085,7 @@ const reopenEditorWith = async (context, preferredEditorId) => {
7910
8085
  errorMessage: undefined,
7911
8086
  loadingState: undefined
7912
8087
  });
7913
- const bounds = {
7914
- height: resetState.height - resetState.tabHeight,
7915
- width: resetState.width,
7916
- x: resetState.x,
7917
- y: resetState.y + resetState.tabHeight
7918
- };
8088
+ const bounds = getSelectedTabBounds(resetState, latestTab.groupId);
7919
8089
  const stateWithViewlet = createViewletForTab(resetState, initialTab.id);
7920
8090
  await context.updateState(() => stateWithViewlet);
7921
8091
  const tabWithViewlet = findTabById(stateWithViewlet, initialTab.id);
@@ -8375,7 +8545,9 @@ const commandMap = {
8375
8545
  'MainArea.handleSashPointerMove': wrapSerialCommand(handleSashPointerMove),
8376
8546
  'MainArea.handleSashPointerUp': wrapSerialCommand(handleSashPointerUp),
8377
8547
  'MainArea.handleTabContextMenu': wrapSerialCommand(handleTabContextMenu),
8548
+ 'MainArea.handleTabKeyDown': wrapSerialCommand(handleTabKeyDown),
8378
8549
  'MainArea.handleTabMouseUp': wrapSerialCommand(resetPointerDown),
8550
+ 'MainArea.handleTabsWheel': wrapSerialCommand(handleTabsWheel),
8379
8551
  'MainArea.handleTestWorkerMessagePort': handleTestWorkerMessagePort,
8380
8552
  'MainArea.handleUriChange': wrapSerialCommand(handleUriChange),
8381
8553
  'MainArea.handleWorkspaceChange': wrapSerialCommand(handleWorkspaceChange),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-area-worker",
3
- "version": "9.50.0",
3
+ "version": "9.51.0",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",