@opensumi/ide-main-layout 3.9.1-next-1749538805.0 → 3.9.1-next-1749540423.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.
Files changed (71) hide show
  1. package/README.md +31 -30
  2. package/lib/browser/accordion/accordion.service.d.ts +1 -9
  3. package/lib/browser/accordion/accordion.service.d.ts.map +1 -1
  4. package/lib/browser/accordion/accordion.service.js +33 -120
  5. package/lib/browser/accordion/accordion.service.js.map +1 -1
  6. package/lib/browser/accordion/accordion.view.d.ts.map +1 -1
  7. package/lib/browser/accordion/accordion.view.js +1 -4
  8. package/lib/browser/accordion/accordion.view.js.map +1 -1
  9. package/lib/browser/accordion/section.view.d.ts.map +1 -1
  10. package/lib/browser/accordion/section.view.js +1 -1
  11. package/lib/browser/accordion/section.view.js.map +1 -1
  12. package/lib/browser/accordion/styles.module.less +0 -61
  13. package/lib/browser/default-config.d.ts.map +1 -1
  14. package/lib/browser/default-config.js +6 -7
  15. package/lib/browser/default-config.js.map +1 -1
  16. package/lib/browser/drop-area/drop-area.d.ts +2 -3
  17. package/lib/browser/drop-area/drop-area.d.ts.map +1 -1
  18. package/lib/browser/drop-area/drop-area.js +5 -8
  19. package/lib/browser/drop-area/drop-area.js.map +1 -1
  20. package/lib/browser/index.d.ts.map +1 -1
  21. package/lib/browser/index.js.map +1 -1
  22. package/lib/browser/layout.service.d.ts +0 -4
  23. package/lib/browser/layout.service.d.ts.map +1 -1
  24. package/lib/browser/layout.service.js +79 -140
  25. package/lib/browser/layout.service.js.map +1 -1
  26. package/lib/browser/main-layout.contribution.d.ts +18 -2
  27. package/lib/browser/main-layout.contribution.d.ts.map +1 -1
  28. package/lib/browser/main-layout.contribution.js +131 -75
  29. package/lib/browser/main-layout.contribution.js.map +1 -1
  30. package/lib/browser/tabbar/bar.view.d.ts.map +1 -1
  31. package/lib/browser/tabbar/bar.view.js +10 -5
  32. package/lib/browser/tabbar/bar.view.js.map +1 -1
  33. package/lib/browser/tabbar/panel.view.js +2 -2
  34. package/lib/browser/tabbar/panel.view.js.map +1 -1
  35. package/lib/browser/tabbar/renderer.view.js +4 -4
  36. package/lib/browser/tabbar/renderer.view.js.map +1 -1
  37. package/lib/browser/tabbar/tabbar.service.d.ts +19 -8
  38. package/lib/browser/tabbar/tabbar.service.d.ts.map +1 -1
  39. package/lib/browser/tabbar/tabbar.service.js +148 -39
  40. package/lib/browser/tabbar/tabbar.service.js.map +1 -1
  41. package/lib/common/main-layout.definition.d.ts +3 -4
  42. package/lib/common/main-layout.definition.d.ts.map +1 -1
  43. package/lib/common/main-layout.definition.js +4 -5
  44. package/lib/common/main-layout.definition.js.map +1 -1
  45. package/package.json +8 -8
  46. package/src/browser/accordion/accordion.service.ts +35 -152
  47. package/src/browser/accordion/accordion.view.tsx +2 -4
  48. package/src/browser/accordion/section.view.tsx +1 -5
  49. package/src/browser/accordion/styles.module.less +0 -61
  50. package/src/browser/default-config.ts +7 -8
  51. package/src/browser/drop-area/drop-area.tsx +3 -6
  52. package/src/browser/index.ts +0 -1
  53. package/src/browser/layout.service.ts +67 -156
  54. package/src/browser/main-layout.contribution.ts +138 -93
  55. package/src/browser/tabbar/bar.view.tsx +14 -9
  56. package/src/browser/tabbar/panel.view.tsx +2 -2
  57. package/src/browser/tabbar/renderer.view.tsx +4 -4
  58. package/src/browser/tabbar/tabbar.service.ts +163 -54
  59. package/src/common/main-layout.definition.ts +4 -6
  60. package/lib/browser/command.d.ts +0 -29
  61. package/lib/browser/command.d.ts.map +0 -1
  62. package/lib/browser/command.js +0 -84
  63. package/lib/browser/command.js.map +0 -1
  64. package/lib/browser/tabbar/TABBAR_CONFIG_USAGE.md +0 -141
  65. package/lib/browser/tabbar/tabbar-behavior-handler.d.ts +0 -71
  66. package/lib/browser/tabbar/tabbar-behavior-handler.d.ts.map +0 -1
  67. package/lib/browser/tabbar/tabbar-behavior-handler.js +0 -210
  68. package/lib/browser/tabbar/tabbar-behavior-handler.js.map +0 -1
  69. package/src/browser/command.ts +0 -99
  70. package/src/browser/tabbar/TABBAR_CONFIG_USAGE.md +0 -141
  71. package/src/browser/tabbar/tabbar-behavior-handler.ts +0 -260
