@lvce-editor/main-area-worker 8.15.0 → 8.17.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.
@@ -280,6 +280,44 @@ const closeOtherTabs = (state, groupId) => {
280
280
  };
281
281
  };
282
282
 
283
+ const getNextActiveTabId = (tabs, newTabs, activeTabId) => {
284
+ if (activeTabId === undefined) {
285
+ return undefined;
286
+ }
287
+ if (newTabs.some(tab => tab.id === activeTabId)) {
288
+ return activeTabId;
289
+ }
290
+ const activeTabIndex = tabs.findIndex(tab => tab.id === activeTabId);
291
+ if (activeTabIndex === -1 || newTabs.length === 0) {
292
+ return undefined;
293
+ }
294
+ return newTabs[Math.min(activeTabIndex, newTabs.length - 1)].id;
295
+ };
296
+ const closeSavedInGroup = group => {
297
+ const {
298
+ activeTabId,
299
+ tabs
300
+ } = group;
301
+ const newTabs = tabs.filter(tab => tab.isDirty);
302
+ if (newTabs.length === tabs.length) {
303
+ return group;
304
+ }
305
+ const newActiveTabId = getNextActiveTabId(tabs, newTabs, activeTabId);
306
+ return {
307
+ ...group,
308
+ activeTabId: newActiveTabId,
309
+ isEmpty: newTabs.length === 0,
310
+ tabs: newTabs
311
+ };
312
+ };
313
+ const closeSaved$1 = state => {
314
+ const {
315
+ groups
316
+ } = state.layout;
317
+ const newGroups = groups.map(closeSavedInGroup);
318
+ return withGroups(state, newGroups);
319
+ };
320
+
283
321
  const getGroupById = (state, groupId) => {
284
322
  return state.layout.groups.find(group => group.id === groupId);
285
323
  };
@@ -330,6 +368,7 @@ const Div = 4;
330
368
  const Span = 8;
331
369
  const Text = 12;
332
370
  const Img = 17;
371
+ const P = 50;
333
372
  const Pre = 51;
334
373
  const Reference = 100;
335
374
 
@@ -419,7 +458,7 @@ const Object$1 = 1;
419
458
  const Number$1 = 2;
420
459
  const Array$1 = 3;
421
460
  const String$1 = 4;
422
- const Boolean = 5;
461
+ const Boolean$1 = 5;
423
462
  const Function = 6;
424
463
  const Null = 7;
425
464
  const Unknown = 8;
@@ -440,7 +479,7 @@ const getType = value => {
440
479
  }
441
480
  return Object$1;
442
481
  case 'boolean':
443
- return Boolean;
482
+ return Boolean$1;
444
483
  default:
445
484
  return Unknown;
446
485
  }
