@lvce-editor/main-area-worker 9.55.2 → 9.56.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.
@@ -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';
@@ -1905,6 +1745,9 @@ const {
1905
1745
  const wrapAsyncCommand = fn => {
1906
1746
  return registry.wrapAsyncCommand(withActiveEditorChangeAsync(fn));
1907
1747
  };
1748
+ const wrapCommand = fn => {
1749
+ return registry.wrapCommand(withActiveEditorChange(fn));
1750
+ };
1908
1751
  const wrapSerialAsyncCommand = fn => {
1909
1752
  return registry.wrapSerialAsyncCommand(withActiveEditorChangeAsync(fn));
1910
1753
  };
@@ -2726,7 +2569,7 @@ const isEqual$1 = (oldState, newState) => {
2726
2569
  };
2727
2570
 
2728
2571
  const isEqual = (oldState, newState) => {
2729
- return oldState.dragOverlay === newState.dragOverlay && oldState.layout === newState.layout;
2572
+ return oldState.dragOverlay === newState.dragOverlay && oldState.layout === newState.layout && oldState.tabDropIndicator === newState.tabDropIndicator;
2730
2573
  };
2731
2574
 
2732
2575
  const RenderItems = 4;
@@ -2810,6 +2653,7 @@ const focus = async state => {
2810
2653
  return state;
2811
2654
  }
2812
2655
  if (isConnected()) {
2656
+ await invoke('Viewlet.focusSelector', editorUid, '[name="editor"]');
2813
2657
  await invoke('Viewlet.focusSelectorAfterRender', editorUid, '[name="editor"]');
2814
2658
  } else {
2815
2659
  await invoke$1('Viewlet.focusSelector', editorUid, '[name="editor"]');
@@ -3458,6 +3302,10 @@ const getActiveEditorUid = state => {
3458
3302
  return editorUid;
3459
3303
  };
3460
3304
 
3305
+ const getComponentState = uid => {
3306
+ return get(uid).newState;
3307
+ };
3308
+
3461
3309
  const getMenuIds = () => {
3462
3310
  return [Main$1, Tab];
3463
3311
  };
@@ -4824,14 +4672,16 @@ const handleDoubleClick = (state, groupIndexRaw, indexRaw) => {
4824
4672
 
4825
4673
  const handleDragLeave = state => {
4826
4674
  const {
4827
- dragOverlay
4675
+ dragOverlay,
4676
+ tabDropIndicator
4828
4677
  } = state;
4829
- if (!dragOverlay) {
4678
+ if (!dragOverlay && !tabDropIndicator) {
4830
4679
  return state;
4831
4680
  }
4832
4681
  return {
4833
4682
  ...state,
4834
- dragOverlay: undefined
4683
+ dragOverlay: undefined,
4684
+ tabDropIndicator: undefined
4835
4685
  };
4836
4686
  };
4837
4687
 
@@ -4956,32 +4806,93 @@ const isDragOverlayEqual = (oldOverlay, newOverlay) => {
4956
4806
  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;
4957
4807
  };
4958
4808
 
4959
- const handleDragOver = (state, eventX, eventY) => {
4809
+ const handleEditorDragOver = (state, eventX, eventY) => {
4960
4810
  const {
4961
4811
  dragOverlay: oldDragOverlay
4962
4812
  } = state;
4963
4813
  const dragOverlay = getDragOverlay(state, eventX, eventY);
4964
- if (isDragOverlayEqual(oldDragOverlay, dragOverlay)) {
4814
+ if (isDragOverlayEqual(oldDragOverlay, dragOverlay) && !state.tabDropIndicator) {
4965
4815
  return state;
4966
4816
  }
4967
4817
  return {
4968
4818
  ...state,
4969
- dragOverlay
4819
+ dragOverlay,
4820
+ tabDropIndicator: undefined
4970
4821
  };
4971
4822
  };
4972
4823
 
4824
+ const hasDraggedTab = state => {
4825
+ const {
4826
+ pointerDownGroupIndex,
4827
+ pointerDownTabIndex
4828
+ } = state;
4829
+ return Boolean(state.layout.groups[pointerDownGroupIndex]?.tabs[pointerDownTabIndex]);
4830
+ };
4831
+ const withTabDropIndicator = (state, tabDropIndicator) => {
4832
+ const oldIndicator = state.tabDropIndicator;
4833
+ if (!state.dragOverlay && oldIndicator?.groupId === tabDropIndicator.groupId && oldIndicator.index === tabDropIndicator.index) {
4834
+ return state;
4835
+ }
4836
+ return {
4837
+ ...state,
4838
+ dragOverlay: undefined,
4839
+ tabDropIndicator
4840
+ };
4841
+ };
4842
+ const handleTabDragOver = (state, groupIndexRaw, tabIndexRaw, tabOffsetLeft, tabWidth, tabsScrollLeft, clientX, clientY) => {
4843
+ if (!hasDraggedTab(state)) {
4844
+ return handleEditorDragOver(state, clientX, clientY);
4845
+ }
4846
+ const groupIndex = Number.parseInt(groupIndexRaw);
4847
+ const tabIndex = Number.parseInt(tabIndexRaw);
4848
+ const group = state.layout.groups[groupIndex];
4849
+ if (!group || tabIndex < 0 || tabIndex >= group.tabs.length) {
4850
+ return state;
4851
+ }
4852
+ const groupBounds = getEditorGroupBounds(state.layout, state.width, state.height)[groupIndex];
4853
+ const tabMidpoint = state.x + groupBounds.x + tabOffsetLeft - tabsScrollLeft + tabWidth / 2;
4854
+ const index = clientX < tabMidpoint ? tabIndex : tabIndex + 1;
4855
+ return withTabDropIndicator(state, {
4856
+ groupId: group.id,
4857
+ index
4858
+ });
4859
+ };
4860
+ const handleTabsDragOver = (state, groupIndexRaw, clientX, clientY) => {
4861
+ if (!hasDraggedTab(state)) {
4862
+ return handleEditorDragOver(state, clientX, clientY);
4863
+ }
4864
+ const groupIndex = Number.parseInt(groupIndexRaw);
4865
+ const group = state.layout.groups[groupIndex];
4866
+ if (!group) {
4867
+ return state;
4868
+ }
4869
+ return withTabDropIndicator(state, {
4870
+ groupId: group.id,
4871
+ index: group.tabs.length
4872
+ });
4873
+ };
4874
+
4875
+ const handleDragOver = (state, eventX, eventY, groupIndexRaw, tabIndexRaw, tabOffsetLeft, tabWidth, tabsScrollLeft) => {
4876
+ if (groupIndexRaw !== undefined && tabIndexRaw !== undefined && tabOffsetLeft !== undefined && tabWidth !== undefined && tabsScrollLeft !== undefined) {
4877
+ return handleTabDragOver(state, groupIndexRaw, tabIndexRaw, tabOffsetLeft, tabWidth, tabsScrollLeft, eventX, eventY);
4878
+ }
4879
+ return handleEditorDragOver(state, eventX, eventY);
4880
+ };
4881
+
4973
4882
  const handleDragStart = state => {
4974
4883
  return state;
4975
4884
  };
4976
4885
 
4977
4886
  const resetPointerDown = state => {
4978
- if (state.pointerDownGroupIndex === -1 && state.pointerDownTabIndex === -1) {
4887
+ if (state.pointerDownGroupIndex === -1 && state.pointerDownTabIndex === -1 && !state.dragOverlay && !state.tabDropIndicator) {
4979
4888
  return state;
4980
4889
  }
4981
4890
  return {
4982
4891
  ...state,
4892
+ dragOverlay: undefined,
4983
4893
  pointerDownGroupIndex: -1,
4984
- pointerDownTabIndex: -1
4894
+ pointerDownTabIndex: -1,
4895
+ tabDropIndicator: undefined
4985
4896
  };
4986
4897
  };
4987
4898
 
@@ -5186,13 +5097,37 @@ const moveTabToGroup = (state, sourceGroupId, targetGroupId, tabId, targetIndex)
5186
5097
  } = layout;
5187
5098
  const sourceGroup = groups.find(group => group.id === sourceGroupId);
5188
5099
  const hasTargetGroup = groups.some(group => group.id === targetGroupId);
5189
- if (!sourceGroup || !hasTargetGroup || sourceGroupId === targetGroupId) {
5100
+ if (!sourceGroup || !hasTargetGroup) {
5190
5101
  return state;
5191
5102
  }
5192
5103
  const tabToMove = sourceGroup.tabs.find(tab => tab.id === tabId);
5193
5104
  if (!tabToMove) {
5194
5105
  return state;
5195
5106
  }
5107
+ if (sourceGroupId === targetGroupId) {
5108
+ if (targetIndex === undefined) {
5109
+ return state;
5110
+ }
5111
+ const sourceIndex = sourceGroup.tabs.findIndex(tab => tab.id === tabId);
5112
+ const insertionBoundary = Math.min(Math.max(targetIndex, 0), sourceGroup.tabs.length);
5113
+ const insertionIndex = insertionBoundary > sourceIndex ? insertionBoundary - 1 : insertionBoundary;
5114
+ if (insertionIndex === sourceIndex) {
5115
+ return state;
5116
+ }
5117
+ const tabs = sourceGroup.tabs.filter(tab => tab.id !== tabId);
5118
+ tabs.splice(insertionIndex, 0, tabToMove);
5119
+ return {
5120
+ ...state,
5121
+ layout: {
5122
+ ...layout,
5123
+ activeGroupId: targetGroupId,
5124
+ groups: groups.map(group => group.id === targetGroupId ? {
5125
+ ...group,
5126
+ tabs
5127
+ } : group)
5128
+ }
5129
+ };
5130
+ }
5196
5131
  const updatedGroups = groups.map(group => {
5197
5132
  if (group.id === sourceGroupId) {
5198
5133
  const newTabs = group.tabs.filter(tab => tab.id !== tabId);
@@ -5213,7 +5148,7 @@ const moveTabToGroup = (state, sourceGroupId, targetGroupId, tabId, targetIndex)
5213
5148
  };
5214
5149
  }
5215
5150
  if (group.id === targetGroupId) {
5216
- const insertIndex = group.tabs.length ;
5151
+ const insertIndex = targetIndex === undefined ? group.tabs.length : Math.min(Math.max(targetIndex, 0), group.tabs.length);
5217
5152
  const newTabs = [...group.tabs];
5218
5153
  newTabs.splice(insertIndex, 0, tabToMove);
5219
5154
  return {
@@ -5238,12 +5173,12 @@ const moveTabToGroup = (state, sourceGroupId, targetGroupId, tabId, targetIndex)
5238
5173
  const getOpenTabCount = state => {
5239
5174
  return state.layout.groups.reduce((count, group) => count + group.tabs.length, 0);
5240
5175
  };
5241
- const applyTabDrop = (state, sourceGroupId, tabId, splitDirection, targetGroupId) => {
5176
+ const applyTabDrop = (state, sourceGroupId, tabId, splitDirection, targetGroupId, targetIndex) => {
5242
5177
  if (targetGroupId === undefined) {
5243
5178
  return state;
5244
5179
  }
5245
5180
  if (splitDirection === None) {
5246
- return moveTabToGroup(state, sourceGroupId, targetGroupId, tabId);
5181
+ return moveTabToGroup(state, sourceGroupId, targetGroupId, tabId, targetIndex);
5247
5182
  }
5248
5183
  if (getOpenTabCount(state) === 1) {
5249
5184
  return state;
@@ -5291,6 +5226,9 @@ const handleDrop = async (context, dropId) => {
5291
5226
  splitDirection = None,
5292
5227
  targetGroupId
5293
5228
  } = initialState.dragOverlay ?? {};
5229
+ const {
5230
+ tabDropIndicator
5231
+ } = initialState;
5294
5232
  await context.updateState(handleDragLeave);
5295
5233
  const {
5296
5234
  platform
@@ -5298,7 +5236,9 @@ const handleDrop = async (context, dropId) => {
5298
5236
  const isElectron = platform === Electron;
5299
5237
  const uris = await getDroppedUrisByDropId(dropId, isElectron);
5300
5238
  if (draggedTab?.uri && uris.length === 1 && normalizeUri(uris[0]) === normalizeUri(draggedTab.uri)) {
5301
- await context.updateState(state => resetPointerDown(applyTabDrop(state, sourceGroup.id, draggedTab.id, splitDirection, targetGroupId)));
5239
+ const tabTargetGroupId = tabDropIndicator?.groupId ?? targetGroupId;
5240
+ const tabTargetIndex = tabDropIndicator?.index;
5241
+ await context.updateState(state => resetPointerDown(applyTabDrop(state, sourceGroup.id, draggedTab.id, splitDirection, tabTargetGroupId, tabTargetIndex)));
5302
5242
  return;
5303
5243
  }
5304
5244
  const actions = await getDropAction(uris);
@@ -7089,8 +7029,6 @@ const text = data => {
7089
7029
  };
7090
7030
  };
7091
7031
 
7092
- new Set(Object.values(VirtualDomElements));
7093
-
7094
7032
  const SetText = 1;
7095
7033
  const Replace = 2;
7096
7034
  const SetAttribute = 3;
@@ -7101,6 +7039,7 @@ const NavigateParent = 8;
7101
7039
  const RemoveChild = 9;
7102
7040
  const NavigateSibling = 10;
7103
7041
  const SetReferenceNodeUid = 11;
7042
+ const MultiNavigation = 18;
7104
7043
 
7105
7044
  const isKey = key => {
7106
7045
  return key !== 'type' && key !== 'childCount';
@@ -7161,6 +7100,55 @@ const getChildrenWithCount = (nodes, startIndex, childCount) => {
7161
7100
  };
7162
7101
  };
7163
7102
 
7103
+ const isNavigationPatch = patch => {
7104
+ switch (patch.type) {
7105
+ case NavigateChild:
7106
+ case NavigateParent:
7107
+ case NavigateSibling:
7108
+ return true;
7109
+ default:
7110
+ return false;
7111
+ }
7112
+ };
7113
+ const getNavigationIndex = patch => {
7114
+ switch (patch.type) {
7115
+ case NavigateChild:
7116
+ case NavigateSibling:
7117
+ return patch.index;
7118
+ default:
7119
+ return 0;
7120
+ }
7121
+ };
7122
+ const appendNavigationPatch = (patches, type, index) => {
7123
+ const previousPatch = patches.at(-1);
7124
+ if (!previousPatch) {
7125
+ patches.push(type === NavigateParent ? {
7126
+ type
7127
+ } : {
7128
+ index,
7129
+ type
7130
+ });
7131
+ return;
7132
+ }
7133
+ if (previousPatch.type === MultiNavigation) {
7134
+ previousPatch.navigations.push(type, index);
7135
+ return;
7136
+ }
7137
+ if (isNavigationPatch(previousPatch)) {
7138
+ patches[patches.length - 1] = {
7139
+ navigations: [previousPatch.type, getNavigationIndex(previousPatch), type, index],
7140
+ type: MultiNavigation
7141
+ };
7142
+ return;
7143
+ }
7144
+ patches.push(type === NavigateParent ? {
7145
+ type
7146
+ } : {
7147
+ index,
7148
+ type
7149
+ });
7150
+ };
7151
+
7164
7152
  const compareNodes = (oldNode, newNode) => {
7165
7153
  // Check if node type changed - return null to signal incompatible nodes
7166
7154
  // (caller should handle this with a Replace operation)
@@ -7225,25 +7213,17 @@ const treeToArray = node => {
7225
7213
 
7226
7214
  const navigateToChild = (patches, currentChildIndex, index) => {
7227
7215
  if (currentChildIndex === -1) {
7228
- patches.push({
7229
- type: NavigateChild,
7230
- index
7231
- });
7216
+ appendNavigationPatch(patches, NavigateChild, index);
7232
7217
  return index;
7233
7218
  }
7234
7219
  if (currentChildIndex !== index) {
7235
- patches.push({
7236
- type: NavigateSibling,
7237
- index
7238
- });
7220
+ appendNavigationPatch(patches, NavigateSibling, index);
7239
7221
  }
7240
7222
  return index;
7241
7223
  };
7242
7224
  const navigateToParent = (patches, currentChildIndex) => {
7243
7225
  if (currentChildIndex >= 0) {
7244
- patches.push({
7245
- type: NavigateParent
7246
- });
7226
+ appendNavigationPatch(patches, NavigateParent, 0);
7247
7227
  }
7248
7228
  return -1;
7249
7229
  };
@@ -7259,6 +7239,29 @@ const replaceTree = (newNode, patches) => {
7259
7239
  nodes: treeToArray(newNode)
7260
7240
  });
7261
7241
  };
7242
+ const appendPatch = (patches, patch) => {
7243
+ switch (patch.type) {
7244
+ case MultiNavigation:
7245
+ for (let i = 0; i < patch.navigations.length; i += 2) {
7246
+ appendNavigationPatch(patches, patch.navigations[i], patch.navigations[i + 1]);
7247
+ }
7248
+ return;
7249
+ case NavigateChild:
7250
+ case NavigateSibling:
7251
+ appendNavigationPatch(patches, patch.type, patch.index);
7252
+ return;
7253
+ case NavigateParent:
7254
+ appendNavigationPatch(patches, patch.type, 0);
7255
+ return;
7256
+ default:
7257
+ patches.push(patch);
7258
+ }
7259
+ };
7260
+ const appendPatches = (patches, newPatches) => {
7261
+ for (const patch of newPatches) {
7262
+ appendPatch(patches, patch);
7263
+ }
7264
+ };
7262
7265
  const diffExistingChild = (oldNode, newNode, patches, currentChildIndex, index) => {
7263
7266
  const nodePatches = compareNodes(oldNode.node, newNode.node);
7264
7267
  if (nodePatches === null) {
@@ -7267,16 +7270,16 @@ const diffExistingChild = (oldNode, newNode, patches, currentChildIndex, index)
7267
7270
  return nextChildIndex;
7268
7271
  }
7269
7272
  const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
7270
- if (nodePatches.length === 0 && !hasChildrenToCompare) {
7273
+ const childPatches = [];
7274
+ if (hasChildrenToCompare) {
7275
+ diffChildren(oldNode.children, newNode.children, childPatches);
7276
+ }
7277
+ if (nodePatches.length === 0 && childPatches.length === 0) {
7271
7278
  return currentChildIndex;
7272
7279
  }
7273
7280
  const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
7274
- if (nodePatches.length > 0) {
7275
- patches.push(...nodePatches);
7276
- }
7277
- if (hasChildrenToCompare) {
7278
- diffChildren(oldNode.children, newNode.children, patches);
7279
- }
7281
+ patches.push(...nodePatches);
7282
+ appendPatches(patches, childPatches);
7280
7283
  return nextChildIndex;
7281
7284
  };
7282
7285
  const diffRootNode = (oldNode, newNode, patches) => {
@@ -7332,7 +7335,7 @@ const diffTrees = (oldTree, newTree, patches, path) => {
7332
7335
  const removeTrailingNavigationPatches = patches => {
7333
7336
  while (patches.length > 0) {
7334
7337
  const patch = patches.at(-1);
7335
- if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling) {
7338
+ if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling && patch.type !== MultiNavigation) {
7336
7339
  break;
7337
7340
  }
7338
7341
  patches.pop();
@@ -7373,6 +7376,8 @@ const HandleDragEnd = 27;
7373
7376
  const HandleTabMouseUp = 28;
7374
7377
  const HandleTabKeyDown = 29;
7375
7378
  const HandleTabsWheel = 30;
7379
+ const HandleTabDragOver = 31;
7380
+ const HandleTabsDragOver = 32;
7376
7381
 
7377
7382
  const dragOverlayVirtualDom = {
7378
7383
  childCount: 0,
@@ -7581,7 +7586,16 @@ const renderTabIcon = tab => {
7581
7586
  type: Img
7582
7587
  }];
7583
7588
  };
7584
- const renderTab = (tab, isActive, tabIndex, groupIndex) => {
7589
+ const getDropIndicatorStyle = dropIndicatorPosition => {
7590
+ if (dropIndicatorPosition === 'before') {
7591
+ return 'box-shadow:inset 2px 0 0 white;';
7592
+ }
7593
+ if (dropIndicatorPosition === 'after') {
7594
+ return 'box-shadow:inset -2px 0 0 white;';
7595
+ }
7596
+ return undefined;
7597
+ };
7598
+ const renderTab = (tab, isActive, tabIndex, groupIndex, dropIndicatorPosition) => {
7585
7599
  const closeButtonNodes = renderTabActions(tab.isDirty, tabIndex, groupIndex);
7586
7600
  const tabIconNodes = renderTabIcon(tab);
7587
7601
  let className = MainTab;
@@ -7604,26 +7618,43 @@ const renderTab = (tab, isActive, tabIndex, groupIndex) => {
7604
7618
  onContextMenu: HandleTabContextMenu,
7605
7619
  onDblClick: HandleDoubleClick,
7606
7620
  onDragEnd: HandleDragEnd,
7621
+ onDragOver: HandleTabDragOver,
7607
7622
  onDragStart: HandleDragStart,
7608
7623
  onKeyDown: HandleTabKeyDown,
7609
7624
  onMouseDown: HandleClickTab,
7610
7625
  onMouseUp: HandleTabMouseUp,
7611
7626
  role: Tab$1,
7627
+ ...(dropIndicatorPosition && {
7628
+ style: getDropIndicatorStyle(dropIndicatorPosition)
7629
+ }),
7612
7630
  tabIndex: isActive ? 0 : -1,
7613
7631
  title: tab.uriTitle || tab.uri || tab.title,
7614
7632
  type: Div
7615
7633
  }, ...tabIconNodes, tabTitleNode, text(tab.title), ...closeButtonNodes];
7616
7634
  };
7617
7635
 
7618
- const getTabsVirtualDom = (group, groupIndex, tabsChildCount) => {
7636
+ const getDropIndicatorPosition = (group, tabIndex, tabDropIndicator) => {
7637
+ if (tabDropIndicator?.groupId !== group.id) {
7638
+ return undefined;
7639
+ }
7640
+ if (tabDropIndicator.index === tabIndex) {
7641
+ return 'before';
7642
+ }
7643
+ if (tabDropIndicator.index === group.tabs.length && tabIndex === group.tabs.length - 1) {
7644
+ return 'after';
7645
+ }
7646
+ return undefined;
7647
+ };
7648
+ const getTabsVirtualDom = (group, groupIndex, tabsChildCount, tabDropIndicator) => {
7619
7649
  return [{
7620
7650
  childCount: tabsChildCount,
7621
7651
  className: MainTabs,
7622
7652
  'data-groupIndex': groupIndex,
7653
+ onDragOver: HandleTabsDragOver,
7623
7654
  onWheel: HandleTabsWheel,
7624
7655
  role: TabList,
7625
7656
  type: Div
7626
- }, ...group.tabs.flatMap((tab, tabIndex) => renderTab(tab, tab.id === group.activeTabId, tabIndex, groupIndex))];
7657
+ }, ...group.tabs.flatMap((tab, tabIndex) => renderTab(tab, tab.id === group.activeTabId, tabIndex, groupIndex, getDropIndicatorPosition(group, tabIndex, tabDropIndicator)))];
7627
7658
  };
7628
7659
 
7629
7660
  const isHtmlFile = tab => {
@@ -7679,7 +7710,7 @@ const renderEditorGroupActions = (group, groupIndex, splitButtonEnabled) => {
7679
7710
  }, ...buttons];
7680
7711
  };
7681
7712
 
7682
- const renderEditorGroupHeader = (group, groupIndex, splitButtonEnabled) => {
7713
+ const renderEditorGroupHeader = (group, groupIndex, splitButtonEnabled, tabDropIndicator) => {
7683
7714
  const tabsChildCount = group.tabs.length;
7684
7715
  const actions = renderEditorGroupActions(group, groupIndex, splitButtonEnabled);
7685
7716
  const hasActions = actions.length > 0;
@@ -7689,7 +7720,7 @@ const renderEditorGroupHeader = (group, groupIndex, splitButtonEnabled) => {
7689
7720
  onDblClick: HandleHeaderDoubleClick,
7690
7721
  role: None$2,
7691
7722
  type: Div
7692
- }, ...getTabsVirtualDom(group, groupIndex, tabsChildCount), ...actions];
7723
+ }, ...getTabsVirtualDom(group, groupIndex, tabsChildCount, tabDropIndicator), ...actions];
7693
7724
  };
7694
7725
 
7695
7726
  const emptyHeader = {
@@ -7748,7 +7779,7 @@ const editorContainerNode = {
7748
7779
  className: EditorContainer,
7749
7780
  type: Div
7750
7781
  };
7751
- const renderEditorGroup = (group, groupIndex, splitButtonEnabled = false, sizeProperty = 'width', closeButtonEnabled = true) => {
7782
+ const renderEditorGroup = (group, groupIndex, splitButtonEnabled = false, sizeProperty = 'width', closeButtonEnabled = true, tabDropIndicator) => {
7752
7783
  const activeTab = group.tabs.find(tab => tab.id === group.activeTabId);
7753
7784
  const style = `${sizeProperty}:${group.size}%;`;
7754
7785
  const hasTabs = group.tabs.length > 0;
@@ -7762,7 +7793,7 @@ const renderEditorGroup = (group, groupIndex, splitButtonEnabled = false, sizePr
7762
7793
  'data-groupId': String(group.id),
7763
7794
  style,
7764
7795
  type: Div
7765
- }, ...renderEditorGroupHeader(group, groupIndex, splitButtonEnabled), editorContainerNode, ...renderEditor(activeTab)];
7796
+ }, ...renderEditorGroupHeader(group, groupIndex, splitButtonEnabled, tabDropIndicator), editorContainerNode, ...renderEditor(activeTab)];
7766
7797
  };
7767
7798
 
7768
7799
  const classVertical = 'Sash SashVertical';
@@ -7808,11 +7839,11 @@ const mainNode$1 = {
7808
7839
  onDrop: HandleDrop,
7809
7840
  type: Div
7810
7841
  };
7811
- const renderSingleEditorGroup = (layout, splitButtonEnabled, sizeProperty = 'width') => {
7842
+ const renderSingleEditorGroup = (layout, splitButtonEnabled, sizeProperty = 'width', tabDropIndicator) => {
7812
7843
  const {
7813
7844
  groups
7814
7845
  } = layout;
7815
- return [mainNode$1, ...renderEditorGroup(groups[0], 0, splitButtonEnabled, sizeProperty, false)];
7846
+ return [mainNode$1, ...renderEditorGroup(groups[0], 0, splitButtonEnabled, sizeProperty, false, tabDropIndicator)];
7816
7847
  };
7817
7848
 
7818
7849
  const getDirectionClassName = (direction, isSplit) => {
@@ -7845,7 +7876,7 @@ const addDragOverlay = (dom, dragOverlay) => {
7845
7876
  const getSizeProperty = direction => {
7846
7877
  return direction === Vertical ? 'height' : 'width';
7847
7878
  };
7848
- const renderSegmentChildren = (direction, groups, splitButtonEnabled) => {
7879
+ const renderSegmentChildren = (direction, groups, splitButtonEnabled, tabDropIndicator) => {
7849
7880
  const segments = getGroupSegments(groups, direction);
7850
7881
  const children = [];
7851
7882
  let childCount = 0;
@@ -7861,7 +7892,7 @@ const renderSegmentChildren = (direction, groups, splitButtonEnabled) => {
7861
7892
  childCount++;
7862
7893
  }
7863
7894
  if (segment.direction === undefined) {
7864
- children.push(...renderEditorGroup(segment.groups[0], segment.startIndex, splitButtonEnabled, sizeProperty));
7895
+ children.push(...renderEditorGroup(segment.groups[0], segment.startIndex, splitButtonEnabled, sizeProperty, true, tabDropIndicator));
7865
7896
  childCount++;
7866
7897
  continue;
7867
7898
  }
@@ -7884,7 +7915,7 @@ const renderSegmentChildren = (direction, groups, splitButtonEnabled) => {
7884
7915
  nestedChildren.push(...renderEditorGroup({
7885
7916
  ...group,
7886
7917
  size: normalizedSize
7887
- }, segment.startIndex + j, splitButtonEnabled, nestedSizeProperty));
7918
+ }, segment.startIndex + j, splitButtonEnabled, nestedSizeProperty, true, tabDropIndicator));
7888
7919
  nestedCount++;
7889
7920
  }
7890
7921
  children.push({
@@ -7903,14 +7934,14 @@ const renderSegmentChildren = (direction, groups, splitButtonEnabled) => {
7903
7934
  children
7904
7935
  };
7905
7936
  };
7906
- const getMainAreaVirtualDom = (layout, splitButtonEnabled = false, dragOverlay) => {
7937
+ const getMainAreaVirtualDom = (layout, splitButtonEnabled = false, dragOverlay, tabDropIndicator) => {
7907
7938
  const {
7908
7939
  direction,
7909
7940
  groups
7910
7941
  } = layout;
7911
7942
  const sizeProperty = getSizeProperty(direction);
7912
7943
  if (groups.length === 1) {
7913
- return addDragOverlay(renderSingleEditorGroup(layout, splitButtonEnabled, sizeProperty), dragOverlay);
7944
+ return addDragOverlay(renderSingleEditorGroup(layout, splitButtonEnabled, sizeProperty, tabDropIndicator), dragOverlay);
7914
7945
  }
7915
7946
  const editorGroupsContainerClassName = getContainerClassName(direction, groups.length);
7916
7947
  if (groups.length === 0) {
@@ -7926,7 +7957,7 @@ const getMainAreaVirtualDom = (layout, splitButtonEnabled = false, dragOverlay)
7926
7957
  const {
7927
7958
  childCount,
7928
7959
  children
7929
- } = renderSegmentChildren(direction, groups, splitButtonEnabled);
7960
+ } = renderSegmentChildren(direction, groups, splitButtonEnabled, tabDropIndicator);
7930
7961
  const sashCorner = getSashCorner(layout);
7931
7962
  const sashCornerChildren = sashCorner ? [renderSashCorner()] : [];
7932
7963
  return addDragOverlay([mainNode, {
@@ -7943,12 +7974,13 @@ const renderItems = (oldState, newState) => {
7943
7974
  initial,
7944
7975
  layout,
7945
7976
  splitButtonEnabled,
7977
+ tabDropIndicator,
7946
7978
  uid
7947
7979
  } = newState;
7948
7980
  if (initial) {
7949
7981
  return [SetDom2, uid, []];
7950
7982
  }
7951
- const dom = getMainAreaVirtualDom(layout, splitButtonEnabled, dragOverlay);
7983
+ const dom = getMainAreaVirtualDom(layout, splitButtonEnabled, dragOverlay, tabDropIndicator);
7952
7984
  return [SetDom2, uid, dom];
7953
7985
  };
7954
7986
 
@@ -8046,6 +8078,16 @@ const renderEventListeners = () => {
8046
8078
  }, {
8047
8079
  name: HandleTabsWheel,
8048
8080
  params: ['handleTabsWheel', 'event.currentTarget.dataset.groupIndex', DeltaMode, DeltaY]
8081
+ }, {
8082
+ name: HandleTabDragOver,
8083
+ params: ['handleTabDragOver', 'event.currentTarget.dataset.groupIndex', 'event.currentTarget.dataset.index', 'event.currentTarget.offsetLeft', 'event.currentTarget.offsetWidth', 'event.currentTarget.parentElement.scrollLeft', ClientX, ClientY],
8084
+ preventDefault: true,
8085
+ stopPropagation: true
8086
+ }, {
8087
+ name: HandleTabsDragOver,
8088
+ params: ['handleTabsDragOver', 'event.currentTarget.dataset.groupIndex', ClientX, ClientY],
8089
+ preventDefault: true,
8090
+ stopPropagation: true
8049
8091
  }, {
8050
8092
  name: HandleDoubleClick,
8051
8093
  params: ['handleDoubleClick', 'event.target.dataset.groupIndex', 'event.target.dataset.index']
@@ -8322,6 +8364,31 @@ const saveState = state => {
8322
8364
  };
8323
8365
  };
8324
8366
 
8367
+ const applyComponentState = (currentState, state) => {
8368
+ if (!state || typeof state !== 'object' || Array.isArray(state)) {
8369
+ throw new TypeError('Main Area state must be an object');
8370
+ }
8371
+ const {
8372
+ maxOpenEditorGroups,
8373
+ maxOpenEditors,
8374
+ uid
8375
+ } = state;
8376
+ const {
8377
+ maxOpenEditorGroups: currentMaxOpenEditorGroups,
8378
+ maxOpenEditors: currentMaxOpenEditors,
8379
+ uid: currentUid
8380
+ } = currentState;
8381
+ if (uid !== currentUid) {
8382
+ throw new Error(`Main Area state uid must remain ${currentUid}`);
8383
+ }
8384
+ return {
8385
+ ...state,
8386
+ maxOpenEditorGroups: maxOpenEditorGroups ?? currentMaxOpenEditorGroups,
8387
+ maxOpenEditors: maxOpenEditors ?? currentMaxOpenEditors
8388
+ };
8389
+ };
8390
+ const setComponentState = wrapCommand(applyComponentState);
8391
+
8325
8392
  const flipDirection = direction => {
8326
8393
  return direction === Horizontal ? Vertical : Horizontal;
8327
8394
  };
@@ -8611,6 +8678,7 @@ const commandMap = {
8611
8678
  'MainArea.focusPreviousTab': wrapSerialCommand(focusPreviousTab),
8612
8679
  'MainArea.getActiveEditorUid': wrapGetter(getActiveEditorUid),
8613
8680
  'MainArea.getCommandIds': getCommandIds,
8681
+ 'MainArea.getComponentState': getComponentState,
8614
8682
  'MainArea.getMenuEntries': wrapGetter(getMenuEntries),
8615
8683
  'MainArea.getMenuIds': getMenuIds,
8616
8684
  'MainArea.handleClick': wrapSerialCommand(handleClick),
@@ -8637,8 +8705,10 @@ const commandMap = {
8637
8705
  'MainArea.handleSashPointerMove': wrapSerialCommand(handleSashPointerMove),
8638
8706
  'MainArea.handleSashPointerUp': wrapSerialCommand(handleSashPointerUp),
8639
8707
  'MainArea.handleTabContextMenu': wrapSerialCommand(handleTabContextMenu),
8708
+ 'MainArea.handleTabDragOver': wrapSerialCommand(handleTabDragOver),
8640
8709
  'MainArea.handleTabKeyDown': wrapSerialCommand(handleTabKeyDown),
8641
8710
  'MainArea.handleTabMouseUp': wrapSerialCommand(resetPointerDown),
8711
+ 'MainArea.handleTabsDragOver': wrapSerialCommand(handleTabsDragOver),
8642
8712
  'MainArea.handleTabsWheel': wrapSerialCommand(handleTabsWheel),
8643
8713
  'MainArea.handleTestWorkerMessagePort': handleTestWorkerMessagePort,
8644
8714
  'MainArea.handleUriChange': wrapSerialCommand(handleUriChange),
@@ -8663,6 +8733,7 @@ const commandMap = {
8663
8733
  'MainArea.save': wrapSerialCommand(save),
8664
8734
  'MainArea.saveState': wrapGetter(saveState),
8665
8735
  'MainArea.selectTab': wrapSerialCommand(selectTab),
8736
+ 'MainArea.setComponentState': setComponentState,
8666
8737
  'MainArea.setEditorLayoutGrid': wrapSerialCommand(setEditorLayoutGrid),
8667
8738
  'MainArea.setEditorLayoutSingle': wrapSerialCommand(setEditorLayoutSingle),
8668
8739
  '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.2",
3
+ "version": "9.56.1",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",