@lvce-editor/main-area-worker 9.55.2 → 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
  };
@@ -4824,14 +4669,16 @@ const handleDoubleClick = (state, groupIndexRaw, indexRaw) => {
4824
4669
 
4825
4670
  const handleDragLeave = state => {
4826
4671
  const {
4827
- dragOverlay
4672
+ dragOverlay,
4673
+ tabDropIndicator
4828
4674
  } = state;
4829
- if (!dragOverlay) {
4675
+ if (!dragOverlay && !tabDropIndicator) {
4830
4676
  return state;
4831
4677
  }
4832
4678
  return {
4833
4679
  ...state,
4834
- dragOverlay: undefined
4680
+ dragOverlay: undefined,
4681
+ tabDropIndicator: undefined
4835
4682
  };
4836
4683
  };
4837
4684
 
@@ -4956,32 +4803,93 @@ const isDragOverlayEqual = (oldOverlay, newOverlay) => {
4956
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;
4957
4804
  };
4958
4805
 
4959
- const handleDragOver = (state, eventX, eventY) => {
4806
+ const handleEditorDragOver = (state, eventX, eventY) => {
4960
4807
  const {
4961
4808
  dragOverlay: oldDragOverlay
4962
4809
  } = state;
4963
4810
  const dragOverlay = getDragOverlay(state, eventX, eventY);
4964
- if (isDragOverlayEqual(oldDragOverlay, dragOverlay)) {
4811
+ if (isDragOverlayEqual(oldDragOverlay, dragOverlay) && !state.tabDropIndicator) {
4965
4812
  return state;
4966
4813
  }
4967
4814
  return {
4968
4815
  ...state,
4969
- dragOverlay
4816
+ dragOverlay,
4817
+ tabDropIndicator: undefined
4970
4818
  };
4971
4819
  };
4972
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
+
4973
4879
  const handleDragStart = state => {
4974
4880
  return state;
4975
4881
  };
4976
4882
 
4977
4883
  const resetPointerDown = state => {
4978
- if (state.pointerDownGroupIndex === -1 && state.pointerDownTabIndex === -1) {
4884
+ if (state.pointerDownGroupIndex === -1 && state.pointerDownTabIndex === -1 && !state.dragOverlay && !state.tabDropIndicator) {
4979
4885
  return state;
4980
4886
  }
4981
4887
  return {
4982
4888
  ...state,
4889
+ dragOverlay: undefined,
4983
4890
  pointerDownGroupIndex: -1,
4984
- pointerDownTabIndex: -1
4891
+ pointerDownTabIndex: -1,
4892
+ tabDropIndicator: undefined
4985
4893
  };
4986
4894
  };
4987
4895
 
@@ -5186,13 +5094,37 @@ const moveTabToGroup = (state, sourceGroupId, targetGroupId, tabId, targetIndex)
5186
5094
  } = layout;
5187
5095
  const sourceGroup = groups.find(group => group.id === sourceGroupId);
5188
5096
  const hasTargetGroup = groups.some(group => group.id === targetGroupId);
5189
- if (!sourceGroup || !hasTargetGroup || sourceGroupId === targetGroupId) {
5097
+ if (!sourceGroup || !hasTargetGroup) {
5190
5098
  return state;
5191
5099
  }
5192
5100
  const tabToMove = sourceGroup.tabs.find(tab => tab.id === tabId);
5193
5101
  if (!tabToMove) {
5194
5102
  return state;
5195
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
+ }
5196
5128
  const updatedGroups = groups.map(group => {
5197
5129
  if (group.id === sourceGroupId) {
5198
5130
  const newTabs = group.tabs.filter(tab => tab.id !== tabId);
@@ -5213,7 +5145,7 @@ const moveTabToGroup = (state, sourceGroupId, targetGroupId, tabId, targetIndex)
5213
5145
  };
5214
5146
  }
5215
5147
  if (group.id === targetGroupId) {
5216
- const insertIndex = group.tabs.length ;
5148
+ const insertIndex = targetIndex === undefined ? group.tabs.length : Math.min(Math.max(targetIndex, 0), group.tabs.length);
5217
5149
  const newTabs = [...group.tabs];
5218
5150
  newTabs.splice(insertIndex, 0, tabToMove);
5219
5151
  return {
@@ -5238,12 +5170,12 @@ const moveTabToGroup = (state, sourceGroupId, targetGroupId, tabId, targetIndex)
5238
5170
  const getOpenTabCount = state => {
5239
5171
  return state.layout.groups.reduce((count, group) => count + group.tabs.length, 0);
5240
5172
  };
5241
- const applyTabDrop = (state, sourceGroupId, tabId, splitDirection, targetGroupId) => {
5173
+ const applyTabDrop = (state, sourceGroupId, tabId, splitDirection, targetGroupId, targetIndex) => {
5242
5174
  if (targetGroupId === undefined) {
5243
5175
  return state;
5244
5176
  }
5245
5177
  if (splitDirection === None) {
5246
- return moveTabToGroup(state, sourceGroupId, targetGroupId, tabId);
5178
+ return moveTabToGroup(state, sourceGroupId, targetGroupId, tabId, targetIndex);
5247
5179
  }
5248
5180
  if (getOpenTabCount(state) === 1) {
5249
5181
  return state;
@@ -5291,6 +5223,9 @@ const handleDrop = async (context, dropId) => {
5291
5223
  splitDirection = None,
5292
5224
  targetGroupId
5293
5225
  } = initialState.dragOverlay ?? {};
5226
+ const {
5227
+ tabDropIndicator
5228
+ } = initialState;
5294
5229
  await context.updateState(handleDragLeave);
5295
5230
  const {
5296
5231
  platform
@@ -5298,7 +5233,9 @@ const handleDrop = async (context, dropId) => {
5298
5233
  const isElectron = platform === Electron;
5299
5234
  const uris = await getDroppedUrisByDropId(dropId, isElectron);
5300
5235
  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)));
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)));
5302
5239
  return;
5303
5240
  }
5304
5241
  const actions = await getDropAction(uris);
@@ -7089,8 +7026,6 @@ const text = data => {
7089
7026
  };
7090
7027
  };
7091
7028
 
7092
- new Set(Object.values(VirtualDomElements));
7093
-
7094
7029
  const SetText = 1;
7095
7030
  const Replace = 2;
7096
7031
  const SetAttribute = 3;
@@ -7101,6 +7036,7 @@ const NavigateParent = 8;
7101
7036
  const RemoveChild = 9;
7102
7037
  const NavigateSibling = 10;
7103
7038
  const SetReferenceNodeUid = 11;
7039
+ const MultiNavigation = 18;
7104
7040
 
7105
7041
  const isKey = key => {
7106
7042
  return key !== 'type' && key !== 'childCount';
@@ -7161,6 +7097,55 @@ const getChildrenWithCount = (nodes, startIndex, childCount) => {
7161
7097
  };
7162
7098
  };
7163
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
+
7164
7149
  const compareNodes = (oldNode, newNode) => {
7165
7150
  // Check if node type changed - return null to signal incompatible nodes
7166
7151
  // (caller should handle this with a Replace operation)
@@ -7225,25 +7210,17 @@ const treeToArray = node => {
7225
7210
 
7226
7211
  const navigateToChild = (patches, currentChildIndex, index) => {
7227
7212
  if (currentChildIndex === -1) {
7228
- patches.push({
7229
- type: NavigateChild,
7230
- index
7231
- });
7213
+ appendNavigationPatch(patches, NavigateChild, index);
7232
7214
  return index;
7233
7215
  }
7234
7216
  if (currentChildIndex !== index) {
7235
- patches.push({
7236
- type: NavigateSibling,
7237
- index
7238
- });
7217
+ appendNavigationPatch(patches, NavigateSibling, index);
7239
7218
  }
7240
7219
  return index;
7241
7220
  };
7242
7221
  const navigateToParent = (patches, currentChildIndex) => {
7243
7222
  if (currentChildIndex >= 0) {
7244
- patches.push({
7245
- type: NavigateParent
7246
- });
7223
+ appendNavigationPatch(patches, NavigateParent, 0);
7247
7224
  }
7248
7225
  return -1;
7249
7226
  };
@@ -7259,6 +7236,29 @@ const replaceTree = (newNode, patches) => {
7259
7236
  nodes: treeToArray(newNode)
7260
7237
  });
7261
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
+ };
7262
7262
  const diffExistingChild = (oldNode, newNode, patches, currentChildIndex, index) => {
7263
7263
  const nodePatches = compareNodes(oldNode.node, newNode.node);
7264
7264
  if (nodePatches === null) {
@@ -7267,16 +7267,16 @@ const diffExistingChild = (oldNode, newNode, patches, currentChildIndex, index)
7267
7267
  return nextChildIndex;
7268
7268
  }
7269
7269
  const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
7270
- 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) {
7271
7275
  return currentChildIndex;
7272
7276
  }
7273
7277
  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
- }
7278
+ patches.push(...nodePatches);
7279
+ appendPatches(patches, childPatches);
7280
7280
  return nextChildIndex;
7281
7281
  };
7282
7282
  const diffRootNode = (oldNode, newNode, patches) => {
@@ -7332,7 +7332,7 @@ const diffTrees = (oldTree, newTree, patches, path) => {
7332
7332
  const removeTrailingNavigationPatches = patches => {
7333
7333
  while (patches.length > 0) {
7334
7334
  const patch = patches.at(-1);
7335
- if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling) {
7335
+ if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling && patch.type !== MultiNavigation) {
7336
7336
  break;
7337
7337
  }
7338
7338
  patches.pop();
@@ -7373,6 +7373,8 @@ const HandleDragEnd = 27;
7373
7373
  const HandleTabMouseUp = 28;
7374
7374
  const HandleTabKeyDown = 29;
7375
7375
  const HandleTabsWheel = 30;
7376
+ const HandleTabDragOver = 31;
7377
+ const HandleTabsDragOver = 32;
7376
7378
 
7377
7379
  const dragOverlayVirtualDom = {
7378
7380
  childCount: 0,
@@ -7581,7 +7583,16 @@ const renderTabIcon = tab => {
7581
7583
  type: Img
7582
7584
  }];
7583
7585
  };
7584
- 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) => {
7585
7596
  const closeButtonNodes = renderTabActions(tab.isDirty, tabIndex, groupIndex);
7586
7597
  const tabIconNodes = renderTabIcon(tab);
7587
7598
  let className = MainTab;
@@ -7604,26 +7615,43 @@ const renderTab = (tab, isActive, tabIndex, groupIndex) => {
7604
7615
  onContextMenu: HandleTabContextMenu,
7605
7616
  onDblClick: HandleDoubleClick,
7606
7617
  onDragEnd: HandleDragEnd,
7618
+ onDragOver: HandleTabDragOver,
7607
7619
  onDragStart: HandleDragStart,
7608
7620
  onKeyDown: HandleTabKeyDown,
7609
7621
  onMouseDown: HandleClickTab,
7610
7622
  onMouseUp: HandleTabMouseUp,
7611
7623
  role: Tab$1,
7624
+ ...(dropIndicatorPosition && {
7625
+ style: getDropIndicatorStyle(dropIndicatorPosition)
7626
+ }),
7612
7627
  tabIndex: isActive ? 0 : -1,
7613
7628
  title: tab.uriTitle || tab.uri || tab.title,
7614
7629
  type: Div
7615
7630
  }, ...tabIconNodes, tabTitleNode, text(tab.title), ...closeButtonNodes];
7616
7631
  };
7617
7632
 
7618
- 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) => {
7619
7646
  return [{
7620
7647
  childCount: tabsChildCount,
7621
7648
  className: MainTabs,
7622
7649
  'data-groupIndex': groupIndex,
7650
+ onDragOver: HandleTabsDragOver,
7623
7651
  onWheel: HandleTabsWheel,
7624
7652
  role: TabList,
7625
7653
  type: Div
7626
- }, ...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)))];
7627
7655
  };