@@ -2359,7 +2398,7 @@ const handleClickTogglePreview = async state => {
2359
2398
 
2360
2399
  const CloseGroup = 'close-group';
2361
2400
  const RetryOpen = 'retry-open';
2362
- const SplitRight = 'split-right';
2401
+ const SplitRight$1 = 'split-right';
2363
2402
  const TogglePreview$1 = 'toggle-preview';
2364
2403
 
2365
2404
  const getBasename$1 = uri => {
@@ -3007,7 +3046,7 @@ const handleClickAction = async (state, action, rawGroupId) => {
3007
3046
  return state;
3008
3047
  case RetryOpen:
3009
3048
  return retryOpen(state);
3010
- case SplitRight:
3049
+ case SplitRight$1:
3011
3050
  return splitEditorGroup$1(state, activeGroup.id, Right);
3012
3051
  case TogglePreview$1:
3013
3052
  return handleClickTogglePreview(state);
@@ -3072,8 +3111,8 @@ const MaskIconClose = 'MaskIcon MaskIconClose';
3072
3111
  const TextEditor = 'TextEditor';
3073
3112
  const TextEditorLoading = 'TextEditor TextEditor--loading';
3074
3113
  const EditorContentLoading = 'EditorContent EditorContent--loading';
3075
- const TextEditorError = 'TextEditor TextEditor--error';
3076
- const EditorContentError = 'EditorContent EditorContent--error';
3114
+ const TextEditorError = 'TextEditor TextEditorError';
3115
+ const EditorContentError = 'EditorContent EditorContentError';
3077
3116
  const Main = 'Main';
3078
3117
  const EDITOR_GROUPS_CONTAINER = 'editor-groups-container';
3079
3118
  const TabIcon = 'TabIcon';
@@ -3765,14 +3804,29 @@ const Close = 'Close';
3765
3804
  const CloseEditorGroup = 'Close Editor Group';
3766
3805
  const CloseAll = 'Close All';
3767
3806
  const CloseOthers = 'Close Others';
3807
+ const CloseSaved = 'Close Saved';
3768
3808
  const CloseToTheRight = 'Close To The Right';
3769
3809
  const CopyPath = 'Copy Path';
3770
3810
  const CopyRelativePath = 'Copy Relative Path';
3771
3811
  const FindFileReferences = 'Find File References';
3772
- const RevealInExplorer = 'Reveal in Explorer';
3812
+ const ReopenEditorWith = 'Reopen Editor With...';
3813
+ const Share = 'Share';
3814
+ const AddFileToChat = 'Add File to Chat';
3815
+ const OpenContainingFolder = 'Open Containing Folder';
3816
+ const RevealInExplorerView = 'Reveal in Explorer View';
3817
+ const KeepOpen = 'Keep Open';
3818
+ const Pin = 'Pin';
3819
+ const SplitAndMove = 'Split & Move';
3820
+ const MoveIntoNewWindow = 'Move into New Window';
3821
+ const CopyIntoNewWindow = 'Copy into New Window';
3773
3822
  const SplitEditorGroup = 'Split Editor Group';
3823
+ const SplitRight = 'Split Right';
3774
3824
  const TogglePreview = 'Toggle Preview';
3825
+ const Retry = 'Retry';
3775
3826
 
3827
+ const splitRight$1 = () => {
3828
+ return i18nString(SplitRight);
3829
+ };
3776
3830
  const splitEditorGroup = () => {
3777
3831
  return i18nString(SplitEditorGroup);
3778
3832
  };
@@ -3788,8 +3842,8 @@ const closeOthers = () => {
3788
3842
  const closeAll = () => {
3789
3843
  return i18nString(CloseAll);
3790
3844
  };
3791
- const revealInExplorer = () => {
3792
- return i18nString(RevealInExplorer);
3845
+ const closeSaved = () => {
3846
+ return i18nString(CloseSaved);
3793
3847
  };
3794
3848
  const closeToTheRight = () => {
3795
3849
  return i18nString(CloseToTheRight);
@@ -3803,9 +3857,42 @@ const copyPath = () => {
3803
3857
  const copyRelativePath = () => {
3804
3858
  return i18nString(CopyRelativePath);
3805
3859
  };
3860
+ const reopenEditorWith = () => {
3861
+ return i18nString(ReopenEditorWith);
3862
+ };
3863
+ const share = () => {
3864
+ return i18nString(Share);
3865
+ };
3866
+ const addFileToChat = () => {
3867
+ return i18nString(AddFileToChat);
3868
+ };
3869
+ const openContainingFolder = () => {
3870
+ return i18nString(OpenContainingFolder);
3871
+ };
3872
+ const revealInExplorerView = () => {
3873
+ return i18nString(RevealInExplorerView);
3874
+ };
3875
+ const keepOpen = () => {
3876
+ return i18nString(KeepOpen);
3877
+ };
3878
+ const pin = () => {
3879
+ return i18nString(Pin);
3880
+ };
3881
+ const splitAndMove = () => {
3882
+ return i18nString(SplitAndMove);
3883
+ };
3884
+ const moveIntoNewWindow = () => {
3885
+ return i18nString(MoveIntoNewWindow);
3886
+ };
3887
+ const copyIntoNewWindow = () => {
3888
+ return i18nString(CopyIntoNewWindow);
3889
+ };
3806
3890
  const togglePreview = () => {
3807
3891
  return i18nString(TogglePreview);
3808
3892
  };
3893
+ const retry = () => {
3894
+ return i18nString(Retry);
3895
+ };
3809
3896
 
3810
3897
  const menuEntrySeparator = {
3811
3898
  command: '',
@@ -3852,18 +3939,17 @@ const getMenuEntries$1 = state => {
3852
3939
  flags: None,
3853
3940
  id: 'tabCloseToTheRight',
3854
3941
  label: closeToTheRight()
3942
+ }, {
3943
+ command: 'Main.closeSaved',
3944
+ flags: None,
3945
+ id: 'tabCloseSaved',
3946
+ label: closeSaved()
3855
3947
  }, {
3856
3948
  command: 'Main.closeAll',
3857
3949
  flags: None,
3858
3950
  id: 'tabCloseAll',
3859
3951
  label: closeAll()
3860
3952
  }, menuEntrySeparator, {
3861
- args: [path],
3862
- command: 'Explorer.revealItem',
3863
- flags: None,
3864
- id: 'revealInExplorer',
3865
- label: revealInExplorer()
3866
- }, {
3867
3953
  args: [path],
3868
3954
  command: 'Main.copyPath',
3869
3955
  flags: None,
@@ -3875,6 +3961,62 @@ const getMenuEntries$1 = state => {
3875
3961
  flags: None,
3876
3962
  id: 'copyRelativePath',
3877
3963
  label: copyRelativePath()
3964
+ }, menuEntrySeparator, {
3965
+ command: '',
3966
+ flags: None,
3967
+ id: 'reopenEditorWith',
3968
+ label: reopenEditorWith()
3969
+ }, menuEntrySeparator, {
3970
+ command: '',
3971
+ flags: None,
3972
+ id: 'share',
3973
+ label: share()
3974
+ }, menuEntrySeparator, {
3975
+ command: '',
3976
+ flags: None,
3977
+ id: 'addFileToChat',
3978
+ label: addFileToChat()
3979
+ }, menuEntrySeparator, {
3980
+ command: '',
3981
+ flags: None,
3982
+ id: 'openContainingFolder',
3983
+ label: openContainingFolder()
3984
+ }, {
3985
+ args: [path],
3986
+ command: 'Explorer.revealItem',
3987
+ flags: None,
3988
+ id: 'revealInExplorerView',
3989
+ label: revealInExplorerView()
3990
+ }, menuEntrySeparator, {
3991
+ command: '',
3992
+ flags: None,
3993
+ id: 'keepOpen',
3994
+ label: keepOpen()
3995
+ }, {
3996
+ command: '',
3997
+ flags: None,
3998
+ id: 'pin',
3999
+ label: pin()
4000
+ }, menuEntrySeparator, {
4001
+ command: 'Main.splitRight',
4002
+ flags: None,
4003
+ id: 'splitRight',
4004
+ label: splitRight$1()
4005
+ }, {
4006
+ command: '',
4007
+ flags: None,
4008
+ id: 'splitAndMove',
4009
+ label: splitAndMove()
4010
+ }, {
4011
+ command: '',
4012
+ flags: None,
4013
+ id: 'moveIntoNewWindow',
4014
+ label: moveIntoNewWindow()
4015
+ }, {
4016
+ command: '',
4017
+ flags: None,
4018
+ id: 'copyIntoNewWindow',
4019
+ label: copyIntoNewWindow()
3878
4020
  }, menuEntrySeparator, {
3879
4021
  args: [/* id */'References', /* focus */true, path],
3880
4022
  command: 'SideBar.show',
@@ -3937,6 +4079,10 @@ const renderCss = (oldState, newState) => {
3937
4079
  return [SetCss, newState.uid, css];
3938
4080
  };
3939
4081
 
4082
+ const mergeClassNames = (...classNames) => {
4083
+ return classNames.filter(Boolean).join(' ');
4084
+ };
4085
+
3940
4086
  const text = data => {
3941
4087
  return {
3942
4088
  childCount: 0,
@@ -4264,14 +4410,17 @@ const renderError = errorMessage => {
4264
4410
  childCount: 2,
4265
4411
  className: EditorContentError,
4266
4412
  type: Div
4413
+ }, {
4414
+ childCount: 1,
4415
+ type: P
4267
4416
  }, text(`Error: ${errorMessage}`), {
4268
4417
  childCount: 1,
4269
- className: `${Button} ${ButtonSecondary}`,
4418
+ className: mergeClassNames(Button, ButtonSecondary),
4270
4419
  'data-action': RetryOpen,
4271
4420
  name: RetryOpen,
4272
4421
  onClick: HandleClickAction,
4273
4422
  type: Button$2
4274
- }, text('Retry')];
4423
+ }, text(retry())];
4275
4424
  };
4276
4425
 
4277
4426
  const renderLoading = () => {
@@ -4431,9 +4580,9 @@ const renderEditorGroupActions = (group, groupIndex, splitButtonEnabled) => {
4431
4580
  buttons.push({
4432
4581
  childCount: 1,
4433
4582
  className: EditorGroupActionButton + ' ' + SplitEditorGroupButton,
4434
- 'data-action': SplitRight,
4583
+ 'data-action': SplitRight$1,
4435
4584
  'data-groupId': String(group.id),
4436
- name: SplitRight,
4585
+ name: SplitRight$1,
4437
4586
  onClick: HandleClickAction,
4438
4587
  title: splitEditorGroup(),
4439
4588
  type: Button$2
@@ -4517,14 +4666,19 @@ const renderEditorGroup = (group, groupIndex, splitButtonEnabled = false, sizePr
4517
4666
  const getSashClassName = direction => {
4518
4667
  return direction === 'horizontal' ? 'Sash SashVertical' : 'Sash SashHorizontal';
4519
4668
  };
4669
+
4520
4670
  const renderSash = (direction, sashId, style) => {
4521
4671
  return [{
4522
- childCount: 0,
4672
+ childCount: 1,
4523
4673
  className: getSashClassName(direction),
4524
4674
  'data-sashId': sashId,
4525
4675
  onPointerDown: HandleSashPointerDown,
4526
4676
  style,
4527
4677
  type: Div
4678
+ }, {
4679
+ childCount: 0,
4680
+ className: 'SashBorder',
4681
+ type: Div
4528
4682
  }];
4529
4683
  };
4530
4684
 
@@ -4562,7 +4716,8 @@ const getMainAreaVirtualDom = (layout, splitButtonEnabled = false) => {
4562
4716
  children.push(...renderSash(direction, sashId, style));
4563
4717
  childCount++;
4564
4718
  }
4565
- children.push(...renderEditorGroup(groups[i], i, splitButtonEnabled, sizeProperty));
4719
+ const editorGroupDom = renderEditorGroup(groups[i], i, splitButtonEnabled, sizeProperty);
4720
+ children.push(...editorGroupDom);
4566
4721
  childCount++;
4567
4722
  }
4568
4723
  return [{
@@ -4794,6 +4949,7 @@ const commandMap = {
4794
4949
  'MainArea.closeAllEditors': wrapCommand(closeAll$1),
4795
4950
  'MainArea.closeFocusedTab': wrapCommand(closeFocusedTab),
4796
4951
  'MainArea.closeOthers': wrapCommand(closeOtherTabs),
4952
+ 'MainArea.closeSaved': wrapCommand(closeSaved$1),
4797
4953
  'MainArea.closeTabsRight': wrapCommand(closeTabsRight),
4798
4954
  'MainArea.copyPath': wrapCommand(copyPath$1),
4799
4955
  'MainArea.copyRelativePath': wrapCommand(copyRelativePath$1),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-area-worker",
3
- "version": "8.15.0",
3
+ "version": "8.17.0",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",