@lvce-editor/main-area-worker 9.55.1 → 9.56.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.
@@ -1384,175 +1384,15 @@ const Tab$1 = 'tab';
1384
1384
  const TabList = 'tablist';
1385
1385
  const ToolBar = 'toolbar';
1386
1386
 
1387
- const Audio = 0;
1388
1387
  const Button$2 = 1;
1389
- const Col = 2;
1390
- const ColGroup = 3;
1391
1388
  const Div = 4;
1392
- const H1 = 5;
1393
- const Input = 6;
1394
- const Kbd = 7;
1395
1389
  const Span = 8;
1396
- const Table = 9;
1397
- const TBody = 10;
1398
- const Td = 11;
1399
1390
  const Text = 12;
1400
- const Th = 13;
1401
- const THead = 14;
1402
- const Tr = 15;
1403
- const I = 16;
1404
1391
  const Img = 17;
1405
- const Root = 0;
1406
- const Ins = 20;
1407
- const Del = 21;
1408
- const H2 = 22;
1409
- const H3 = 23;
1410
- const H4 = 24;
1411
- const H5 = 25;
1412
- const H6 = 26;
1413
- const Article = 27;
1414
- const Aside = 28;
1415
- const Footer = 29;
1416
- const Header = 30;
1417
- const Nav = 40;
1418
- const Section = 41;
1419
- const Search = 42;
1420
- const Dd = 43;
1421
- const Dl = 44;
1422
- const Figcaption = 45;
1423
- const Figure = 46;
1424
- const Hr = 47;
1425
- const Li = 48;
1426
- const Ol = 49;
1427
1392
  const P = 50;
1428
1393
  const Pre = 51;
1429
- const A = 53;
1430
- const Abbr = 54;
1431
- const Br = 55;
1432
- const Cite = 56;
1433
- const Data = 57;
1434
- const Time = 58;
1435
- const Tfoot = 59;
1436
- const Ul = 60;
1437
- const Video = 61;
1438
- const TextArea = 62;
1439
- const Select = 63;
1440
- const Option = 64;
1441
- const Code = 65;
1442
- const Label = 66;
1443
- const Dt = 67;
1444
- const Iframe = 68;
1445
- const Main$2 = 69;
1446
- const Strong = 70;
1447
- const Em = 71;
1448
- const Style = 72;
1449
- const Html = 73;
1450
- const Head = 74;
1451
- const Title = 75;
1452
- const Meta = 76;
1453
- const Canvas = 77;
1454
- const Form = 78;
1455
- const BlockQuote = 79;
1456
- const Quote = 80;
1457
- const Circle = 81;
1458
- const Defs = 82;
1459
- const Ellipse = 83;
1460
- const G = 84;
1461
- const Line = 85;
1462
- const Path = 86;
1463
- const Polygon = 87;
1464
- const Polyline = 88;
1465
- const Rect = 89;
1466
- const Svg = 90;
1467
- const Use = 91;
1468
1394
  const Reference = 100;
1469
1395
 
1470
- const VirtualDomElements = {
1471
- __proto__: null,
1472
- A,
1473
- Abbr,
1474
- Article,
1475
- Aside,
1476
- Audio,
1477
- BlockQuote,
1478
- Br,
1479
- Button: Button$2,
1480
- Canvas,
1481
- Circle,
1482
- Cite,
1483
- Code,
1484
- Col,
1485
- ColGroup,
1486
- Data,
1487
- Dd,
1488
- Defs,
1489
- Del,
1490
- Div,
1491
- Dl,
1492
- Dt,
1493
- Ellipse,
1494
- Em,
1495
- Figcaption,
1496
- Figure,
1497
- Footer,
1498
- Form,
1499
- G,
1500
- H1,
1501
- H2,
1502
- H3,
1503
- H4,
1504
- H5,
1505
- H6,
1506
- Head,
1507
- Header,
1508
- Hr,
1509
- Html,
1510
- I,
1511
- Iframe,
1512
- Img,
1513
- Input,
1514
- Ins,
1515
- Kbd,
1516
- Label,
1517
- Li,
1518
- Line,
1519
- Main: Main$2,
1520
- Meta,
1521
- Nav,
1522
- Ol,
1523
- Option,
1524
- P,
1525
- Path,
1526
- Polygon,
1527
- Polyline,
1528
- Pre,
1529
- Quote,
1530
- Rect,
1531
- Reference,
1532
- Root,
1533
- Search,
1534
- Section,
1535
- Select,
1536
- Span,
1537
- Strong,
1538
- Style,
1539
- Svg,
1540
- TBody,
1541
- THead,
1542
- Table,
1543
- Td,
1544
- Text,
1545
- TextArea,
1546
- Tfoot,
1547
- Th,
1548
- Time,
1549
- Title,
1550
- Tr,
1551
- Ul,
1552
- Use,
1553
- Video
1554
- };
1555
-
1556
1396
  const Button$1 = 'event.button';
1557
1397
  const ClientX = 'event.clientX';
1558
1398
  const ClientY = 'event.clientY';
@@ -2726,7 +2566,7 @@ const isEqual$1 = (oldState, newState) => {
2726
2566
  };
2727
2567
 
2728
2568
  const isEqual = (oldState, newState) => {
2729
- return oldState.dragOverlay === newState.dragOverlay && oldState.layout === newState.layout;
2569
+ return oldState.dragOverlay === newState.dragOverlay && oldState.layout === newState.layout && oldState.tabDropIndicator === newState.tabDropIndicator;
2730
2570
  };