7628
7656
 
7629
7657
  const isHtmlFile = tab => {
@@ -7679,7 +7707,7 @@ const renderEditorGroupActions = (group, groupIndex, splitButtonEnabled) => {
7679
7707
  }, ...buttons];
7680
7708
  };
7681
7709
 
7682
- const renderEditorGroupHeader = (group, groupIndex, splitButtonEnabled) => {
7710
+ const renderEditorGroupHeader = (group, groupIndex, splitButtonEnabled, tabDropIndicator) => {
7683
7711
  const tabsChildCount = group.tabs.length;
7684
7712
  const actions = renderEditorGroupActions(group, groupIndex, splitButtonEnabled);
7685
7713
  const hasActions = actions.length > 0;
@@ -7689,7 +7717,7 @@ const renderEditorGroupHeader = (group, groupIndex, splitButtonEnabled) => {
7689
7717
  onDblClick: HandleHeaderDoubleClick,
7690
7718
  role: None$2,
7691
7719
  type: Div
7692
- }, ...getTabsVirtualDom(group, groupIndex, tabsChildCount), ...actions];
7720
+ }, ...getTabsVirtualDom(group, groupIndex, tabsChildCount, tabDropIndicator), ...actions];
7693
7721
  };
7694
7722
 
7695
7723
  const emptyHeader = {
@@ -7748,7 +7776,7 @@ const editorContainerNode = {
7748
7776
  className: EditorContainer,
7749
7777
  type: Div
7750
7778
  };
7751
- const renderEditorGroup = (group, groupIndex, splitButtonEnabled = false, sizeProperty = 'width', closeButtonEnabled = true) => {
7779
+ const renderEditorGroup = (group, groupIndex, splitButtonEnabled = false, sizeProperty = 'width', closeButtonEnabled = true, tabDropIndicator) => {
7752
7780
  const activeTab = group.tabs.find(tab => tab.id === group.activeTabId);
7753
7781
  const style = `${sizeProperty}:${group.size}%;`;
7754
7782
  const hasTabs = group.tabs.length > 0;
@@ -7762,7 +7790,7 @@ const renderEditorGroup = (group, groupIndex, splitButtonEnabled = false, sizePr
7762
7790
  'data-groupId': String(group.id),
7763
7791
  style,
7764
7792
  type: Div
7765
- }, ...renderEditorGroupHeader(group, groupIndex, splitButtonEnabled), editorContainerNode, ...renderEditor(activeTab)];
7793
+ }, ...renderEditorGroupHeader(group, groupIndex, splitButtonEnabled, tabDropIndicator), editorContainerNode, ...renderEditor(activeTab)];
7766
7794
  };
