@opensumi/ide-main-layout 3.9.1-next-1749540423.0 → 3.9.1-next-1749547010.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.
- package/README.md +30 -31
- package/lib/browser/accordion/accordion.service.d.ts +9 -1
- package/lib/browser/accordion/accordion.service.d.ts.map +1 -1
- package/lib/browser/accordion/accordion.service.js +120 -33
- package/lib/browser/accordion/accordion.service.js.map +1 -1
- package/lib/browser/accordion/accordion.view.d.ts.map +1 -1
- package/lib/browser/accordion/accordion.view.js +4 -1
- package/lib/browser/accordion/accordion.view.js.map +1 -1
- package/lib/browser/accordion/section.view.d.ts.map +1 -1
- package/lib/browser/accordion/section.view.js +1 -1
- package/lib/browser/accordion/section.view.js.map +1 -1
- package/lib/browser/accordion/styles.module.less +61 -0
- package/lib/browser/command.d.ts +29 -0
- package/lib/browser/command.d.ts.map +1 -0
- package/lib/browser/command.js +84 -0
- package/lib/browser/command.js.map +1 -0
- package/lib/browser/default-config.d.ts.map +1 -1
- package/lib/browser/default-config.js +7 -6
- package/lib/browser/default-config.js.map +1 -1
- package/lib/browser/drop-area/drop-area.d.ts +3 -2
- package/lib/browser/drop-area/drop-area.d.ts.map +1 -1
- package/lib/browser/drop-area/drop-area.js +8 -5
- package/lib/browser/drop-area/drop-area.js.map +1 -1
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/layout.service.d.ts +4 -0
- package/lib/browser/layout.service.d.ts.map +1 -1
- package/lib/browser/layout.service.js +140 -79
- package/lib/browser/layout.service.js.map +1 -1
- package/lib/browser/main-layout.contribution.d.ts +2 -18
- package/lib/browser/main-layout.contribution.d.ts.map +1 -1
- package/lib/browser/main-layout.contribution.js +75 -131
- package/lib/browser/main-layout.contribution.js.map +1 -1
- package/lib/browser/tabbar/TABBAR_CONFIG_USAGE.md +141 -0
- package/lib/browser/tabbar/bar.view.d.ts.map +1 -1
- package/lib/browser/tabbar/bar.view.js +5 -10
- package/lib/browser/tabbar/bar.view.js.map +1 -1
- package/lib/browser/tabbar/panel.view.js +2 -2
- package/lib/browser/tabbar/panel.view.js.map +1 -1
- package/lib/browser/tabbar/renderer.view.js +4 -4
- package/lib/browser/tabbar/renderer.view.js.map +1 -1
- package/lib/browser/tabbar/tabbar-behavior-handler.d.ts +71 -0
- package/lib/browser/tabbar/tabbar-behavior-handler.d.ts.map +1 -0
- package/lib/browser/tabbar/tabbar-behavior-handler.js +210 -0
- package/lib/browser/tabbar/tabbar-behavior-handler.js.map +1 -0
- package/lib/browser/tabbar/tabbar.service.d.ts +8 -19
- package/lib/browser/tabbar/tabbar.service.d.ts.map +1 -1
- package/lib/browser/tabbar/tabbar.service.js +39 -148
- package/lib/browser/tabbar/tabbar.service.js.map +1 -1
- package/lib/common/main-layout.definition.d.ts +4 -3
- package/lib/common/main-layout.definition.d.ts.map +1 -1
- package/lib/common/main-layout.definition.js +5 -4
- package/lib/common/main-layout.definition.js.map +1 -1
- package/package.json +8 -8
- package/src/browser/accordion/accordion.service.ts +152 -35
- package/src/browser/accordion/accordion.view.tsx +4 -2
- package/src/browser/accordion/section.view.tsx +5 -1
- package/src/browser/accordion/styles.module.less +61 -0
- package/src/browser/command.ts +99 -0
- package/src/browser/default-config.ts +8 -7
- package/src/browser/drop-area/drop-area.tsx +6 -3
- package/src/browser/index.ts +1 -0
- package/src/browser/layout.service.ts +156 -67
- package/src/browser/main-layout.contribution.ts +93 -138
- package/src/browser/tabbar/TABBAR_CONFIG_USAGE.md +141 -0
- package/src/browser/tabbar/bar.view.tsx +9 -14
- package/src/browser/tabbar/panel.view.tsx +2 -2
- package/src/browser/tabbar/renderer.view.tsx +4 -4
- package/src/browser/tabbar/tabbar-behavior-handler.ts +260 -0
- package/src/browser/tabbar/tabbar.service.ts +54 -163
- package/src/common/main-layout.definition.ts +6 -4
|
@@ -39,85 +39,34 @@ import {
|
|
|
39
39
|
MenuId,
|
|
40
40
|
} from '@opensumi/ide-core-browser/lib/menu/next';
|
|
41
41
|
import { ContributionProvider, Domain, IEventBus, WithEventBus, localize } from '@opensumi/ide-core-common';
|
|
42
|
-
import {
|
|
42
|
+
import { CommandContribution, CommandRegistry, CommandService } from '@opensumi/ide-core-common/lib/command';
|
|
43
43
|
|
|
44
|
-
import {
|
|
44
|
+
import { DROP_EXTEND_VIEW_CONTAINER, DROP_PANEL_CONTAINER, DROP_VIEW_CONTAINER, IMainLayoutService } from '../common';
|
|
45
45
|
|
|
46
|
-
import {
|
|
46
|
+
import {
|
|
47
|
+
EXPAND_BOTTOM_PANEL,
|
|
48
|
+
EXPAND_PANEL_COMMAND,
|
|
49
|
+
IS_VISIBLE_BOTTOM_PANEL_COMMAND,
|
|
50
|
+
IS_VISIBLE_EXTEND_VIEW_COMMAND,
|
|
51
|
+
IS_VISIBLE_LEFT_PANEL_COMMAND,
|
|
52
|
+
IS_VISIBLE_PANEL_COMMAND,
|
|
53
|
+
IS_VISIBLE_RIGHT_PANEL_COMMAND,
|
|
54
|
+
IS_VISIBLE_VIEW_COMMAND,
|
|
55
|
+
RETRACT_BOTTOM_PANEL,
|
|
56
|
+
RETRACT_PANEL_COMMAND,
|
|
57
|
+
TOGGLE_BOTTOM_PANEL_COMMAND,
|
|
58
|
+
TOGGLE_EXTEND_VIEW_COMMAND,
|
|
59
|
+
TOGGLE_LEFT_PANEL_COMMAND,
|
|
60
|
+
TOGGLE_PANEL_COMMAND,
|
|
61
|
+
TOGGLE_RIGHT_PANEL_COMMAND,
|
|
62
|
+
TOGGLE_VIEW_COMMAND,
|
|
63
|
+
WORKBENCH_ACTION_CLOSEPANEL,
|
|
64
|
+
WORKBENCH_ACTION_CLOSESIDECAR,
|
|
65
|
+
} from './command';
|
|
66
|
+
import { ExtendViewDropArea, PanelDropArea, ViewDropArea } from './drop-area/drop-area';
|
|
47
67
|
import { ViewQuickOpenHandler } from './quick-open-view';
|
|
48
68
|
import { BottomTabRenderer, LeftTabRenderer, RightTabRenderer } from './tabbar/renderer.view';
|
|
49
69
|
|
|
50
|
-
// NOTE 左右侧面板的展开、折叠命令请使用组合命令 activity-bar.left.toggle,layout命令仅做折叠展开,不处理tab激活逻辑
|
|
51
|
-
export const HIDE_LEFT_PANEL_COMMAND: Command = {
|
|
52
|
-
id: 'main-layout.left-panel.hide',
|
|
53
|
-
label: '%main-layout.left-panel.hide%',
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export const WORKBENCH_ACTION_CLOSESIDECAR: Command = {
|
|
57
|
-
id: 'workbench.action.closeSidebar',
|
|
58
|
-
label: '%main-layout.sidebar.hide%',
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
export const SHOW_LEFT_PANEL_COMMAND: Command = {
|
|
62
|
-
id: 'main-layout.left-panel.show',
|
|
63
|
-
label: '%main-layout.left-panel.show%',
|
|
64
|
-
};
|
|
65
|
-
export const TOGGLE_LEFT_PANEL_COMMAND: MenuCommandDesc = {
|
|
66
|
-
id: 'main-layout.left-panel.toggle',
|
|
67
|
-
label: '%main-layout.left-panel.toggle%',
|
|
68
|
-
};
|
|
69
|
-
export const HIDE_RIGHT_PANEL_COMMAND: Command = {
|
|
70
|
-
id: 'main-layout.right-panel.hide',
|
|
71
|
-
label: '%main-layout.right-panel.hide%',
|
|
72
|
-
};
|
|
73
|
-
export const SHOW_RIGHT_PANEL_COMMAND: Command = {
|
|
74
|
-
id: 'main-layout.right-panel.show',
|
|
75
|
-
label: '%main-layout.right-panel.show%',
|
|
76
|
-
};
|
|
77
|
-
export const TOGGLE_RIGHT_PANEL_COMMAND: MenuCommandDesc = {
|
|
78
|
-
id: 'main-layout.right-panel.toggle',
|
|
79
|
-
label: '%main-layout.right-panel.toggle%',
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
export const HIDE_BOTTOM_PANEL_COMMAND: Command = {
|
|
83
|
-
id: 'main-layout.bottom-panel.hide',
|
|
84
|
-
label: '%main-layout.bottom-panel.hide%',
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
export const WORKBENCH_ACTION_CLOSEPANEL: Command = {
|
|
88
|
-
id: 'workbench.action.closePanel',
|
|
89
|
-
delegate: HIDE_BOTTOM_PANEL_COMMAND.id,
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
export const SHOW_BOTTOM_PANEL_COMMAND: Command = {
|
|
93
|
-
id: 'main-layout.bottom-panel.show',
|
|
94
|
-
label: '%main-layout.bottom-panel.show%',
|
|
95
|
-
};
|
|
96
|
-
export const TOGGLE_BOTTOM_PANEL_COMMAND: Command = {
|
|
97
|
-
id: 'main-layout.bottom-panel.toggle',
|
|
98
|
-
iconClass: getIcon('minus'),
|
|
99
|
-
label: '%layout.tabbar.toggle%',
|
|
100
|
-
};
|
|
101
|
-
export const IS_VISIBLE_BOTTOM_PANEL_COMMAND: Command = {
|
|
102
|
-
id: 'main-layout.bottom-panel.is-visible',
|
|
103
|
-
};
|
|
104
|
-
export const IS_VISIBLE_LEFT_PANEL_COMMAND: Command = {
|
|
105
|
-
id: 'main-layout.left-panel.is-visible',
|
|
106
|
-
};
|
|
107
|
-
export const IS_VISIBLE_RIGHT_PANEL_COMMAND: Command = {
|
|
108
|
-
id: 'main-layout.right-panel.is-visible',
|
|
109
|
-
};
|
|
110
|
-
export const EXPAND_BOTTOM_PANEL: Command = {
|
|
111
|
-
id: 'main-layout.bottom-panel.expand',
|
|
112
|
-
label: '%layout.tabbar.expand%',
|
|
113
|
-
iconClass: getIcon('expand'),
|
|
114
|
-
};
|
|
115
|
-
export const RETRACT_BOTTOM_PANEL: Command = {
|
|
116
|
-
id: 'main-layout.bottom-panel.retract',
|
|
117
|
-
label: '%layout.tabbar.retract%',
|
|
118
|
-
iconClass: getIcon('shrink'),
|
|
119
|
-
};
|
|
120
|
-
|
|
121
70
|
@Domain(
|
|
122
71
|
CommandContribution,
|
|
123
72
|
ClientAppContribution,
|
|
@@ -196,15 +145,20 @@ export class MainLayoutModuleContribution
|
|
|
196
145
|
}
|
|
197
146
|
|
|
198
147
|
registerComponent(registry: ComponentRegistry): void {
|
|
199
|
-
registry.register(
|
|
200
|
-
component:
|
|
148
|
+
registry.register(DROP_EXTEND_VIEW_CONTAINER, [], {
|
|
149
|
+
component: ExtendViewDropArea,
|
|
150
|
+
hideTab: true,
|
|
151
|
+
containerId: DROP_EXTEND_VIEW_CONTAINER,
|
|
152
|
+
});
|
|
153
|
+
registry.register(DROP_PANEL_CONTAINER, [], {
|
|
154
|
+
component: PanelDropArea,
|
|
201
155
|
hideTab: true,
|
|
202
|
-
containerId:
|
|
156
|
+
containerId: DROP_PANEL_CONTAINER,
|
|
203
157
|
});
|
|
204
|
-
registry.register(
|
|
205
|
-
component:
|
|
158
|
+
registry.register(DROP_VIEW_CONTAINER, [], {
|
|
159
|
+
component: ViewDropArea,
|
|
206
160
|
hideTab: true,
|
|
207
|
-
containerId:
|
|
161
|
+
containerId: DROP_VIEW_CONTAINER,
|
|
208
162
|
});
|
|
209
163
|
}
|
|
210
164
|
|
|
@@ -217,78 +171,75 @@ export class MainLayoutModuleContribution
|
|
|
217
171
|
}
|
|
218
172
|
|
|
219
173
|
registerRenderer(registry: SlotRendererRegistry) {
|
|
220
|
-
registry.registerSlotRenderer(SlotLocation.
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
registerCommands(commands: CommandRegistry): void {
|
|
226
|
-
// @deprecated
|
|
227
|
-
commands.registerCommand(HIDE_LEFT_PANEL_COMMAND, {
|
|
228
|
-
execute: () => {
|
|
229
|
-
this.mainLayoutService.toggleSlot(SlotLocation.left, false);
|
|
174
|
+
registry.registerSlotRenderer(SlotLocation.extendView, RightTabRenderer, {
|
|
175
|
+
isLatter: true,
|
|
176
|
+
supportedActions: {
|
|
177
|
+
accordion: true,
|
|
230
178
|
},
|
|
231
179
|
});
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
this.mainLayoutService.toggleSlot(SlotLocation.left, true, size);
|
|
180
|
+
registry.registerSlotRenderer(SlotLocation.view, LeftTabRenderer, {
|
|
181
|
+
supportedActions: {
|
|
182
|
+
accordion: true,
|
|
236
183
|
},
|
|
237
184
|
});
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
185
|
+
registry.registerSlotRenderer(SlotLocation.panel, BottomTabRenderer, {
|
|
186
|
+
isLatter: true,
|
|
187
|
+
supportedActions: {
|
|
188
|
+
expand: true,
|
|
189
|
+
toggle: true,
|
|
241
190
|
},
|
|
242
191
|
});
|
|
192
|
+
}
|
|
243
193
|
|
|
244
|
-
|
|
245
|
-
commands.registerCommand(
|
|
246
|
-
execute: () => {
|
|
247
|
-
this.mainLayoutService.toggleSlot(SlotLocation.
|
|
194
|
+
registerCommands(commands: CommandRegistry): void {
|
|
195
|
+
commands.registerCommand(TOGGLE_VIEW_COMMAND, {
|
|
196
|
+
execute: (show?: boolean, size?: number) => {
|
|
197
|
+
this.mainLayoutService.toggleSlot(SlotLocation.view, show, size);
|
|
248
198
|
},
|
|
249
199
|
});
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
this.mainLayoutService.toggleSlot(SlotLocation.right, true, size);
|
|
200
|
+
commands.registerCommand(TOGGLE_EXTEND_VIEW_COMMAND, {
|
|
201
|
+
execute: (show?: boolean, size?: number) => {
|
|
202
|
+
this.mainLayoutService.toggleSlot(SlotLocation.extendView, show, size);
|
|
254
203
|
},
|
|
255
204
|
});
|
|
256
|
-
commands.registerCommand(
|
|
205
|
+
commands.registerCommand(TOGGLE_PANEL_COMMAND, {
|
|
257
206
|
execute: (show?: boolean, size?: number) => {
|
|
258
|
-
this.mainLayoutService.toggleSlot(SlotLocation.
|
|
207
|
+
this.mainLayoutService.toggleSlot(SlotLocation.panel, show, size);
|
|
259
208
|
},
|
|
260
209
|
});
|
|
210
|
+
commands.registerCommand(IS_VISIBLE_VIEW_COMMAND, {
|
|
211
|
+
execute: () => this.mainLayoutService.isVisible(SlotLocation.view),
|
|
212
|
+
});
|
|
213
|
+
commands.registerCommand(IS_VISIBLE_EXTEND_VIEW_COMMAND, {
|
|
214
|
+
execute: () => this.mainLayoutService.isVisible(SlotLocation.extendView),
|
|
215
|
+
});
|
|
216
|
+
commands.registerCommand(IS_VISIBLE_PANEL_COMMAND, {
|
|
217
|
+
execute: () => this.mainLayoutService.isVisible(SlotLocation.panel),
|
|
218
|
+
});
|
|
219
|
+
// TODO: 下个版本废弃掉
|
|
220
|
+
commands.registerCommand(TOGGLE_LEFT_PANEL_COMMAND);
|
|
221
|
+
commands.registerCommand(TOGGLE_RIGHT_PANEL_COMMAND);
|
|
222
|
+
commands.registerCommand(TOGGLE_BOTTOM_PANEL_COMMAND);
|
|
223
|
+
commands.registerCommand(EXPAND_BOTTOM_PANEL);
|
|
224
|
+
commands.registerCommand(RETRACT_BOTTOM_PANEL);
|
|
225
|
+
commands.registerCommand(IS_VISIBLE_LEFT_PANEL_COMMAND);
|
|
226
|
+
commands.registerCommand(IS_VISIBLE_RIGHT_PANEL_COMMAND);
|
|
227
|
+
commands.registerCommand(IS_VISIBLE_BOTTOM_PANEL_COMMAND);
|
|
261
228
|
|
|
262
229
|
commands.registerCommand(WORKBENCH_ACTION_CLOSESIDECAR, {
|
|
263
230
|
execute: () =>
|
|
264
231
|
Promise.all([
|
|
265
|
-
this.mainLayoutService.toggleSlot(SlotLocation.
|
|
266
|
-
this.mainLayoutService.toggleSlot(SlotLocation.
|
|
232
|
+
this.mainLayoutService.toggleSlot(SlotLocation.view, false),
|
|
233
|
+
this.mainLayoutService.toggleSlot(SlotLocation.extendView, false),
|
|
267
234
|
]),
|
|
268
235
|
});
|
|
269
236
|
|
|
270
|
-
commands.registerCommand(
|
|
237
|
+
commands.registerCommand(WORKBENCH_ACTION_CLOSEPANEL, {
|
|
271
238
|
execute: () => {
|
|
272
|
-
this.mainLayoutService.toggleSlot(SlotLocation.
|
|
239
|
+
this.mainLayoutService.toggleSlot(SlotLocation.panel, false);
|
|
273
240
|
},
|
|
274
241
|
});
|
|
275
242
|
|
|
276
|
-
commands.registerCommand(HIDE_BOTTOM_PANEL_COMMAND, {
|
|
277
|
-
execute: () => {
|
|
278
|
-
this.mainLayoutService.toggleSlot(SlotLocation.bottom, false);
|
|
279
|
-
},
|
|
280
|
-
});
|
|
281
|
-
commands.registerCommand(WORKBENCH_ACTION_CLOSEPANEL);
|
|
282
|
-
commands.registerCommand(IS_VISIBLE_BOTTOM_PANEL_COMMAND, {
|
|
283
|
-
execute: () => this.mainLayoutService.getTabbarService('bottom').currentContainerId.get() !== '',
|
|
284
|
-
});
|
|
285
|
-
commands.registerCommand(IS_VISIBLE_LEFT_PANEL_COMMAND, {
|
|
286
|
-
execute: () => this.mainLayoutService.isVisible(SlotLocation.left),
|
|
287
|
-
});
|
|
288
|
-
commands.registerCommand(IS_VISIBLE_RIGHT_PANEL_COMMAND, {
|
|
289
|
-
execute: () => this.mainLayoutService.isVisible(SlotLocation.left),
|
|
290
|
-
});
|
|
291
|
-
|
|
292
243
|
commands.registerCommand(
|
|
293
244
|
{
|
|
294
245
|
id: 'view.outward.right-panel.hide',
|
|
@@ -359,14 +310,14 @@ export class MainLayoutModuleContribution
|
|
|
359
310
|
});
|
|
360
311
|
|
|
361
312
|
Object.entries({
|
|
362
|
-
[SlotLocation.
|
|
313
|
+
[SlotLocation.view]: [
|
|
363
314
|
EXPLORER_CONTAINER_ID,
|
|
364
315
|
SEARCH_CONTAINER_ID,
|
|
365
316
|
SCM_CONTAINER_ID,
|
|
366
317
|
DEBUG_CONTAINER_ID,
|
|
367
318
|
EXTENSION_CONTAINER_ID,
|
|
368
319
|
],
|
|
369
|
-
[SlotLocation.
|
|
320
|
+
[SlotLocation.panel]: [
|
|
370
321
|
MARKER_CONTAINER_ID,
|
|
371
322
|
OUTPUT_CONTAINER_ID,
|
|
372
323
|
DEBUG_CONSOLE_CONTAINER_ID,
|
|
@@ -396,24 +347,24 @@ export class MainLayoutModuleContribution
|
|
|
396
347
|
});
|
|
397
348
|
|
|
398
349
|
menus.registerMenuItem(MenuId.MenubarViewMenu, {
|
|
399
|
-
command:
|
|
350
|
+
command: TOGGLE_VIEW_COMMAND,
|
|
400
351
|
group: '5_panel',
|
|
401
352
|
});
|
|
402
353
|
menus.registerMenuItem(MenuId.MenubarViewMenu, {
|
|
403
|
-
command:
|
|
354
|
+
command: TOGGLE_EXTEND_VIEW_COMMAND,
|
|
404
355
|
group: '5_panel',
|
|
405
356
|
});
|
|
406
357
|
menus.registerMenuItem(MenuId.MenubarViewMenu, {
|
|
407
|
-
command:
|
|
358
|
+
command: TOGGLE_PANEL_COMMAND as MenuCommandDesc,
|
|
408
359
|
group: '5_panel',
|
|
409
360
|
});
|
|
410
361
|
menus.registerMenuItem(MenuId.MenubarViewMenu, {
|
|
411
|
-
command:
|
|
362
|
+
command: EXPAND_PANEL_COMMAND as MenuCommandDesc,
|
|
412
363
|
group: '5_panel',
|
|
413
364
|
when: '!bottomFullExpanded',
|
|
414
365
|
});
|
|
415
366
|
menus.registerMenuItem(MenuId.MenubarViewMenu, {
|
|
416
|
-
command:
|
|
367
|
+
command: RETRACT_PANEL_COMMAND as MenuCommandDesc,
|
|
417
368
|
group: '5_panel',
|
|
418
369
|
when: 'bottomFullExpanded',
|
|
419
370
|
});
|
|
@@ -431,20 +382,24 @@ export class MainLayoutModuleContribution
|
|
|
431
382
|
protected registerSideToggleKey() {
|
|
432
383
|
this.keybindingRegistry.registerKeybinding({
|
|
433
384
|
keybinding: 'ctrlcmd+b',
|
|
434
|
-
command:
|
|
385
|
+
command: TOGGLE_VIEW_COMMAND.id,
|
|
386
|
+
});
|
|
387
|
+
this.keybindingRegistry.registerKeybinding({
|
|
388
|
+
keybinding: 'ctrlcmd+alt+b',
|
|
389
|
+
command: TOGGLE_EXTEND_VIEW_COMMAND.id,
|
|
435
390
|
});
|
|
436
391
|
this.keybindingRegistry.registerKeybinding({
|
|
437
392
|
keybinding: 'ctrlcmd+j',
|
|
438
|
-
command:
|
|
393
|
+
command: TOGGLE_PANEL_COMMAND.id,
|
|
439
394
|
});
|
|
440
395
|
this.keybindingRegistry.registerKeybinding({
|
|
441
396
|
keybinding: 'ctrlcmd+shift+j',
|
|
442
|
-
command:
|
|
397
|
+
command: EXPAND_PANEL_COMMAND.id,
|
|
443
398
|
when: '!bottomFullExpanded',
|
|
444
399
|
});
|
|
445
400
|
this.keybindingRegistry.registerKeybinding({
|
|
446
401
|
keybinding: 'ctrlcmd+shift+j',
|
|
447
|
-
command:
|
|
402
|
+
command: RETRACT_PANEL_COMMAND.id,
|
|
448
403
|
when: 'bottomFullExpanded',
|
|
449
404
|
});
|
|
450
405
|
}
|
|
@@ -0,0 +1,141 @@
|
|
|
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
|
+
- **清晰性**:配置意图明确,便于理解和维护
|
|
@@ -5,6 +5,7 @@ import { Badge, Icon } from '@opensumi/ide-components';
|
|
|
5
5
|
import {
|
|
6
6
|
ComponentRegistryInfo,
|
|
7
7
|
ComponentRegistryProvider,
|
|
8
|
+
Event,
|
|
8
9
|
KeybindingRegistry,
|
|
9
10
|
addClassName,
|
|
10
11
|
getIcon,
|
|
@@ -109,20 +110,20 @@ export const TabbarViewBase: FC<ITabbarViewProps> = (props) => {
|
|
|
109
110
|
}, []);
|
|
110
111
|
|
|
111
112
|
useEffect(() => {
|
|
112
|
-
|
|
113
|
-
splitVisibleTabs(
|
|
114
|
-
tabbarService.visibleContainers.filter((container) => !container.options?.hideTab),
|
|
115
|
-
visibleCount,
|
|
116
|
-
),
|
|
117
|
-
);
|
|
118
|
-
const disposable = tabbarService.onStateChange(() => {
|
|
113
|
+
const updateContainers = () => {
|
|
119
114
|
setContainers(
|
|
120
115
|
splitVisibleTabs(
|
|
121
116
|
tabbarService.visibleContainers.filter((container) => !container.options?.hideTab),
|
|
122
117
|
visibleCount,
|
|
123
118
|
),
|
|
124
119
|
);
|
|
125
|
-
}
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
updateContainers();
|
|
123
|
+
const disposable = Event.any<any>(
|
|
124
|
+
tabbarService.onDidRegisterContainer,
|
|
125
|
+
tabbarService.onStateChange,
|
|
126
|
+
)(updateContainers);
|
|
126
127
|
return () => {
|
|
127
128
|
disposable.dispose();
|
|
128
129
|
};
|
|
@@ -153,9 +154,6 @@ export const TabbarViewBase: FC<ITabbarViewProps> = (props) => {
|
|
|
153
154
|
if (!containerId) {
|
|
154
155
|
return null;
|
|
155
156
|
}
|
|
156
|
-
if (side && component.options?.hideLocationTab?.includes(side)) {
|
|
157
|
-
return null;
|
|
158
|
-
}
|
|
159
157
|
|
|
160
158
|
tabbarService.updateTabInMoreKey(containerId, false);
|
|
161
159
|
let ref: HTMLLIElement | null;
|
|
@@ -423,9 +421,6 @@ export const ChatTabbarRenderer2: FC<{ barSize?: number; style?: CSSProperties }
|
|
|
423
421
|
const { barSize = 32, style } = props;
|
|
424
422
|
const { side } = useContext(TabbarConfig);
|
|
425
423
|
const tabbarService: TabbarService = useInjectable(TabbarServiceFactory)(side);
|
|
426
|
-
useEffect(() => {
|
|
427
|
-
tabbarService.setIsLatter(true);
|
|
428
|
-
}, [tabbarService]);
|
|
429
424
|
const styles_right_tab_bar = useDesignStyles(styles.ai_right_tab_bar, 'ai_right_tab_bar');
|
|
430
425
|
const styles_right_tab = useDesignStyles(styles.ai_right_tab, 'ai_right_tab');
|
|
431
426
|
|
|
@@ -224,7 +224,7 @@ const BottomPanelView: React.FC<{
|
|
|
224
224
|
</div>
|
|
225
225
|
<div className={styles_panel_toolbar_container}>
|
|
226
226
|
{titleMenu && <InlineActionBar menus={titleMenu} />}
|
|
227
|
-
<InlineMenuBar menus={tabbarService.commonTitleMenu} moreAtFirst />
|
|
227
|
+
{tabbarService.commonTitleMenu && <InlineMenuBar menus={tabbarService.commonTitleMenu} moreAtFirst />}
|
|
228
228
|
</div>
|
|
229
229
|
</div>
|
|
230
230
|
<div className={styles.container_wrap} ref={(ele) => (ref.current = ele)}>
|
|
@@ -240,7 +240,7 @@ const BottomPanelView: React.FC<{
|
|
|
240
240
|
<AccordionContainer
|
|
241
241
|
views={component.views}
|
|
242
242
|
alignment='horizontal'
|
|
243
|
-
minSize={component.options!.miniSize}
|
|
243
|
+
minSize={component.options!.miniSize || 200}
|
|
244
244
|
containerId={component.options!.containerId}
|
|
245
245
|
/>
|
|
246
246
|
)}
|
|
@@ -34,7 +34,7 @@ export const TabbarConfig = createContext<{
|
|
|
34
34
|
direction: Layout.direction;
|
|
35
35
|
fullSize: number;
|
|
36
36
|
}>({
|
|
37
|
-
side: SlotLocation.
|
|
37
|
+
side: SlotLocation.view,
|
|
38
38
|
direction: EDirection.LeftToRight,
|
|
39
39
|
fullSize: 0,
|
|
40
40
|
});
|
|
@@ -114,7 +114,7 @@ export const RightTabRenderer = ({
|
|
|
114
114
|
tabpanelView?: FC<{}>;
|
|
115
115
|
}) => (
|
|
116
116
|
<TabRendererBase
|
|
117
|
-
side={SlotLocation.
|
|
117
|
+
side={SlotLocation.extendView}
|
|
118
118
|
direction={EDirection.RightToLeft}
|
|
119
119
|
id={VIEW_CONTAINERS.RIGHT_TABBAR_PANEL}
|
|
120
120
|
className={cls(className, 'right-slot')}
|
|
@@ -134,7 +134,7 @@ export const LeftTabRenderer = ({
|
|
|
134
134
|
tabbarView?: FC<{}>;
|
|
135
135
|
}) => (
|
|
136
136
|
<TabRendererBase
|
|
137
|
-
side={SlotLocation.
|
|
137
|
+
side={SlotLocation.view}
|
|
138
138
|
direction={EDirection.LeftToRight}
|
|
139
139
|
id={VIEW_CONTAINERS.LEFT_TABBAR_PANEL}
|
|
140
140
|
className={cls(className, 'left-slot')}
|
|
@@ -154,7 +154,7 @@ export const BottomTabRenderer = ({
|
|
|
154
154
|
tabbarView?: FC<{}>;
|
|
155
155
|
}) => (
|
|
156
156
|
<TabRendererBase
|
|
157
|
-
side={SlotLocation.
|
|
157
|
+
side={SlotLocation.panel}
|
|
158
158
|
id={VIEW_CONTAINERS.BOTTOM_TABBAR_PANEL}
|
|
159
159
|
direction={EDirection.BottomToTop}
|
|
160
160
|
className={cls(className, 'bottom-slot')}
|