2731
2571
 
2732
2572
  const RenderItems = 4;
@@ -2810,6 +2650,7 @@ const focus = async state => {
2810
2650
  return state;
2811
2651
  }
2812
2652
  if (isConnected()) {
2653
+ await invoke('Viewlet.focusSelector', editorUid, '[name="editor"]');
2813
2654
  await invoke('Viewlet.focusSelectorAfterRender', editorUid, '[name="editor"]');
2814
2655
  } else {
2815
2656
  await invoke$1('Viewlet.focusSelector', editorUid, '[name="editor"]');
@@ -3458,6 +3299,10 @@ const getActiveEditorUid = state => {
3458
3299
  return editorUid;
3459
3300
  };
3460
3301
 
3302
+ const getComponentState = uid => {
3303
+ return get(uid).newState;
3304
+ };
3305
+
3461
3306
  const getMenuIds = () => {
3462
3307
  return [Main$1, Tab];
3463
3308
  };
@@ -4094,6 +3939,11 @@ const renderMainAreaPending = async uid => {
4094
3939
  // Older renderer workers render the final state when openInput completes.
4095
3940
  }
4096
3941
  };
3942
+ const focusIfRequested = async (state, shouldFocus) => {
3943
+ if (shouldFocus) {
3944
+ await focus(state);
3945
+ }
3946
+ };
4097
3947
  const getExistingTabState = (state, existingTab, preview) => {
4098
3948
  const focusedState = focusEditorGroup(state, existingTab.groupId);
4099
3949
  const pinnedState = !preview && existingTab.tab.isPreview ? updateTab(focusedState, existingTab.tab.id, {
@@ -4136,6 +3986,7 @@ const openInputWithContext = async (context, options) => {
4136
3986
  if (existingTab && !shouldRetry) {
4137
3987
  const switchedState = getExistingTabState(currentState, existingTab, preview);
4138
3988
  await context.updateState(() => switchedState);
3989
+ await focusIfRequested(switchedState, options.focus);
4139
3990
  return;
4140
3991
  }
4141
3992
  const replacedEditorUid = getActivePreviewEditorUid(currentState);
@@ -4201,6 +4052,7 @@ const openInputWithContext = async (context, options) => {
4201
4052
  let readyState = handleViewletReady(latestState, editorUid);
4202
4053
  await context.updateState(() => readyState);
4203
4054
  await renderMainAreaPending(state.uid);
4055
+ await focusIfRequested(context.getState(), options.focus);
4204
4056
  const renderedTitle = await getViewletTitle(editorUid);
4205
4057
  if (renderedTitle) {
4206
4058
  readyState = handleViewletReady(context.getState(), editorUid, renderedTitle);
@@ -4817,14 +4669,16 @@ const handleDoubleClick = (state, groupIndexRaw, indexRaw) => {
4817
4669
 
4818
4670
  const handleDragLeave = state => {
4819
4671
  const {
4820
- dragOverlay
4672
+ dragOverlay,
4673
+ tabDropIndicator
4821
4674
  } = state;
4822
- if (!dragOverlay) {
4675
+ if (!dragOverlay && !tabDropIndicator) {
4823
4676
  return state;
4824
4677
  }
4825
4678
  return {
4826
4679
  ...state,
4827
- dragOverlay: undefined
4680
+ dragOverlay: undefined,
4681
+ tabDropIndicator: undefined
4828
4682
  };
4829
4683
  };
4830
4684
 
@@ -4949,32 +4803,93 @@ const isDragOverlayEqual = (oldOverlay, newOverlay) => {
4949
4803
  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;
4950
4804
  };
4951
4805
 
4952
- const handleDragOver = (state, eventX, eventY) => {
4806
+ const handleEditorDragOver = (state, eventX, eventY) => {
4953
4807
  const {
4954
4808
  dragOverlay: oldDragOverlay
4955
4809
  } = state;
4956
4810
  const dragOverlay = getDragOverlay(state, eventX, eventY);
4957
- if (isDragOverlayEqual(oldDragOverlay, dragOverlay)) {
4811
+ if (isDragOverlayEqual(oldDragOverlay, dragOverlay) && !state.tabDropIndicator) {
4958
4812
  return state;
4959
4813
  }
4960
4814
  return {
4961
4815
  ...state,
4962
- dragOverlay
4816
+ dragOverlay,
4817
+ tabDropIndicator: undefined
4963
4818
  };
4964
4819
  };
4965
4820
 
4821
+ const hasDraggedTab = state => {
4822
+ const {
4823
+ pointerDownGroupIndex,
4824
+ pointerDownTabIndex
4825
+ } = state;
4826
+ return Boolean(state.layout.groups[pointerDownGroupIndex]?.tabs[pointerDownTabIndex]);
4827
+ };
4828
+ const withTabDropIndicator = (state, tabDropIndicator) => {
4829
+ const oldIndicator = state.tabDropIndicator;
4830
+ if (!state.dragOverlay && oldIndicator?.groupId === tabDropIndicator.groupId && oldIndicator.index === tabDropIndicator.index) {
4831
+ return state;
4832
+ }
4833
+ return {
4834
+ ...state,
4835
+ dragOverlay: undefined,
4836
+ tabDropIndicator
4837
+ };
4838
+ };
4839
+ const handleTabDragOver = (state, groupIndexRaw, tabIndexRaw, tabOffsetLeft, tabWidth, tabsScrollLeft, clientX, clientY) => {
4840
+ if (!hasDraggedTab(state)) {
4841
+ return handleEditorDragOver(state, clientX, clientY);
4842
+ }
4843
+ const groupIndex = Number.parseInt(groupIndexRaw);
4844
+ const tabIndex = Number.parseInt(tabIndexRaw);
4845
+ const group = state.layout.groups[groupIndex];
4846
+ if (!group || tabIndex < 0 || tabIndex >= group.tabs.length) {
4847
+ return state;
4848
+ }
4849
+ const groupBounds = getEditorGroupBounds(state.layout, state.width, state.height)[groupIndex];
4850
+ const tabMidpoint = state.x + groupBounds.x + tabOffsetLeft - tabsScrollLeft + tabWidth / 2;
4851
+ const index = clientX < tabMidpoint ? tabIndex : tabIndex + 1;
4852
+ return withTabDropIndicator(state, {
4853
+ groupId: group.id,
4854
+ index
4855
+ });
4856
+ };
4857
+ const handleTabsDragOver = (state, groupIndexRaw, clientX, clientY) => {
4858
+ if (!hasDraggedTab(state)) {
4859
+ return handleEditorDragOver(state, clientX, clientY);
4860
+ }
4861
+ const groupIndex = Number.parseInt(groupIndexRaw);
4862
+ const group = state.layout.groups[groupIndex];
4863
+ if (!group) {
4864
+ return state;
4865
+ }
4866
+ return withTabDropIndicator(state, {
4867
+ groupId: group.id,
4868
+ index: group.tabs.length
4869
+ });
4870
+ };
4871
+
4872
+ const handleDragOver = (state, eventX, eventY, groupIndexRaw, tabIndexRaw, tabOffsetLeft, tabWidth, tabsScrollLeft) => {
4873
+ if (groupIndexRaw !== undefined && tabIndexRaw !== undefined && tabOffsetLeft !== undefined && tabWidth !== undefined && tabsScrollLeft !== undefined) {
4874
+ return handleTabDragOver(state, groupIndexRaw, tabIndexRaw, tabOffsetLeft, tabWidth, tabsScrollLeft, eventX, eventY);
4875
+ }
4876
+ return handleEditorDragOver(state, eventX, eventY);
4877
+ };
4878
+
4966
4879
  const handleDragStart = state => {
4967
4880
  return state;
4968
4881
  };
4969
4882
 
4970
4883
  const resetPointerDown = state => {
4971
- if (state.pointerDownGroupIndex === -1 && state.pointerDownTabIndex === -1) {
4884
+ if (state.pointerDownGroupIndex === -1 && state.pointerDownTabIndex === -1 && !state.dragOverlay && !state.tabDropIndicator) {
4972
4885
  return state;
4973
4886
  }
4974
4887
  return {
4975
4888
  ...state,
4889
+ dragOverlay: undefined,
4976
4890
  pointerDownGroupIndex: -1,
4977
- pointerDownTabIndex: -1
4891
+ pointerDownTabIndex: -1,
4892
+ tabDropIndicator: undefined
4978
4893
  };
4979
4894
  };
4980
4895
 
@@ -5179,13 +5094,37 @@ const moveTabToGroup = (state, sourceGroupId, targetGroupId, tabId, targetIndex)
5179
5094
  } = layout;
5180
5095
  const sourceGroup = groups.find(group => group.id === sourceGroupId);
5181
5096
  const hasTargetGroup = groups.some(group => group.id === targetGroupId);
5182
- if (!sourceGroup || !hasTargetGroup || sourceGroupId === targetGroupId) {
5097
+ if (!sourceGroup || !hasTargetGroup) {
5183
5098
  return state;
5184
5099
  }
5185
5100
  const tabToMove = sourceGroup.tabs.find(tab => tab.id === tabId);
5186
5101
  if (!tabToMove) {
5187
5102
  return state;
5188
5103
  }
5104
+ if (sourceGroupId === targetGroupId) {
5105
+ if (targetIndex === undefined) {
5106
+ return state;
5107
+ }
5108
+ const sourceIndex = sourceGroup.tabs.findIndex(tab => tab.id === tabId);
5109
+ const insertionBoundary = Math.min(Math.max(targetIndex, 0), sourceGroup.tabs.length);
5110
+ const insertionIndex = insertionBoundary > sourceIndex ? insertionBoundary - 1 : insertionBoundary;
5111
+ if (insertionIndex === sourceIndex) {
5112
+ return state;
5113
+ }
5114
+ const tabs = sourceGroup.tabs.filter(tab => tab.id !== tabId);
5115
+ tabs.splice(insertionIndex, 0, tabToMove);
5116
+ return {
5117
+ ...state,
5118
+ layout: {
5119
+ ...layout,
5120
+ activeGroupId: targetGroupId,
5121
+ groups: groups.map(group => group.id === targetGroupId ? {
5122
+ ...group,
5123
+ tabs
5124
+ } : group)
5125
+ }
5126
+ };
5127
+ }
5189
5128
  const updatedGroups = groups.map(group => {
5190
5129
  if (group.id === sourceGroupId) {
5191
5130
  const newTabs = group.tabs.filter(tab => tab.id !== tabId);
@@ -5206,7 +5145,7 @@ const moveTabToGroup = (state, sourceGroupId, targetGroupId, tabId, targetIndex)
5206
5145
  };
5207
5146
  }
5208
5147
  if (group.id === targetGroupId) {
5209
- const insertIndex = group.tabs.length ;
5148
+ const insertIndex = targetIndex === undefined ? group.tabs.length : Math.min(Math.max(targetIndex, 0), group.tabs.length);
5210
5149
  const newTabs = [...group.tabs];
5211
5150
  newTabs.splice(insertIndex, 0, tabToMove);
5212
5151
  return {
@@ -5231,12 +5170,12 @@ const moveTabToGroup = (state, sourceGroupId, targetGroupId, tabId, targetIndex)
5231
5170
  const getOpenTabCount = state => {
5232
5171
  return state.layout.groups.reduce((count, group) => count + group.tabs.length, 0);
5233
5172
  };
5234
- const applyTabDrop = (state, sourceGroupId, tabId, splitDirection, targetGroupId) => {
5173
+ const applyTabDrop = (state, sourceGroupId, tabId, splitDirection, targetGroupId, targetIndex) => {
5235
5174
  if (targetGroupId === undefined) {
5236
5175
  return state;
5237
5176
  }
5238
5177
  if (splitDirection === None) {
5239
- return moveTabToGroup(state, sourceGroupId, targetGroupId, tabId);
5178
+ return moveTabToGroup(state, sourceGroupId, targetGroupId, tabId, targetIndex);
5240
5179
  }
5241
5180
  if (getOpenTabCount(state) === 1) {
5242
5181
  return state;
@@ -5284,6 +5223,9 @@ const handleDrop = async (context, dropId) => {
5284
5223
  splitDirection = None,
5285
5224
  targetGroupId
5286
5225
  } = initialState.dragOverlay ?? {};
5226
+ const {
5227
+ tabDropIndicator
5228
+ } = initialState;
5287
5229
  await context.updateState(handleDragLeave);
5288
5230
  const {
5289
5231
  platform
@@ -5291,7 +5233,9 @@ const handleDrop = async (context, dropId) => {
5291
5233
  const isElectron = platform === Electron;
5292
5234
  const uris = await getDroppedUrisByDropId(dropId, isElectron);
5293
5235
  if (draggedTab?.uri && uris.length === 1 && normalizeUri(uris[0]) === normalizeUri(draggedTab.uri)) {
5294
- await context.updateState(state => resetPointerDown(applyTabDrop(state, sourceGroup.id, draggedTab.id, splitDirection, targetGroupId)));
5236
+ const tabTargetGroupId = tabDropIndicator?.groupId ?? targetGroupId;
5237
+ const tabTargetIndex = tabDropIndicator?.index;
5238
+ await context.updateState(state => resetPointerDown(applyTabDrop(state, sourceGroup.id, draggedTab.id, splitDirection, tabTargetGroupId, tabTargetIndex)));
5295
5239
  return;
5296
5240
  }
5297
5241
  const actions = await getDropAction(uris);
@@ -7082,8 +7026,6 @@ const text = data => {
7082
7026
  };
7083
7027
  };
7084
7028
 
7085
- new Set(Object.values(VirtualDomElements));
7086
-
7087
7029
  const SetText = 1;
7088
7030
  const Replace = 2;
7089
7031
  const SetAttribute = 3;
@@ -7094,6 +7036,7 @@ const NavigateParent = 8;
7094
7036
  const RemoveChild = 9;
7095
7037
  const NavigateSibling = 10;
7096
7038
  const SetReferenceNodeUid = 11;
7039
+ const MultiNavigation = 18;
7097
7040
 
7098
7041
  const isKey = key => {
7099
7042
  return key !== 'type' && key !== 'childCount';
@@ -7154,6 +7097,55 @@ const getChildrenWithCount = (nodes, startIndex, childCount) => {
7154
7097
  };
7155
7098
  };
7156
7099
 
7100
+ const isNavigationPatch = patch => {
7101
+ switch (patch.type) {
7102
+ case NavigateChild:
7103
+ case NavigateParent:
7104
+ case NavigateSibling:
7105
+ return true;
7106
+ default:
7107
+ return false;
7108
+ }
7109
+ };
7110
+ const getNavigationIndex = patch => {
7111
+ switch (patch.type) {
7112
+ case NavigateChild:
7113
+ case NavigateSibling:
7114
+ return patch.index;
7115
+ default:
7116
+ return 0;
7117
+ }
7118
+ };
7119
+ const appendNavigationPatch = (patches, type, index) => {
7120
+ const previousPatch = patches.at(-1);
7121
+ if (!previousPatch) {
7122
+ patches.push(type === NavigateParent ? {
7123
+ type
7124
+ } : {
7125
+ index,
7126
+ type
7127
+ });
7128
+ return;
7129
+ }
7130
+ if (previousPatch.type === MultiNavigation) {
7131
+ previousPatch.navigations.push(type, index);
7132
+ return;
7133
+ }
7134
+ if (isNavigationPatch(previousPatch)) {
7135
+ patches[patches.length - 1] = {
7136
+ navigations: [previousPatch.type, getNavigationIndex(previousPatch), type, index],
7137
+ type: MultiNavigation
7138
+ };
7139
+ return;
7140
+ }
7141
+ patches.push(type === NavigateParent ? {
7142
+ type
7143
+ } : {
7144
+ index,
7145
+ type
7146
+ });
7147
+ };
7148
+
7157
7149
  const compareNodes = (oldNode, newNode) => {
7158
7150
  // Check if node type changed - return null to signal incompatible nodes
7159
7151
  // (caller should handle this with a Replace operation)
@@ -7218,25 +7210,17 @@ const treeToArray = node => {
7218
7210
 
7219
7211
  const navigateToChild = (patches, currentChildIndex, index) => {
7220
7212
  if (currentChildIndex === -1) {
7221
- patches.push({
7222
- type: NavigateChild,
7223
- index
7224
- });
7213
+ appendNavigationPatch(patches, NavigateChild, index);
7225
7214
  return index;
7226
7215
  }
7227
7216
  if (currentChildIndex !== index) {
7228
- patches.push({
7229
- type: NavigateSibling,
7230
- index
7231
- });
7217
+ appendNavigationPatch(patches, NavigateSibling, index);
7232
7218
  }
7233
7219
  return index;
7234
7220
  };
7235
7221
  const navigateToParent = (patches, currentChildIndex) => {
7236
7222
  if (currentChildIndex >= 0) {
7237
- patches.push({
7238
- type: NavigateParent
7239
- });
7223
+ appendNavigationPatch(patches, NavigateParent, 0);
7240
7224
  }
7241
7225
  return -1;
7242
7226
  };
@@ -7252,6 +7236,29 @@ const replaceTree = (newNode, patches) => {
7252
7236
  nodes: treeToArray(newNode)
7253
7237
  });
7254
7238
  };
7239
+ const appendPatch = (patches, patch) => {
7240
+ switch (patch.type) {
7241
+ case MultiNavigation:
7242
+ for (let i = 0; i < patch.navigations.length; i += 2) {
7243
+ appendNavigationPatch(patches, patch.navigations[i], patch.navigations[i + 1]);
7244
+ }
7245
+ return;
7246
+ case NavigateChild:
7247
+ case NavigateSibling:
7248
+ appendNavigationPatch(patches, patch.type, patch.index);
7249
+ return;
7250
+ case NavigateParent:
7251
+ appendNavigationPatch(patches, patch.type, 0);
7252
+ return;
7253
+ default:
7254
+ patches.push(patch);
7255
+ }
7256
+ };
7257
+ const appendPatches = (patches, newPatches) => {
7258
+ for (const patch of newPatches) {
7259
+ appendPatch(patches, patch);
7260
+ }
7261
+ };
7255
7262
  const diffExistingChild = (oldNode, newNode, patches, currentChildIndex, index) => {
7256
7263
  const nodePatches = compareNodes(oldNode.node, newNode.node);
7257
7264
  if (nodePatches === null) {
@@ -7260,16 +7267,16 @@ const diffExistingChild = (oldNode, newNode, patches, currentChildIndex, index)
7260
7267
  return nextChildIndex;
7261
7268
  }
7262
7269
  const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
7263
- if (nodePatches.length === 0 && !hasChildrenToCompare) {
7270
+ const childPatches = [];
7271
+ if (hasChildrenToCompare) {
7272
+ diffChildren(oldNode.children, newNode.children, childPatches);
7273
+ }
7274
+ if (nodePatches.length === 0 && childPatches.length === 0) {
7264
7275
  return currentChildIndex;
7265
7276
  }
7266
7277
  const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
7267
- if (nodePatches.length > 0) {
7268
- patches.push(...nodePatches);
7269
- }
7270
- if (hasChildrenToCompare) {
7271
- diffChildren(oldNode.children, newNode.children, patches);
7272
- }
7278
+ patches.push(...nodePatches);
7279
+ appendPatches(patches, childPatches);
7273
7280
  return nextChildIndex;
7274
7281
  };
7275
7282
  const diffRootNode = (oldNode, newNode, patches) => {
@@ -7325,7 +7332,7 @@ const diffTrees = (oldTree, newTree, patches, path) => {
7325
7332
  const removeTrailingNavigationPatches = patches => {
7326
7333
  while (patches.length > 0) {
7327
7334
  const patch = patches.at(-1);
7328
- if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling) {
7335
+ if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling && patch.type !== MultiNavigation) {
7329
7336
  break;
7330
7337
  }
7331
7338
  patches.pop();
@@ -7366,6 +7373,8 @@ const HandleDragEnd = 27;
7366
7373
  const HandleTabMouseUp = 28;
7367
7374
  const HandleTabKeyDown = 29;
7368
7375
  const HandleTabsWheel = 30;
7376
+ const HandleTabDragOver = 31;
7377
+ const HandleTabsDragOver = 32;
7369
7378
 
7370
7379
  const dragOverlayVirtualDom = {
7371
7380
  childCount: 0,
@@ -7574,7 +7583,16 @@ const renderTabIcon = tab => {
7574
7583
  type: Img
7575
7584
  }];
7576
7585
  };
7577
- const renderTab = (tab, isActive, tabIndex, groupIndex) => {
7586
+ const getDropIndicatorStyle = dropIndicatorPosition => {
7587
+ if (dropIndicatorPosition === 'before') {
7588
+ return 'box-shadow:inset 2px 0 0 white;';
7589
+ }
7590
+ if (dropIndicatorPosition === 'after') {
7591
+ return 'box-shadow:inset -2px 0 0 white;';
7592
+ }
7593
+ return undefined;
7594
+ };
7595
+ const renderTab = (tab, isActive, tabIndex, groupIndex, dropIndicatorPosition) => {
7578
7596
  const closeButtonNodes = renderTabActions(tab.isDirty, tabIndex, groupIndex);
7579
7597
  const tabIconNodes = renderTabIcon(tab);
7580
7598
  let className = MainTab;
@@ -7597,26 +7615,43 @@ const renderTab = (tab, isActive, tabIndex, groupIndex) => {
7597
7615
  onContextMenu: HandleTabContextMenu,
7598
7616
  onDblClick: HandleDoubleClick,
7599
7617
  onDragEnd: HandleDragEnd,
7618
+ onDragOver: HandleTabDragOver,
7600
7619
  onDragStart: HandleDragStart,
7601
7620
  onKeyDown: HandleTabKeyDown,
7602
7621
  onMouseDown: HandleClickTab,
7603
7622
  onMouseUp: HandleTabMouseUp,
7604
7623
  role: Tab$1,
7624
+ ...(dropIndicatorPosition && {
7625
+ style: getDropIndicatorStyle(dropIndicatorPosition)
7626
+ }),
7605
7627
  tabIndex: isActive ? 0 : -1,
7606
7628
  title: tab.uriTitle || tab.uri || tab.title,
7607
7629
  type: Div
7608
7630
  }, ...tabIconNodes, tabTitleNode, text(tab.title), ...closeButtonNodes];
7609
7631
  };
7610
7632
 
7611
- const getTabsVirtualDom = (group, groupIndex, tabsChildCount) => {
7633
+ const getDropIndicatorPosition = (group, tabIndex, tabDropIndicator) => {
7634
+ if (tabDropIndicator?.groupId !== group.id) {
7635
+ return undefined;
7636
+ }
7637
+ if (tabDropIndicator.index === tabIndex) {
7638
+ return 'before';
7639
+ }
7640
+ if (tabDropIndicator.index === group.tabs.length && tabIndex === group.tabs.length - 1) {
7641
+ return 'after';
7642
+ }
7643
+ return undefined;
7644
+ };
7645
+ const getTabsVirtualDom = (group, groupIndex, tabsChildCount, tabDropIndicator) => {
7612
7646
  return [{
7613
7647
  childCount: tabsChildCount,
7614
7648
  className: MainTabs,
7615
7649
  'data-groupIndex': groupIndex,
7650
+ onDragOver: HandleTabsDragOver,
7616
7651
  onWheel: HandleTabsWheel,
7617
7652
  role: TabList,
7618
7653
  type: Div
7619
- }, ...group.tabs.flatMap((tab, tabIndex) => renderTab(tab, tab.id === group.activeTabId, tabIndex, groupIndex))];
7654
+ }, ...group.tabs.flatMap((tab, tabIndex) => renderTab(tab, tab.id === group.activeTabId, tabIndex, groupIndex, getDropIndicatorPosition(group, tabIndex, tabDropIndicator)))];
7620
7655
  };
7621
7656
 
7622
7657
  const isHtmlFile = tab => {
@@ -7672,7 +7707,7 @@ const renderEditorGroupActions = (group, groupIndex, splitButtonEnabled) => {
7672
7707
  }, ...buttons];
7673
7708
  };
7674
7709
 
7675
- const renderEditorGroupHeader = (group, groupIndex, splitButtonEnabled) => {
7710
+ const renderEditorGroupHeader = (group, groupIndex, splitButtonEnabled, tabDropIndicator) => {
7676
7711
  const tabsChildCount = group.tabs.length;
7677
7712
  const actions = renderEditorGroupActions(group, groupIndex, splitButtonEnabled);
7678
7713
  const hasActions = actions.length > 0;
@@ -7682,7 +7717,7 @@ const renderEditorGroupHeader = (group, groupIndex, splitButtonEnabled) => {
7682
7717
  onDblClick: HandleHeaderDoubleClick,
7683
7718
  role: None$2,
7684
7719
  type: Div
7685
- }, ...getTabsVirtualDom(group, groupIndex, tabsChildCount), ...actions];
7720
+ }, ...getTabsVirtualDom(group, groupIndex, tabsChildCount, tabDropIndicator), ...actions];
7686
7721
  };
7687
7722
 
7688
7723
  const emptyHeader = {
@@ -7741,7 +7776,7 @@ const editorContainerNode = {
7741
7776
  className: EditorContainer,
7742
7777
  type: Div
7743
7778
  };
7744
- const renderEditorGroup = (group, groupIndex, splitButtonEnabled = false, sizeProperty = 'width', closeButtonEnabled = true) => {
7779
+ const renderEditorGroup = (group, groupIndex, splitButtonEnabled = false, sizeProperty = 'width', closeButtonEnabled = true, tabDropIndicator) => {
7745
7780
  const activeTab = group.tabs.find(tab => tab.id === group.activeTabId);
7746
7781
  const style = `${sizeProperty}:${group.size}%;`;
7747
7782
  const hasTabs = group.tabs.length > 0;
@@ -7755,7 +7790,7 @@ const renderEditorGroup = (group, groupIndex, splitButtonEnabled = false, sizePr
7755
7790
  'data-groupId': String(group.id),
7756
7791
  style,
7757
7792
  type: Div
7758
- }, ...renderEditorGroupHeader(group, groupIndex, splitButtonEnabled), editorContainerNode, ...renderEditor(activeTab)];
7793
+ }, ...renderEditorGroupHeader(group, groupIndex, splitButtonEnabled, tabDropIndicator), editorContainerNode, ...renderEditor(activeTab)];
7759
7794
  };
7760
7795
 
7761
7796
  const classVertical = 'Sash SashVertical';
@@ -7801,11 +7836,11 @@ const mainNode$1 = {
7801
7836
  onDrop: HandleDrop,
7802
7837
  type: Div
7803
7838
  };
7804
- const renderSingleEditorGroup = (layout, splitButtonEnabled, sizeProperty = 'width') => {
7839
+ const renderSingleEditorGroup = (layout, splitButtonEnabled, sizeProperty = 'width', tabDropIndicator) => {
7805
7840
  const {
7806
7841
  groups
7807
7842
  } = layout;
7808
- return [mainNode$1, ...renderEditorGroup(groups[0], 0, splitButtonEnabled, sizeProperty, false)];
7843
+ return [mainNode$1, ...renderEditorGroup(groups[0], 0, splitButtonEnabled, sizeProperty, false, tabDropIndicator)];
7809
7844
  };
7810
7845
 
7811
7846
  const getDirectionClassName = (direction, isSplit) => {
@@ -7838,7 +7873,7 @@ const addDragOverlay = (dom, dragOverlay) => {
7838
7873
  const getSizeProperty = direction => {
7839
7874
  return direction === Vertical ? 'height' : 'width';
7840
7875
  };
7841
- const renderSegmentChildren = (direction, groups, splitButtonEnabled) => {
7876
+ const renderSegmentChildren = (direction, groups, splitButtonEnabled, tabDropIndicator) => {
7842
7877
  const segments = getGroupSegments(groups, direction);
7843
7878
  const children = [];
7844
7879
  let childCount = 0;
@@ -7854,7 +7889,7 @@ const renderSegmentChildren = (direction, groups, splitButtonEnabled) => {
7854
7889
  childCount++;
7855
7890
  }
7856
7891
  if (segment.direction === undefined) {
7857
- children.push(...renderEditorGroup(segment.groups[0], segment.startIndex, splitButtonEnabled, sizeProperty));
7892
+ children.push(...renderEditorGroup(segment.groups[0], segment.startIndex, splitButtonEnabled, sizeProperty, true, tabDropIndicator));
7858
7893
  childCount++;
7859
7894
  continue;
7860
7895
  }
@@ -7877,7 +7912,7 @@ const renderSegmentChildren = (direction, groups, splitButtonEnabled) => {
7877
7912
  nestedChildren.push(...renderEditorGroup({
7878
7913
  ...group,
7879
7914
  size: normalizedSize
7880
- }, segment.startIndex + j, splitButtonEnabled, nestedSizeProperty));
7915
+ }, segment.startIndex + j, splitButtonEnabled, nestedSizeProperty, true, tabDropIndicator));
7881
7916
  nestedCount++;
7882
7917
  }
7883
7918
  children.push({
@@ -7896,14 +7931,14 @@ const renderSegmentChildren = (direction, groups, splitButtonEnabled) => {
7896
7931
  children
7897
7932
  };
7898
7933
  };
7899
- const getMainAreaVirtualDom = (layout, splitButtonEnabled = false, dragOverlay) => {
7934
+ const getMainAreaVirtualDom = (layout, splitButtonEnabled = false, dragOverlay, tabDropIndicator) => {
7900
7935
  const {
7901
7936
  direction,
7902
7937
  groups
7903
7938
  } = layout;
7904
7939
  const sizeProperty = getSizeProperty(direction);
7905
7940
  if (groups.length === 1) {
7906
- return addDragOverlay(renderSingleEditorGroup(layout, splitButtonEnabled, sizeProperty), dragOverlay);
7941
+ return addDragOverlay(renderSingleEditorGroup(layout, splitButtonEnabled, sizeProperty, tabDropIndicator), dragOverlay);
7907
7942
  }
7908
7943
  const editorGroupsContainerClassName = getContainerClassName(direction, groups.length);
7909
7944
  if (groups.length === 0) {
@@ -7919,7 +7954,7 @@ const getMainAreaVirtualDom = (layout, splitButtonEnabled = false, dragOverlay)
7919
7954
  const {
7920
7955
  childCount,
7921
7956
  children
7922
- } = renderSegmentChildren(direction, groups, splitButtonEnabled);
7957
+ } = renderSegmentChildren(direction, groups, splitButtonEnabled, tabDropIndicator);
7923
7958
  const sashCorner = getSashCorner(layout);
7924
7959
  const sashCornerChildren = sashCorner ? [renderSashCorner()] : [];
7925
7960
  return addDragOverlay([mainNode, {
@@ -7936,12 +7971,13 @@ const renderItems = (oldState, newState) => {
7936
7971
  initial,
7937
7972
  layout,
7938
7973
  splitButtonEnabled,
7974
+ tabDropIndicator,
7939
7975
  uid
7940
7976
  } = newState;
7941
7977
  if (initial) {
7942
7978
  return [SetDom2, uid, []];
7943
7979
  }
7944
- const dom = getMainAreaVirtualDom(layout, splitButtonEnabled, dragOverlay);
7980
+ const dom = getMainAreaVirtualDom(layout, splitButtonEnabled, dragOverlay, tabDropIndicator);
7945
7981
  return [SetDom2, uid, dom];
7946
7982
  };
7947
7983
 
@@ -8039,6 +8075,16 @@ const renderEventListeners = () => {
8039
8075
  }, {
8040
8076
  name: HandleTabsWheel,
8041
8077
  params: ['handleTabsWheel', 'event.currentTarget.dataset.groupIndex', DeltaMode, DeltaY]
8078
+ }, {
8079
+ name: HandleTabDragOver,
8080
+ params: ['handleTabDragOver', 'event.currentTarget.dataset.groupIndex', 'event.currentTarget.dataset.index', 'event.currentTarget.offsetLeft', 'event.currentTarget.offsetWidth', 'event.currentTarget.parentElement.scrollLeft', ClientX, ClientY],
8081
+ preventDefault: true,
8082
+ stopPropagation: true
8083
+ }, {
8084
+ name: HandleTabsDragOver,
8085
+ params: ['handleTabsDragOver', 'event.currentTarget.dataset.groupIndex', ClientX, ClientY],
8086
+ preventDefault: true,
8087
+ stopPropagation: true
8042
8088
  }, {
8043
8089
  name: HandleDoubleClick,
8044
8090
  params: ['handleDoubleClick', 'event.target.dataset.groupIndex', 'event.target.dataset.index']
@@ -8315,6 +8361,31 @@ const saveState = state => {
8315
8361
  };
8316
8362
  };
8317
8363
 
8364
+ const applyComponentState = (currentState, state) => {
8365
+ if (!state || typeof state !== 'object' || Array.isArray(state)) {
8366
+ throw new TypeError('Main Area state must be an object');
8367
+ }
8368
+ const {
8369
+ maxOpenEditorGroups,
8370
+ maxOpenEditors,
8371
+ uid
8372
+ } = state;
8373
+ const {
8374
+ maxOpenEditorGroups: currentMaxOpenEditorGroups,
8375
+ maxOpenEditors: currentMaxOpenEditors,
8376
+ uid: currentUid
8377
+ } = currentState;
8378
+ if (uid !== currentUid) {
8379
+ throw new Error(`Main Area state uid must remain ${currentUid}`);
8380
+ }
8381
+ return {
8382
+ ...state,
8383
+ maxOpenEditorGroups: maxOpenEditorGroups ?? currentMaxOpenEditorGroups,
8384
+ maxOpenEditors: maxOpenEditors ?? currentMaxOpenEditors
8385
+ };
8386
+ };
8387
+ const setComponentState = wrapSerialCommand(applyComponentState);
8388
+
8318
8389
  const flipDirection = direction => {
8319
8390
  return direction === Horizontal ? Vertical : Horizontal;
8320
8391
  };
@@ -8604,6 +8675,7 @@ const commandMap = {
8604
8675
  'MainArea.focusPreviousTab': wrapSerialCommand(focusPreviousTab),
8605
8676
  'MainArea.getActiveEditorUid': wrapGetter(getActiveEditorUid),
8606
8677
  'MainArea.getCommandIds': getCommandIds,
8678
+ 'MainArea.getComponentState': getComponentState,
8607
8679
  'MainArea.getMenuEntries': wrapGetter(getMenuEntries),
8608
8680
  'MainArea.getMenuIds': getMenuIds,
8609
8681
  'MainArea.handleClick': wrapSerialCommand(handleClick),
@@ -8630,8 +8702,10 @@ const commandMap = {
8630
8702
  'MainArea.handleSashPointerMove': wrapSerialCommand(handleSashPointerMove),
8631
8703
  'MainArea.handleSashPointerUp': wrapSerialCommand(handleSashPointerUp),
8632
8704
  'MainArea.handleTabContextMenu': wrapSerialCommand(handleTabContextMenu),
8705
+ 'MainArea.handleTabDragOver': wrapSerialCommand(handleTabDragOver),
8633
8706
  'MainArea.handleTabKeyDown': wrapSerialCommand(handleTabKeyDown),
8634
8707
  'MainArea.handleTabMouseUp': wrapSerialCommand(resetPointerDown),
8708
+ 'MainArea.handleTabsDragOver': wrapSerialCommand(handleTabsDragOver),
8635
8709
  'MainArea.handleTabsWheel': wrapSerialCommand(handleTabsWheel),
8636
8710
  'MainArea.handleTestWorkerMessagePort': handleTestWorkerMessagePort,
8637
8711
  'MainArea.handleUriChange': wrapSerialCommand(handleUriChange),
@@ -8656,6 +8730,7 @@ const commandMap = {
8656
8730
  'MainArea.save': wrapSerialCommand(save),
8657
8731
  'MainArea.saveState': wrapGetter(saveState),
8658
8732
  'MainArea.selectTab': wrapSerialCommand(selectTab),
8733
+ 'MainArea.setComponentState': setComponentState,
8659
8734
  'MainArea.setEditorLayoutGrid': wrapSerialCommand(setEditorLayoutGrid),
8660
8735
  'MainArea.setEditorLayoutSingle': wrapSerialCommand(setEditorLayoutSingle),
8661
8736
  'MainArea.setEditorLayoutThreeColumns': wrapSerialCommand(setEditorLayoutThreeColumns),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-area-worker",
3
- "version": "9.55.1",
3
+ "version": "9.56.0",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",