7767
7795
 
7768
7796
  const classVertical = 'Sash SashVertical';
@@ -7808,11 +7836,11 @@ const mainNode$1 = {
7808
7836
  onDrop: HandleDrop,
7809
7837
  type: Div
7810
7838
  };
7811
- const renderSingleEditorGroup = (layout, splitButtonEnabled, sizeProperty = 'width') => {
7839
+ const renderSingleEditorGroup = (layout, splitButtonEnabled, sizeProperty = 'width', tabDropIndicator) => {
7812
7840
  const {
7813
7841
  groups
7814
7842
  } = layout;
7815
- return [mainNode$1, ...renderEditorGroup(groups[0], 0, splitButtonEnabled, sizeProperty, false)];
7843
+ return [mainNode$1, ...renderEditorGroup(groups[0], 0, splitButtonEnabled, sizeProperty, false, tabDropIndicator)];
7816
7844
  };
7817
7845
 
7818
7846
  const getDirectionClassName = (direction, isSplit) => {
@@ -7845,7 +7873,7 @@ const addDragOverlay = (dom, dragOverlay) => {
7845
7873
  const getSizeProperty = direction => {
7846
7874
  return direction === Vertical ? 'height' : 'width';
7847
7875
  };
7848
- const renderSegmentChildren = (direction, groups, splitButtonEnabled) => {
7876
+ const renderSegmentChildren = (direction, groups, splitButtonEnabled, tabDropIndicator) => {
7849
7877
  const segments = getGroupSegments(groups, direction);
7850
7878
  const children = [];
7851
7879
  let childCount = 0;
@@ -7861,7 +7889,7 @@ const renderSegmentChildren = (direction, groups, splitButtonEnabled) => {
7861
7889
  childCount++;
7862
7890
  }
7863
7891
  if (segment.direction === undefined) {
7864
- children.push(...renderEditorGroup(segment.groups[0], segment.startIndex, splitButtonEnabled, sizeProperty));
7892
+ children.push(...renderEditorGroup(segment.groups[0], segment.startIndex, splitButtonEnabled, sizeProperty, true, tabDropIndicator));
7865
7893
  childCount++;
7866
7894
  continue;
7867
7895
  }
@@ -7884,7 +7912,7 @@ const renderSegmentChildren = (direction, groups, splitButtonEnabled) => {
7884
7912
  nestedChildren.push(...renderEditorGroup({
7885
7913
  ...group,
7886
7914
  size: normalizedSize
7887
- }, segment.startIndex + j, splitButtonEnabled, nestedSizeProperty));
7915
+ }, segment.startIndex + j, splitButtonEnabled, nestedSizeProperty, true, tabDropIndicator));
7888
7916
  nestedCount++;
7889
7917
  }
7890
7918
  children.push({
@@ -7903,14 +7931,14 @@ const renderSegmentChildren = (direction, groups, splitButtonEnabled) => {
7903
7931
  children
7904
7932
  };
7905
7933
  };
7906
- const getMainAreaVirtualDom = (layout, splitButtonEnabled = false, dragOverlay) => {
7934
+ const getMainAreaVirtualDom = (layout, splitButtonEnabled = false, dragOverlay, tabDropIndicator) => {
7907
7935
  const {
7908
7936
  direction,
7909
7937
  groups
7910
7938
  } = layout;
7911
7939
  const sizeProperty = getSizeProperty(direction);
7912
7940
  if (groups.length === 1) {
7913
- return addDragOverlay(renderSingleEditorGroup(layout, splitButtonEnabled, sizeProperty), dragOverlay);
7941
+ return addDragOverlay(renderSingleEditorGroup(layout, splitButtonEnabled, sizeProperty, tabDropIndicator), dragOverlay);
7914
7942
  }
7915
7943
  const editorGroupsContainerClassName = getContainerClassName(direction, groups.length);
7916
7944
  if (groups.length === 0) {
@@ -7926,7 +7954,7 @@ const getMainAreaVirtualDom = (layout, splitButtonEnabled = false, dragOverlay)
7926
7954
  const {
7927
7955
  childCount,
7928
7956
  children
7929
- } = renderSegmentChildren(direction, groups, splitButtonEnabled);
7957
+ } = renderSegmentChildren(direction, groups, splitButtonEnabled, tabDropIndicator);
7930
7958
  const sashCorner = getSashCorner(layout);
7931
7959
  const sashCornerChildren = sashCorner ? [renderSashCorner()] : [];
7932
7960
  return addDragOverlay([mainNode, {
@@ -7943,12 +7971,13 @@ const renderItems = (oldState, newState) => {
7943
7971
  initial,
7944
7972
  layout,
7945
7973
  splitButtonEnabled,
7974
+ tabDropIndicator,
7946
7975
  uid
7947
7976
  } = newState;
7948
7977
  if (initial) {
7949
7978
  return [SetDom2, uid, []];
7950
7979
  }
7951
- const dom = getMainAreaVirtualDom(layout, splitButtonEnabled, dragOverlay);
7980
+ const dom = getMainAreaVirtualDom(layout, splitButtonEnabled, dragOverlay, tabDropIndicator);
7952
7981
  return [SetDom2, uid, dom];
7953
7982
  };
7954
7983
 
@@ -8046,6 +8075,16 @@ const renderEventListeners = () => {
8046
8075
  }, {
8047
8076
  name: HandleTabsWheel,
8048
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
8049
8088
  }, {
8050
8089
  name: HandleDoubleClick,
8051
8090
  params: ['handleDoubleClick', 'event.target.dataset.groupIndex', 'event.target.dataset.index']
@@ -8322,6 +8361,31 @@ const saveState = state => {
8322
8361
  };
8323
8362
  };
8324
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
+
8325
8389
  const flipDirection = direction => {
8326
8390
  return direction === Horizontal ? Vertical : Horizontal;
8327
8391
  };
@@ -8611,6 +8675,7 @@ const commandMap = {
8611
8675
  'MainArea.focusPreviousTab': wrapSerialCommand(focusPreviousTab),
8612
8676
  'MainArea.getActiveEditorUid': wrapGetter(getActiveEditorUid),
8613
8677
  'MainArea.getCommandIds': getCommandIds,
8678
+ 'MainArea.getComponentState': getComponentState,
8614
8679
  'MainArea.getMenuEntries': wrapGetter(getMenuEntries),
8615
8680
  'MainArea.getMenuIds': getMenuIds,
8616
8681
  'MainArea.handleClick': wrapSerialCommand(handleClick),
@@ -8637,8 +8702,10 @@ const commandMap = {
8637
8702
  'MainArea.handleSashPointerMove': wrapSerialCommand(handleSashPointerMove),
8638
8703
  'MainArea.handleSashPointerUp': wrapSerialCommand(handleSashPointerUp),
8639
8704
  'MainArea.handleTabContextMenu': wrapSerialCommand(handleTabContextMenu),
8705
+ 'MainArea.handleTabDragOver': wrapSerialCommand(handleTabDragOver),
8640
8706
  'MainArea.handleTabKeyDown': wrapSerialCommand(handleTabKeyDown),
8641
8707
  'MainArea.handleTabMouseUp': wrapSerialCommand(resetPointerDown),
8708
+ 'MainArea.handleTabsDragOver': wrapSerialCommand(handleTabsDragOver),
8642
8709
  'MainArea.handleTabsWheel': wrapSerialCommand(handleTabsWheel),
8643
8710
  'MainArea.handleTestWorkerMessagePort': handleTestWorkerMessagePort,
8644
8711
  'MainArea.handleUriChange': wrapSerialCommand(handleUriChange),
@@ -8663,6 +8730,7 @@ const commandMap = {
8663
8730
  'MainArea.save': wrapSerialCommand(save),
8664
8731
  'MainArea.saveState': wrapGetter(saveState),
8665
8732
  'MainArea.selectTab': wrapSerialCommand(selectTab),
8733
+ 'MainArea.setComponentState': setComponentState,
8666
8734
  'MainArea.setEditorLayoutGrid': wrapSerialCommand(setEditorLayoutGrid),
8667
8735
  'MainArea.setEditorLayoutSingle': wrapSerialCommand(setEditorLayoutSingle),
8668
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.2",
3
+ "version": "9.56.0",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",