File tree Expand file tree Collapse file tree
core/src/core/diff-viewer Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -105,10 +105,15 @@ export interface IOverrideAppRendererProps extends IOverrideAppRendererConfig {
105105 Landing ?: React . ComponentType < LandingProps > ;
106106}
107107
108+ export interface IExtraContent {
109+ component ?: React . ComponentType < any > ;
110+ initialProps ?: any ;
111+ }
112+
108113export const IDiffViewerProps = Symbol ( 'IDiffViewerProps' ) ;
109114export interface IDiffViewerProps extends Partial < IOverrideAppRendererProps > {
110115 onRef : ( handle : IDiffViewerHandle ) => void ;
111116
112117 onWillApplyTheme ?: ( theme : ITheme ) => Record < string , string | undefined > ;
113- tabBarRightExtraContent ?: React . ReactNode ;
118+ tabBarRightExtraContent ?: IExtraContent ;
114119}
Original file line number Diff line number Diff line change 1+ import { Autowired } from '@opensumi/di' ;
2+ import { ComponentContribution , ComponentRegistry } from '@opensumi/ide-core-browser' ;
3+ import { Domain } from '@opensumi/ide-core-common' ;
4+ import { TabbarRightExtraContentId } from '@opensumi/ide-editor' ;
5+ import { IDiffViewerProps } from '../common' ;
6+
7+ @Domain ( ComponentContribution )
8+ export class DiffViewerComponentContribution implements ComponentContribution {
9+ @Autowired ( IDiffViewerProps )
10+ protected diffViewerProps : IDiffViewerProps ;
11+
12+ registerComponent ( registry : ComponentRegistry ) {
13+ if ( this . diffViewerProps . tabBarRightExtraContent ) {
14+ registry . register ( TabbarRightExtraContentId , {
15+ id : TabbarRightExtraContentId ,
16+ component : this . diffViewerProps . tabBarRightExtraContent . component ,
17+ initialProps : this . diffViewerProps . tabBarRightExtraContent . initialProps ,
18+ } ) ;
19+ }
20+ }
21+ }
Original file line number Diff line number Diff line change @@ -2,12 +2,14 @@ import { BrowserModule } from '@opensumi/ide-core-browser';
22
33import { Injectable } from '../../modules/opensumi__common-di' ;
44import { DiffViewerContribution } from './internal/base' ;
5+ import { DiffViewerComponentContribution } from './internal/component.provider' ;
56import { DiffViewerThemeProvider } from './internal/theme.provider' ;
67
78@Injectable ( )
89export class DiffViewerModule extends BrowserModule {
910 providers = [
1011 DiffViewerContribution ,
1112 DiffViewerThemeProvider ,
13+ DiffViewerComponentContribution ,
1214 ] ;
1315}
Original file line number Diff line number Diff line change @@ -37,6 +37,14 @@ const App = () => {
3737
3838 const memo = useMemo ( ( ) => (
3939 < DiffViewerRenderer
40+ tabBarRightExtraContent = { {
41+ component : ( ) => < div > heelo</ div > ,
42+ } }
43+ onWillApplyTheme = { ( ) => {
44+ return {
45+ 'editorGroupHeader.tabsBackground' : '#fff' ,
46+ } ;
47+ } }
4048 onRef = { ( handle ) => {
4149 handleRef . current = handle ;
4250 console . log ( '=====' , handle ) ;
@@ -47,7 +55,7 @@ const App = () => {
4755 handle . onDidTabChange ( ( e ) => {
4856 console . log ( 'onDidTabChange' , e . newPath ) ;
4957 setEventInfo ( e ) ;
50- } )
58+ } ) ;
5159 data . forEach ( v => {
5260 handleRef . current ! . openDiffInTab (
5361 v . path ,
You can’t perform that action at this time.
0 commit comments