@@ -14,6 +14,7 @@ import {
14
14
  IScopedContextKeyService,
15
15
  KeybindingRegistry,
16
16
  ResizeEvent,
17
+ SlotLocation,
17
18
  ViewContextKeyRegistry,
18
19
  WithEventBus,
19
20
  createFormatLocalizedStr,
@@ -25,6 +26,7 @@ import {
25
26
  localize,
26
27
  toDisposable,
27
28
  } from '@opensumi/ide-core-browser';
29
+ import { SCM_CONTAINER_ID } from '@opensumi/ide-core-browser/lib/common/container-id';
28
30
  import { ResizeHandle } from '@opensumi/ide-core-browser/lib/components';
29
31
  import { LAYOUT_STATE, LayoutState } from '@opensumi/ide-core-browser/lib/layout/layout-state';
30
32
  import {
@@ -36,11 +38,10 @@ import {
36
38
  IMenuRegistry,
37
39
  MenuId,
38
40
  generateCtxMenu,
41
+ getTabbarCommonMenuId,
39
42
  } from '@opensumi/ide-core-browser/lib/menu/next';
40
43
  import { IProgressService } from '@opensumi/ide-core-browser/lib/progress';
41
- import { slotRendererRegistry } from '@opensumi/ide-core-browser/lib/react-providers';
42
44
  import {
43
- ITransaction,
44
45
  autorunDelta,
45
46
  derivedOpts,
46
47
  observableFromEventOpts,
@@ -48,9 +49,8 @@ import {
48
49
  transaction,
49
50
  } from '@opensumi/ide-monaco/lib/common/observable';
50
51
 
51
- import { IMainLayoutService, TabBarRegistrationEvent } from '../../common';
52
-
53
- import { ITabbarResizeOptions, TabbarBehaviorHandler } from './tabbar-behavior-handler';
52
+ import { IMainLayoutService, SUPPORT_ACCORDION_LOCATION, TabBarRegistrationEvent } from '../../common';
53
+ import { EXPAND_BOTTOM_PANEL, RETRACT_BOTTOM_PANEL, TOGGLE_BOTTOM_PANEL_COMMAND } from '../main-layout.contribution';
54
54
 
55
55
  import type { ViewBadge } from 'vscode';
56
56
 
@@ -65,6 +65,11 @@ export interface TabState {
65
65
  // 排序位置,数字越小优先级越高
66
66
  priority: number;
67
67
  }
68
+ const CONTAINER_NAME_MAP = {
69
+ left: 'view',
70
+ right: 'extendView',
71
+ bottom: 'panel',
72
+ };
68
73
 
69
74
  const NONE_CONTAINER_ID = undefined;
70
75
 
@@ -99,15 +104,21 @@ export class TabbarService extends WithEventBus {
99
104
  public previousContainerId: string | undefined = undefined;
100
105
  public containersMap: Map<string, ComponentRegistryProvider> = new Map();
101
106
  public prevSize?: number;
102
- public commonTitleMenu?: IContextMenu;
107
+ public commonTitleMenu: IContextMenu;
103
108
  public viewReady = new Deferred<void>();
104
109
 
105
110
  private state: Map<string, TabState> = new Map();
106
111
  private storedState: { [containerId: string]: TabState } = {};
107
112
 
108
- private behaviorHandler: TabbarBehaviorHandler;
109
-
110
- public resizeHandle?: ITabbarResizeOptions;
113
+ resizeHandle?: {
114
+ setSize: (targetSize?: number) => void;
115
+ setRelativeSize: (prev: number, next: number) => void;
116
+ getSize: () => number;
117
+ getRelativeSize: () => number[];
118
+ lockSize: (lock: boolean | undefined) => void;
119
+ setMaxSize: (lock: boolean | undefined) => void;
120
+ hidePanel: (show?: boolean) => void;
121
+ };
111
122
 
112
123
  @Autowired(AbstractMenuService)
113
124
  protected menuService: AbstractMenuService;
@@ -142,6 +153,8 @@ export class TabbarService extends WithEventBus {
142
153
  @Autowired(IProgressService)
143
154
  private progressService: IProgressService;
144
155
 
156
+ private accordionRestored: Set<string> = new Set();
157
+
145
158
  private readonly onCurrentChangeEmitter = new Emitter<{ previousId: string; currentId: string }>();
146
159
  readonly onCurrentChange: Event<{ previousId: string; currentId: string }> = this.onCurrentChangeEmitter.event;
147
160
 
@@ -157,6 +170,7 @@ export class TabbarService extends WithEventBus {
157
170
  private disposableMap: Map<string, DisposableCollection> = new Map();
158
171
  private tabInMoreKeyMap: Map<string, IContextKey<boolean>> = new Map();
159
172
  private shouldWaitForViewRender = false;
173
+ private isLatter: boolean;
160
174
 
161
175
  private scopedCtxKeyService: IScopedContextKeyService;
162
176
  private onDidRegisterContainerEmitter = new Emitter<string>();
@@ -164,10 +178,7 @@ export class TabbarService extends WithEventBus {
164
178
 
165
179
  constructor(public location: string) {
166
180
  super();
167
- // 从插槽渲染器注册表获取配置,创建行为处理器
168
- const tabbarConfig = slotRendererRegistry.getTabbarConfig(location);
169
- this.behaviorHandler = new TabbarBehaviorHandler(location, tabbarConfig);
170
-
181
+ this.setIsLatter(location === SlotLocation.right || location === SlotLocation.bottom);
171
182
  this.scopedCtxKeyService = this.contextKeyService.createScoped();
172
183
  this.scopedCtxKeyService.createKey('triggerWithTab', true);
173
184
  this.menuRegistry.registerMenuItem(this.menuId, {
@@ -179,17 +190,10 @@ export class TabbarService extends WithEventBus {
179
190
  when: 'triggerWithTab == true',
180
191
  });
181
192
  this.activatedKey = this.contextKeyService.createKey(getTabbarCtxKey(this.location), '');
182
-
183
- // 使用行为处理器注册特定位置的命令和菜单
184
- this.behaviorHandler.registerLocationSpecificCommands({
185
- commandRegistry: this.commandRegistry,
186
- layoutService: this.layoutService,
187
- });
188
-
189
- this.commonTitleMenu = this.behaviorHandler.registerLocationSpecificMenus({
190
- menuRegistry: this.menuRegistry,
191
- ctxMenuService: this.ctxMenuService,
192
- });
193
+ if (this.location === 'bottom') {
194
+ this.registerPanelCommands();
195
+ this.registerPanelMenus();
196
+ }
193
197
 
194
198
  this.eventBus.onDirective(ResizeEvent.createDirective(this.location), () => {
195
199
  this.onResize();
@@ -200,6 +204,10 @@ export class TabbarService extends WithEventBus {
200
204
  return this.onDidRegisterContainerEmitter.event;
201
205
  }
202
206
 
207
+ public setIsLatter(v: boolean) {
208
+ this.isLatter = v;
209
+ }
210
+
203
211
  updateNextContainerId(nextContainerId?: string) {
204
212
  if (isUndefined(nextContainerId)) {
205
213
  this.useFirstContainerId = true;
@@ -208,14 +216,10 @@ export class TabbarService extends WithEventBus {
208
216
  }
209
217
  }
210
218
 
211
- updateCurrentContainerId(containerId: string, tx?: ITransaction) {
212
- if (tx) {
219
+ updateCurrentContainerId(containerId: string) {
220
+ transaction((tx) => {
213
221
  this.containerIdObs.set(containerId, tx);
214
- } else {
215
- transaction((tx) => {
216
- this.containerIdObs.set(containerId, tx);
217
- });
218
- }
222
+ });
219
223
  }
220
224
 
221
225
  updateBadge(containerId: string, value?: ViewBadge | string) {
@@ -226,6 +230,24 @@ export class TabbarService extends WithEventBus {
226
230
  component?.fireChange(component);
227
231
  }
228
232
 
233
+ registerPanelCommands(): void {
234
+ this.commandRegistry.registerCommand(EXPAND_BOTTOM_PANEL, {
235
+ execute: () => {
236
+ this.layoutService.expandBottom(true);
237
+ },
238
+ });
239
+ this.commandRegistry.registerCommand(RETRACT_BOTTOM_PANEL, {
240
+ execute: () => {
241
+ this.layoutService.expandBottom(false);
242
+ },
243
+ });
244
+ this.commandRegistry.registerCommand(TOGGLE_BOTTOM_PANEL_COMMAND, {
245
+ execute: (show?: boolean, size?: number) => {
246
+ this.layoutService.toggleSlot(SlotLocation.bottom, show, size);
247
+ },
248
+ });
249
+ }
250
+
229
251
  public getContainerState(containerId: string) {
230
252
  const viewState = this.state.get(containerId);
231
253
  return viewState!;
@@ -323,7 +345,16 @@ export class TabbarService extends WithEventBus {
323
345
  }
324
346
 
325
347
  registerResizeHandle(resizeHandle: ResizeHandle) {
326
- this.resizeHandle = this.behaviorHandler.wrapResizeHandle(resizeHandle);
348
+ const { setSize, setRelativeSize, getSize, getRelativeSize, lockSize, setMaxSize, hidePanel } = resizeHandle;
349
+ this.resizeHandle = {
350
+ setSize: (size) => setSize(size, this.isLatter),
351
+ setRelativeSize: (prev: number, next: number) => setRelativeSize(prev, next, this.isLatter),
352
+ getSize: () => getSize(this.isLatter),
353
+ getRelativeSize: () => getRelativeSize(this.isLatter),
354
+ setMaxSize: (lock: boolean | undefined) => setMaxSize(lock, this.isLatter),
355
+ lockSize: (lock: boolean | undefined) => lockSize(lock, this.isLatter),
356
+ hidePanel: (show) => hidePanel(show),
357
+ };
327
358
  return this.listenCurrentChange();
328
359
  }
329
360
 
@@ -410,7 +441,7 @@ export class TabbarService extends WithEventBus {
410
441
  disposables.push(this.registerActivateKeyBinding(componentInfo, componentInfo.options!.fromExtension));
411
442
  // 注册视图是否存在的contextKey
412
443
  const containerExistKey = this.contextKeyService.createKey<boolean>(
413
- `workbench.${this.location}.${componentInfo.options!.containerId}`,
444
+ `workbench.${CONTAINER_NAME_MAP[this.location] || 'view'}.${componentInfo.options!.containerId}`,
414
445
  true,
415
446
  );
416
447
  disposables.push({
@@ -572,11 +603,28 @@ export class TabbarService extends WithEventBus {
572
603
  }
573
604
 
574
605
  doExpand(expand: boolean) {
575
- this.behaviorHandler.doExpand(expand, this.resizeHandle);
606
+ if (this.resizeHandle) {
607
+ const { setRelativeSize } = this.resizeHandle;
608
+ if (expand) {
609
+ if (!this.isLatter) {
610
+ setRelativeSize(1, 0);
611
+ } else {
612
+ setRelativeSize(0, 1);
613
+ }
614
+ } else {
615
+ // FIXME 底部需要额外的字段记录展开前的尺寸
616
+ setRelativeSize(2, 1);
617
+ }
618
+ }
576
619
  }
577
620
 
578
621
  get isExpanded(): boolean {
579
- return this.behaviorHandler.isExpanded(this.resizeHandle);
622
+ if (this.resizeHandle) {
623
+ const { getRelativeSize } = this.resizeHandle;
624
+ const relativeSizes = getRelativeSize().join(',');
625
+ return this.isLatter ? relativeSizes === '0,1' : relativeSizes === '1,0';
626
+ }
627
+ return false;
580
628
  }
581
629
 
582
630
  handleTabClick(e: React.MouseEvent, forbidCollapse?: boolean) {
@@ -647,19 +695,23 @@ export class TabbarService extends WithEventBus {
647
695
  }
648
696
  }
649
697
  this.visibleContainers.forEach((container) => {
650
- this.tryRestoreAccordionSize(container);
698
+ if (SUPPORT_ACCORDION_LOCATION.has(this.location)) {
699
+ this.tryRestoreAccordionSize(container.options!.containerId);
700
+ }
651
701
  });
652
702
  }
653
703
 
654
704
  removeContainer(containerId: string) {
655
705
  const disposable = this.disposableMap.get(containerId);
656
706
  disposable?.dispose();
657
- this.onStateChangeEmitter.fire();
707
+ this.updateCurrentContainerId('');
708
+ this.doChangeViewEmitter.fire();
658
709
  }
659
710
 
660
711
  dynamicAddContainer(containerId: string, options: ComponentRegistryInfo) {
661
712
  this.registerContainer(containerId, options);
662
713
  this.updateCurrentContainerId(containerId);
714
+ this.doChangeViewEmitter.fire();
663
715
  }
664
716
 
665
717
  protected doInsertTab(containers: ComponentRegistryInfo[], sourceIndex: number, targetIndex: number) {
@@ -710,12 +762,12 @@ export class TabbarService extends WithEventBus {
710
762
  },
711
763
  {
712
764
  execute: ({ forceShow }: { forceShow?: boolean } = {}) => {
713
- this.behaviorHandler.handleActivateKeyBinding(
714
- containerId,
715
- this.currentContainerId.get() || '',
716
- (id: string) => this.updateCurrentContainerId(id),
717
- forceShow,
718
- );
765
+ // 支持toggle
766
+ if (this.location === 'bottom' && !forceShow) {
767
+ this.updateCurrentContainerId(this.currentContainerId.get() === containerId ? '' : containerId);
768
+ } else {
769
+ this.updateCurrentContainerId(containerId);
770
+ }
719
771
  },
720
772
  },
721
773
  ),
@@ -806,6 +858,31 @@ export class TabbarService extends WithEventBus {
806
858
  return `${containerId}.isInMore`;
807
859
  }
808
860
 
861
+ protected registerPanelMenus() {
862
+ this.menuRegistry.registerMenuItems(getTabbarCommonMenuId('bottom'), [
863
+ {
864
+ command: EXPAND_BOTTOM_PANEL.id,
865
+ group: 'navigation',
866
+ when: '!bottomFullExpanded',
867
+ order: 1,
868
+ },
869
+ {
870
+ command: RETRACT_BOTTOM_PANEL.id,
871
+ group: 'navigation',
872
+ when: 'bottomFullExpanded',
873
+ order: 1,
874
+ },
875
+ {
876
+ command: TOGGLE_BOTTOM_PANEL_COMMAND.id,
877
+ group: 'navigation',
878
+ order: 2,
879
+ },
880
+ ]);
881
+ this.commonTitleMenu = this.ctxMenuService.createMenu({
882
+ id: 'tabbar/bottom/common',
883
+ });
884
+ }
885
+
809
886
  protected doToggleTab(containerId: string, forceShow?: boolean) {
810
887
  const state = this.getContainerState(containerId);
811
888
  if (forceShow === undefined) {
@@ -821,9 +898,9 @@ export class TabbarService extends WithEventBus {
821
898
  this.storeState();
822
899
  }
823
900
 
824
- protected shouldExpand(containerId: string | undefined): boolean {
901
+ protected shouldExpand(containerId: string | undefined) {
825
902
  const info = this.getContainer(containerId);
826
- return !!(info && info.options && info.options.expanded);
903
+ return info && info.options && info.options.expanded;
827
904
  }
828
905
 
829
906
  protected onResize() {
@@ -849,19 +926,15 @@ export class TabbarService extends WithEventBus {
849
926
  }
850
927
 
851
928
  private handleChange(currentId, previousId) {
852
- // 这里的 handleChange 是会在 registerResizeHandle 后才会执行, currentId 为 undefined 只会在 autorun 首次注册时执行
853
- if (!this.resizeHandle || currentId === undefined) {
929
+ // 这里的 handleChange 是会在 registerResizeHandle 后才会执行
930
+ if (!this.resizeHandle) {
854
931
  return;
855
932
  }
856
933
  const { getSize, setSize, lockSize } = this.resizeHandle;
857
934
  this.onCurrentChangeEmitter.fire({ previousId, currentId });
858
935
  const isCurrentExpanded = this.shouldExpand(currentId);
859
936
  if (this.shouldExpand(this.previousContainerId) || isCurrentExpanded) {
860
- this.behaviorHandler.handleFullExpanded(currentId, isCurrentExpanded, this.resizeHandle, {
861
- barSize: this.barSize,
862
- panelSize: this.panelSize,
863
- prevSize: this.prevSize,
864
- });
937
+ this.handleFullExpanded(currentId, isCurrentExpanded);
865
938
  } else {
866
939
  if (currentId) {
867
940
  if (previousId && currentId !== previousId) {
@@ -880,7 +953,43 @@ export class TabbarService extends WithEventBus {
880
953
  }
881
954
  }
882
955
 
883
- protected tryRestoreAccordionSize(containerInfo: ComponentRegistryProvider) {
884
- this.behaviorHandler.tryRestoreAccordionSize(containerInfo, this.layoutService);
956
+ protected tryRestoreAccordionSize(containerId: string) {
957
+ if (this.accordionRestored.has(containerId)) {
958
+ return;
959
+ }
960
+ const containerInfo = this.containersMap.get(containerId);
961
+ // 使用自定义视图取代手风琴的面板不需要 restore
962
+ // scm 视图例外,因为在新版本 Gitlens 中可以将自己注册到 scm 中
963
+ // 暂时用这种方式使 scm 面板状态可以被持久化
964
+ if (
965
+ (!containerInfo || containerInfo.options?.component) &&
966
+ containerInfo?.options?.containerId !== SCM_CONTAINER_ID
967
+ ) {
968
+ return;
969
+ }
970
+ const accordionService = this.layoutService.getAccordionService(containerId);
971
+ // 需要保证此时tab切换已完成dom渲染
972
+ accordionService.restoreState();
973
+ this.accordionRestored.add(containerId);
974
+ }
975
+
976
+ protected handleFullExpanded(currentId: string, isCurrentExpanded?: boolean) {
977
+ if (!this.resizeHandle) {
978
+ return;
979
+ }
980
+ const { setRelativeSize, setSize } = this.resizeHandle;
981
+ if (currentId) {
982
+ if (isCurrentExpanded) {
983
+ if (!this.isLatter) {
984
+ setRelativeSize(1, 0);
985
+ } else {
986
+ setRelativeSize(0, 1);
987
+ }
988
+ } else {
989
+ setSize(this.prevSize || this.panelSize + this.barSize);
990
+ }
991
+ } else {
992
+ setSize(this.barSize);
993
+ }
885
994
  }
886
995
  }
@@ -1,5 +1,4 @@
1
1
  import { BasicEvent, IDisposable, SlotLocation } from '@opensumi/ide-core-browser';
2
- import { Layout } from '@opensumi/ide-core-browser/lib/components';
3
2
  import { SideStateManager, View, ViewContainerOptions } from '@opensumi/ide-core-browser/lib/layout';
4
3
  import { ComponentRegistryInfo } from '@opensumi/ide-core-browser/lib/layout/layout.interface';
5
4
  import { IContextMenu } from '@opensumi/ide-core-browser/lib/menu/next';
@@ -42,7 +41,7 @@ export interface IMainLayoutService {
42
41
  * 注册单个或多个视图到tabbar位置
43
42
  * @param views 使用手风琴能力时传入的多个子视图
44
43
  * @param options container相关选项
45
- * @param side 注册的位置,支持 view、extendView、panel,对应之前的 left、right、bottom
44
+ * @param side 注册的位置,支持left、right、bottom
46
45
  */
47
46
  collectTabbarComponent(views: View[], options: ViewContainerOptions, side: string): string;
48
47
 
@@ -132,8 +131,7 @@ export class ViewCollapseChangedEvent extends BasicEvent<{
132
131
  collapsed: boolean;
133
132
  }> {}
134
133
 
135
- export const SUPPORT_ACCORDION_LOCATION = new Set([SlotLocation.view, SlotLocation.extendView]);
134
+ export const SUPPORT_ACCORDION_LOCATION = new Set([SlotLocation.left, SlotLocation.right]);
136
135
 
137
- export const DROP_PANEL_CONTAINER = 'drop-panel';
138
- export const DROP_EXTEND_VIEW_CONTAINER = 'drop-extend-view';
139
- export const DROP_VIEW_CONTAINER = 'drop-view';
136
+ export const DROP_BOTTOM_CONTAINER = 'drop-bottom';
137
+ export const DROP_RIGHT_CONTAINER = 'drop-right';
@@ -1,29 +0,0 @@
1
- import { Command } from '@opensumi/ide-core-browser';
2
- import { MenuCommandDesc } from '@opensumi/ide-core-browser/lib/menu/next';
3
- /** @deprecated 请使用 main-layout.view.toggle */
4
- export declare const TOGGLE_LEFT_PANEL_COMMAND: Command;
5
- /** @deprecated 请使用 main-layout.extendView.toggle */
6
- export declare const TOGGLE_RIGHT_PANEL_COMMAND: Command;
7
- /** @deprecated 请使用 main-layout.panel.toggle */
8
- export declare const TOGGLE_BOTTOM_PANEL_COMMAND: Command;
9
- /** @deprecated 请使用 main-layout.panel.is-visible */
10
- export declare const IS_VISIBLE_BOTTOM_PANEL_COMMAND: Command;
11
- /** @deprecated 请使用 main-layout.view.is-visible */
12
- export declare const IS_VISIBLE_LEFT_PANEL_COMMAND: Command;
13
- /** @deprecated 请使用 main-layout.extend-view.is-visible */
14
- export declare const IS_VISIBLE_RIGHT_PANEL_COMMAND: Command;
15
- /** @deprecated 请使用 main-layout.panel.expand */
16
- export declare const EXPAND_BOTTOM_PANEL: Command;
17
- /** @deprecated 请使用 main-layout.panel.retract */
18
- export declare const RETRACT_BOTTOM_PANEL: Command;
19
- export declare const WORKBENCH_ACTION_CLOSESIDECAR: Command;
20
- export declare const WORKBENCH_ACTION_CLOSEPANEL: Command;
21
- export declare const TOGGLE_VIEW_COMMAND: MenuCommandDesc;
22
- export declare const TOGGLE_EXTEND_VIEW_COMMAND: MenuCommandDesc;
23
- export declare const TOGGLE_PANEL_COMMAND: Command;
24
- export declare const IS_VISIBLE_VIEW_COMMAND: Command;
25
- export declare const IS_VISIBLE_EXTEND_VIEW_COMMAND: Command;
26
- export declare const IS_VISIBLE_PANEL_COMMAND: Command;
27
- export declare const EXPAND_PANEL_COMMAND: Command;
28
- export declare const RETRACT_PANEL_COMMAND: Command;
29
- //# sourceMappingURL=command.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/browser/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAW,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAE3E,8CAA8C;AAC9C,eAAO,MAAM,yBAAyB,EAAE,OAGvC,CAAC;AAEF,oDAAoD;AACpD,eAAO,MAAM,0BAA0B,EAAE,OAGxC,CAAC;AAEF,+CAA+C;AAC/C,eAAO,MAAM,2BAA2B,EAAE,OAGzC,CAAC;AAEF,mDAAmD;AACnD,eAAO,MAAM,+BAA+B,EAAE,OAG7C,CAAC;AAEF,kDAAkD;AAClD,eAAO,MAAM,6BAA6B,EAAE,OAG3C,CAAC;AAEF,yDAAyD;AACzD,eAAO,MAAM,8BAA8B,EAAE,OAG5C,CAAC;AAEF,+CAA+C;AAC/C,eAAO,MAAM,mBAAmB,EAAE,OAGjC,CAAC;AAEF,gDAAgD;AAChD,eAAO,MAAM,oBAAoB,EAAE,OAGlC,CAAC;AAEF,eAAO,MAAM,6BAA6B,EAAE,OAG3C,CAAC;AAEF,eAAO,MAAM,2BAA2B,EAAE,OAEzC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,eAGjC,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,eAGxC,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,OAIlC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,OAErC,CAAC;AAEF,eAAO,MAAM,8BAA8B,EAAE,OAE5C,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,OAEtC,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,OAIlC,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,OAInC,CAAC"}
@@ -1,84 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RETRACT_PANEL_COMMAND = exports.EXPAND_PANEL_COMMAND = exports.IS_VISIBLE_PANEL_COMMAND = exports.IS_VISIBLE_EXTEND_VIEW_COMMAND = exports.IS_VISIBLE_VIEW_COMMAND = exports.TOGGLE_PANEL_COMMAND = exports.TOGGLE_EXTEND_VIEW_COMMAND = exports.TOGGLE_VIEW_COMMAND = exports.WORKBENCH_ACTION_CLOSEPANEL = exports.WORKBENCH_ACTION_CLOSESIDECAR = exports.RETRACT_BOTTOM_PANEL = exports.EXPAND_BOTTOM_PANEL = exports.IS_VISIBLE_RIGHT_PANEL_COMMAND = exports.IS_VISIBLE_LEFT_PANEL_COMMAND = exports.IS_VISIBLE_BOTTOM_PANEL_COMMAND = exports.TOGGLE_BOTTOM_PANEL_COMMAND = exports.TOGGLE_RIGHT_PANEL_COMMAND = exports.TOGGLE_LEFT_PANEL_COMMAND = void 0;
4
- const ide_core_browser_1 = require("@opensumi/ide-core-browser");
5
- /** @deprecated 请使用 main-layout.view.toggle */
6
- exports.TOGGLE_LEFT_PANEL_COMMAND = {
7
- id: 'main-layout.left-panel.toggle',
8
- delegate: 'main-layout.view.toggle',
9
- };
10
- /** @deprecated 请使用 main-layout.extendView.toggle */
11
- exports.TOGGLE_RIGHT_PANEL_COMMAND = {
12
- id: 'main-layout.right-panel.toggle',
13
- delegate: 'main-layout.extend-view.toggle',
14
- };
15
- /** @deprecated 请使用 main-layout.panel.toggle */
16
- exports.TOGGLE_BOTTOM_PANEL_COMMAND = {
17
- id: 'main-layout.bottom-panel.toggle',
18
- delegate: 'main-layout.panel.toggle',
19
- };
20
- /** @deprecated 请使用 main-layout.panel.is-visible */
21
- exports.IS_VISIBLE_BOTTOM_PANEL_COMMAND = {
22
- id: 'main-layout.bottom-panel.is-visible',
23
- delegate: 'main-layout.panel.is-visible',
24
- };
25
- /** @deprecated 请使用 main-layout.view.is-visible */
26
- exports.IS_VISIBLE_LEFT_PANEL_COMMAND = {
27
- id: 'main-layout.left-panel.is-visible',
28
- delegate: 'main-layout.view.is-visible',
29
- };
30
- /** @deprecated 请使用 main-layout.extend-view.is-visible */
31
- exports.IS_VISIBLE_RIGHT_PANEL_COMMAND = {
32
- id: 'main-layout.right-panel.is-visible',
33
- delegate: 'main-layout.extend-view.is-visible',
34
- };
35
- /** @deprecated 请使用 main-layout.panel.expand */
36
- exports.EXPAND_BOTTOM_PANEL = {
37
- id: 'main-layout.bottom-panel.expand',
38
- delegate: 'main-layout.panel.expand',
39
- };
40
- /** @deprecated 请使用 main-layout.panel.retract */
41
- exports.RETRACT_BOTTOM_PANEL = {
42
- id: 'main-layout.bottom-panel.retract',
43
- delegate: 'main-layout.panel.retract',
44
- };
45
- exports.WORKBENCH_ACTION_CLOSESIDECAR = {
46
- id: 'workbench.action.closeSidebar',
47
- label: '%main-layout.sidebar.hide%',
48
- };
49
- exports.WORKBENCH_ACTION_CLOSEPANEL = {
50
- id: 'workbench.action.closePanel',
51
- };
52
- exports.TOGGLE_VIEW_COMMAND = {
53
- id: 'main-layout.view.toggle',
54
- label: '%main-layout.view.toggle%',
55
- };
56
- exports.TOGGLE_EXTEND_VIEW_COMMAND = {
57
- id: 'main-layout.extend-view.toggle',
58
- label: '%main-layout.extend-view.toggle%',
59
- };
60
- exports.TOGGLE_PANEL_COMMAND = {
61
- id: 'main-layout.panel.toggle',
62
- iconClass: (0, ide_core_browser_1.getIcon)('minus'),
63
- label: '%main-layout.panel.toggle%',
64
- };
65
- exports.IS_VISIBLE_VIEW_COMMAND = {
66
- id: 'main-layout.view.is-visible',
67
- };
68
- exports.IS_VISIBLE_EXTEND_VIEW_COMMAND = {
69
- id: 'main-layout.extend-view.is-visible',
70
- };
71
- exports.IS_VISIBLE_PANEL_COMMAND = {
72
- id: 'main-layout.panel.is-visible',
73
- };
74
- exports.EXPAND_PANEL_COMMAND = {
75
- id: 'main-layout.panel.expand',
76
- label: '%layout.tabbar.expand%',
77
- iconClass: (0, ide_core_browser_1.getIcon)('expand'),
78
- };
79
- exports.RETRACT_PANEL_COMMAND = {
80
- id: 'main-layout.panel.retract',
81
- label: '%layout.tabbar.retract%',
82
- iconClass: (0, ide_core_browser_1.getIcon)('shrink'),
83
- };
84
- //# sourceMappingURL=command.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"command.js","sourceRoot":"","sources":["../../src/browser/command.ts"],"names":[],"mappings":";;;AAAA,iEAA8D;AAG9D,8CAA8C;AACjC,QAAA,yBAAyB,GAAY;IAChD,EAAE,EAAE,+BAA+B;IACnC,QAAQ,EAAE,yBAAyB;CACpC,CAAC;AAEF,oDAAoD;AACvC,QAAA,0BAA0B,GAAY;IACjD,EAAE,EAAE,gCAAgC;IACpC,QAAQ,EAAE,gCAAgC;CAC3C,CAAC;AAEF,+CAA+C;AAClC,QAAA,2BAA2B,GAAY;IAClD,EAAE,EAAE,iCAAiC;IACrC,QAAQ,EAAE,0BAA0B;CACrC,CAAC;AAEF,mDAAmD;AACtC,QAAA,+BAA+B,GAAY;IACtD,EAAE,EAAE,qCAAqC;IACzC,QAAQ,EAAE,8BAA8B;CACzC,CAAC;AAEF,kDAAkD;AACrC,QAAA,6BAA6B,GAAY;IACpD,EAAE,EAAE,mCAAmC;IACvC,QAAQ,EAAE,6BAA6B;CACxC,CAAC;AAEF,yDAAyD;AAC5C,QAAA,8BAA8B,GAAY;IACrD,EAAE,EAAE,oCAAoC;IACxC,QAAQ,EAAE,oCAAoC;CAC/C,CAAC;AAEF,+CAA+C;AAClC,QAAA,mBAAmB,GAAY;IAC1C,EAAE,EAAE,iCAAiC;IACrC,QAAQ,EAAE,0BAA0B;CACrC,CAAC;AAEF,gDAAgD;AACnC,QAAA,oBAAoB,GAAY;IAC3C,EAAE,EAAE,kCAAkC;IACtC,QAAQ,EAAE,2BAA2B;CACtC,CAAC;AAEW,QAAA,6BAA6B,GAAY;IACpD,EAAE,EAAE,+BAA+B;IACnC,KAAK,EAAE,4BAA4B;CACpC,CAAC;AAEW,QAAA,2BAA2B,GAAY;IAClD,EAAE,EAAE,6BAA6B;CAClC,CAAC;AAEW,QAAA,mBAAmB,GAAoB;IAClD,EAAE,EAAE,yBAAyB;IAC7B,KAAK,EAAE,2BAA2B;CACnC,CAAC;AAEW,QAAA,0BAA0B,GAAoB;IACzD,EAAE,EAAE,gCAAgC;IACpC,KAAK,EAAE,kCAAkC;CAC1C,CAAC;AAEW,QAAA,oBAAoB,GAAY;IAC3C,EAAE,EAAE,0BAA0B;IAC9B,SAAS,EAAE,IAAA,0BAAO,EAAC,OAAO,CAAC;IAC3B,KAAK,EAAE,4BAA4B;CACpC,CAAC;AAEW,QAAA,uBAAuB,GAAY;IAC9C,EAAE,EAAE,6BAA6B;CAClC,CAAC;AAEW,QAAA,8BAA8B,GAAY;IACrD,EAAE,EAAE,oCAAoC;CACzC,CAAC;AAEW,QAAA,wBAAwB,GAAY;IAC/C,EAAE,EAAE,8BAA8B;CACnC,CAAC;AAEW,QAAA,oBAAoB,GAAY;IAC3C,EAAE,EAAE,0BAA0B;IAC9B,KAAK,EAAE,wBAAwB;IAC/B,SAAS,EAAE,IAAA,0BAAO,EAAC,QAAQ,CAAC;CAC7B,CAAC;AAEW,QAAA,qBAAqB,GAAY;IAC5C,EAAE,EAAE,2BAA2B;IAC/B,KAAK,EAAE,yBAAyB;IAChC,SAAS,EAAE,IAAA,0BAAO,EAAC,QAAQ,CAAC;CAC7B,CAAC"}
@@ -1,141 +0,0 @@
1
- # Tabbar 配置使用指南
2
-
3
- ## 概述
4
-
5
- 现在支持在注册插槽渲染器时传入 `tabbarConfig` 配置,用于控制 tabbar 的布局行为。这样不同的插槽渲染器可以根据自己的实现特点提供相应的配置。
6
-
7
- ## 配置接口
8
-
9
- ```typescript
10
- export interface TabbarConfig {
11
- /** 是否为后置位置(bar 在 panel 右侧或底下) */
12
- isLatter: boolean;
13
- /** 支持的操作类型 */
14
- supportedActions?: {
15
- expand?: boolean;
16
- toggle?: boolean;
17
- accordion?: boolean;
18
- };
19
- }
20
- ```
21
-
22
- ## 使用方式
23
-
24
- ### 1. 注册带配置的插槽渲染器
25
-
26
- ```typescript
27
- import { SlotLocation } from '@opensumi/ide-core-browser';
28
- import { slotRendererRegistry } from '@opensumi/ide-core-browser/lib/react-providers';
29
-
30
- // 注册左侧面板渲染器(bar 在 panel 左侧)
31
- slotRendererRegistry.registerSlotRenderer(SlotLocation.view, LeftTabRenderer, {
32
- isLatter: false, // bar 在 panel 左侧
33
- supportedActions: {
34
- accordion: true, // 支持手风琴
35
- },
36
- });
37
-
38
- // 注册右侧面板渲染器(bar 在 panel 右侧)
39
- slotRendererRegistry.registerSlotRenderer(SlotLocation.extendView, RightTabRenderer, {
40
- isLatter: true, // bar 在 panel 右侧
41
- supportedActions: {
42
- accordion: true,
43
- },
44
- });
45
-
46
- // 注册底部面板渲染器(bar 在 panel 底下)
47
- slotRendererRegistry.registerSlotRenderer(SlotLocation.panel, BottomTabRenderer, {
48
- isLatter: true, // bar 在 panel 底下
49
- supportedActions: {
50
- expand: true, // 支持展开/收缩
51
- toggle: true, // 支持 toggle 行为
52
- },
53
- });
54
- ```
55
-
56
- ### 2. 自定义插槽渲染器的配置
57
-
58
- 如果你有自定义的插槽渲染器,可以根据具体的布局实现来设置配置:
59
-
60
- ```typescript
61
- // 自定义的水平布局渲染器
62
- class HorizontalTabRenderer extends React.Component {
63
- // 实现水平布局,bar 在左侧
64
- }
65
-
66
- // 注册时指定配置
67
- slotRendererRegistry.registerSlotRenderer('customLocation', HorizontalTabRenderer, {
68
- isLatter: false, // bar 在左侧
69
- supportedActions: {
70
- accordion: false, // 不支持手风琴
71
- expand: false, // 不支持展开
72
- },
73
- });
74
- ```
75
-
76
- ### 3. 配置的优先级
77
-
78
- 配置采用以下优先级:
79
-
80
- 1. **插槽渲染器配置**:通过 `registerSlotRenderer` 传入的 `tabbarConfig`
81
- 2. **默认配置**:基于 location 的默认配置
82
-
83
- ```typescript
84
- // 在策略中获取配置的逻辑
85
- protected getIsLatter(): boolean {
86
- if (this.tabbarConfig?.isLatter !== undefined) {
87
- return this.tabbarConfig.isLatter; // 优先使用渲染器配置
88
- }
89
- // 默认配置:扩展视图和底部面板为后置位置
90
- return this.location === 'extendView' || this.location === 'panel';
91
- }
92
- ```
93
-
94
- ## 实际应用场景
95
-
96
- ### 场景 1:自定义右侧面板布局
97
-
98
- 如果你的右侧面板采用了特殊的布局,bar 实际在左侧:
99
-
100
- ```typescript
101
- slotRendererRegistry.registerSlotRenderer(SlotLocation.extendView, CustomRightRenderer, {
102
- isLatter: false, // 虽然是右侧面板,但 bar 在左侧
103
- });
104
- ```
105
-
106
- ### 场景 2:底部面板的变体
107
-
108
- 底部面板的不同实现可能有不同的布局:
109
-
110
- ```typescript
111
- // 传统底部面板:bar 在上方
112
- slotRendererRegistry.registerSlotRenderer(SlotLocation.panel, TraditionalBottomRenderer, {
113
- isLatter: false, // bar 在 panel 上方
114
- supportedActions: {
115
- expand: true,
116
- toggle: true,
117
- },
118
- });
119
-
120
- // 现代底部面板:bar 在下方
121
- slotRendererRegistry.registerSlotRenderer(SlotLocation.panel, ModernBottomRenderer, {
122
- isLatter: true, // bar 在 panel 下方
123
- supportedActions: {
124
- expand: true,
125
- toggle: true,
126
- },
127
- });
128
- ```
129
-
130
- ## 注意事项
131
-
132
- 1. **向后兼容**:如果不提供 `tabbarConfig`,会使用默认配置
133
- 2. **配置验证**:确保 `isLatter` 的值与实际的渲染器布局一致
134
- 3. **动态更新**:目前配置在注册时确定,不支持运行时动态修改
135
-
136
- ## 好处
137
-
138
- - **灵活性**:不同的渲染器可以有不同的布局配置
139
- - **解耦合**:策略不再硬编码位置相关的配置
140
- - **可扩展**:新的渲染器可以轻松定义自己的配置
141
- - **清晰性**:配置意图明确,便于理解和维护