@lvce-editor/main-area-worker 8.7.0 → 8.8.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.
@@ -1746,7 +1746,7 @@ const createViewlet = async (viewletModuleId, editorUid, tabId, bounds, uri) =>
1746
1746
 
1747
1747
  const handleAttach = async command => {
1748
1748
  // TODO find a better way to append editors
1749
- const parentNodeSelector = '.editor-groups-container';
1749
+ const parentNodeSelector = '.editor-groups-container, .EditorGroup';
1750
1750
  await invoke('Layout.attachViewlet', parentNodeSelector, command.instanceId);
1751
1751
  };
1752
1752
 
@@ -2273,7 +2273,7 @@ const handleClick = async (state, name) => {
2273
2273
  return state;
2274
2274
  };
2275
2275
 
2276
- const closeEditorGroup = (state, groupId) => {
2276
+ const closeEditorGroup$1 = (state, groupId) => {
2277
2277
  const {
2278
2278
  layout
2279
2279
  } = state;
@@ -2915,7 +2915,7 @@ const handleClickAction = async (state, action, rawGroupId) => {
2915
2915
  if (rawGroupId) {
2916
2916
  const groupId = Number.parseInt(rawGroupId, 10);
2917
2917
  if (!Number.isNaN(groupId)) {
2918
- return closeEditorGroup(state, groupId);
2918
+ return closeEditorGroup$1(state, groupId);
2919
2919
  }
2920
2920
  }
2921
2921
  return state;
@@ -2972,7 +2972,10 @@ const handleDoubleClick = async state => {
2972
2972
  };
2973
2973
 
2974
2974
  const EditorGroupHeader = 'EditorGroupHeader';
2975
+ const EmptyGroupCloseButton = 'EmptyGroupCloseButton';
2975
2976
  const EditorGroup = 'EditorGroup';
2977
+ const EditorGroupsHorizontal = 'EditorGroupsHorizontal';
2978
+ const EditorGroupsVertical = 'EditorGroupsVertical';
2976
2979
  const EditorContainer = 'EditorContainer';
2977
2980
  const EditorGroupActions = 'EditorGroupActions';
2978
2981
  const EditorGroupActionButton = 'EditorGroupActionButton';
@@ -3619,6 +3622,7 @@ const i18nString = (key, placeholders = emptyObject) => {
3619
3622
  };
3620
3623
 
3621
3624
  const Close = 'Close';
3625
+ const CloseEditorGroup = 'Close Editor Group';
3622
3626
  const CloseAll = 'Close All';
3623
3627
  const CloseOthers = 'Close Others';
3624
3628
  const CloseToTheRight = 'Close To The Right';
@@ -3635,6 +3639,9 @@ const splitEditorGroup = () => {
3635
3639
  const close = () => {
3636
3640
  return i18nString(Close);
3637
3641
  };
3642
+ const closeEditorGroup = () => {
3643
+ return i18nString(CloseEditorGroup);
3644
+ };
3638
3645
  const closeOthers = () => {
3639
3646
  return i18nString(CloseOthers);
3640
3647
  };
@@ -4283,9 +4290,35 @@ const renderEditorGroupHeader = (group, groupIndex, splitButtonEnabled) => {
4283
4290
  }, ...getTabsVirtualDom(group, groupIndex, tabsChildCount), ...actions];
4284
4291
  };
4285
4292
 
4286
- const renderEditorGroup = (group, groupIndex, splitButtonEnabled = false, direction = 'horizontal') => {
4293
+ const renderEmptyGroupCloseButton = (group, groupIndex) => {
4294
+ return [{
4295
+ childCount: 1,
4296
+ className: EmptyGroupCloseButton,
4297
+ 'data-action': 'close-group',
4298
+ 'data-groupId': String(group.id),
4299
+ onClick: HandleClickAction,
4300
+ title: closeEditorGroup(),
4301
+ type: Button$2
4302
+ }, text('✕')];
4303
+ };
4304
+
4305
+ const renderEmptyEditorGroup = (group, groupIndex, style) => {
4306
+ return [{
4307
+ childCount: 1,
4308
+ className: EditorGroup,
4309
+ style,
4310
+ type: Div
4311
+ }, ...renderEmptyGroupCloseButton(group)];
4312
+ };
4313
+
4314
+ const renderEditorGroup = (group, groupIndex, splitButtonEnabled = false, sizeProperty = 'width') => {
4287
4315
  const activeTab = group.tabs.find(tab => tab.id === group.activeTabId);
4288
- const style = direction === 'horizontal' ? `width:${group.size}%;` : `height:${group.size}%;`;
4316
+ const style = `${sizeProperty}:${group.size}%;`;
4317
+ const hasTabs = group.tabs.length > 0;
4318
+ const hasEmptyGroupCloseButton = !hasTabs;
4319
+ if (hasEmptyGroupCloseButton) {
4320
+ return renderEmptyEditorGroup(group, groupIndex, style);
4321
+ }
4289
4322
  return [{
4290
4323
  childCount: 2,
4291
4324
  className: EditorGroup,
@@ -4301,7 +4334,7 @@ const renderEditorGroup = (group, groupIndex, splitButtonEnabled = false, direct
4301
4334
  const renderSash = (direction, sashId) => {
4302
4335
  return {
4303
4336
  childCount: 0,
4304
- className: direction === 'vertical' ? 'SashVertical' : 'SashHorizontal',
4337
+ className: direction === 'horizontal' ? 'SashVertical' : 'SashHorizontal',
4305
4338
  'data-sashId': sashId,
4306
4339
  onPointerDown: HandleSashPointerDown,
4307
4340
  onPointerMove: HandleSashPointerMove,
@@ -4311,7 +4344,18 @@ const renderSash = (direction, sashId) => {
4311
4344
  };
4312
4345
 
4313
4346
  const getMainAreaVirtualDom = (layout, splitButtonEnabled = false) => {
4347
+ const sizeProperty = layout.direction === 'vertical' ? 'height' : 'width';
4348
+ if (layout.groups.length === 1) {
4349
+ return [{
4350
+ childCount: 1,
4351
+ className: Main,
4352
+ type: Div
4353
+ }, ...renderEditorGroup(layout.groups[0], 0, splitButtonEnabled, sizeProperty)];
4354
+ }
4314
4355
  const children = [];
4356
+ const isSplit = layout.groups.length > 1;
4357
+ const directionClassName = isSplit ? layout.direction === 'horizontal' ? EditorGroupsVertical : EditorGroupsHorizontal : '';
4358
+ const editorGroupsContainerClassName = directionClassName ? `${EDITOR_GROUPS_CONTAINER} ${directionClassName}` : EDITOR_GROUPS_CONTAINER;
4315
4359
  for (let i = 0; i < layout.groups.length; i++) {
4316
4360
  if (i > 0) {
4317
4361
  // Insert sash between groups
@@ -4320,7 +4364,7 @@ const getMainAreaVirtualDom = (layout, splitButtonEnabled = false) => {
4320
4364
  const sashId = create(beforeGroupId, afterGroupId);
4321
4365
  children.push(renderSash(layout.direction, sashId));
4322
4366
  }
4323
- children.push(...renderEditorGroup(layout.groups[i], i, splitButtonEnabled, layout.direction));
4367
+ children.push(...renderEditorGroup(layout.groups[i], i, splitButtonEnabled, sizeProperty));
4324
4368
  }
4325
4369
  return [{
4326
4370
  childCount: 1,
@@ -4328,7 +4372,7 @@ const getMainAreaVirtualDom = (layout, splitButtonEnabled = false) => {
4328
4372
  type: Div
4329
4373
  }, {
4330
4374
  childCount: children.length,
4331
- className: EDITOR_GROUPS_CONTAINER,
4375
+ className: editorGroupsContainerClassName,
4332
4376
  role: None$1,
4333
4377
  type: Div
4334
4378
  }, ...children];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-area-worker",
3
- "version": "8.7.0",
3
+ "version": "8.8.0",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",