Skip to content

Commit 48c8984

Browse files
authored
feat: editorService support subscribe onMoveTab, onSelectTab, onCloseAll, onCloseTab, onCloseOth etc (#140)
1 parent a2d3d27 commit 48c8984

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

src/services/workbench/editorService.ts

+45
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ export interface IEditorService extends Component<IEditor> {
3838
originValue?: string
3939
) => void
4040
);
41+
onMoveTab(
42+
callback: (updateTabs: IEditorTab<any>[], groupId?: number) => void
43+
);
44+
onSelectTab(callback: (tabId: string, groupId?: number) => void);
45+
onCloseAll(callback: (groupId?: number) => void);
46+
onCloseTab(callback: (tabId: string, groupId?: number) => void);
47+
onCloseOthers(callback: (tabItem: IEditorTab, groupId?: number) => void);
48+
onCloseToLeft(callback: (tabItem: IEditorTab, groupId?: number) => void);
49+
onCloseToRight(callback: (tabItem: IEditorTab, groupId?: number) => void);
4150
/**
4251
* Set active group and tab
4352
* @param groupId Target group ID
@@ -298,4 +307,40 @@ export class EditorService
298307
) {
299308
this.subscribe(EditorEvent.OnUpdateTab, callback);
300309
}
310+
311+
public onMoveTab(
312+
callback: (updateTabs: IEditorTab<any>[], groupId?: number) => void
313+
) {
314+
this.subscribe(EditorEvent.OnMoveTab, callback);
315+
}
316+
317+
public onSelectTab(callback: (tabId: string, groupId?: number) => void) {
318+
this.subscribe(EditorEvent.OnSelectTab, callback);
319+
}
320+
321+
public onCloseAll(callback: (groupId?: number) => void) {
322+
this.subscribe(EditorEvent.OnCloseAll, callback);
323+
}
324+
325+
public onCloseTab(callback: (tabId: string, groupId?: number) => void) {
326+
this.subscribe(EditorEvent.OnCloseTab, callback);
327+
}
328+
329+
public onCloseOthers(
330+
callback: (tabItem: IEditorTab, groupId?: number) => void
331+
) {
332+
this.subscribe(EditorEvent.OnCloseOthers, callback);
333+
}
334+
335+
public onCloseToLeft(
336+
callback: (tabItem: IEditorTab, groupId?: number) => void
337+
) {
338+
this.subscribe(EditorEvent.OnCloseToLeft, callback);
339+
}
340+
341+
public onCloseToRight(
342+
callback: (tabItem: IEditorTab, groupId?: number) => void
343+
) {
344+
this.subscribe(EditorEvent.OnCloseToRight, callback);
345+
}
301346
}

0 commit comments

Comments
 (0)