@@ -19,6 +19,9 @@ export type EditorAppConfigBase = ModelUpdate & {
19
19
domReadOnly ?: boolean ;
20
20
readOnly ?: boolean ;
21
21
awaitExtensionReadiness ?: Array < ( ) => Promise < void > > ;
22
+ overrideAutomaticLayout ?: boolean ;
23
+ editorOptions ?: editor . IStandaloneEditorConstructionOptions ;
24
+ diffEditorOptions ?: editor . IStandaloneDiffEditorConstructionOptions ;
22
25
}
23
26
24
27
export enum ModelUpdateType {
@@ -49,7 +52,7 @@ export abstract class EditorAppBase {
49
52
}
50
53
51
54
protected buildConfig ( userAppConfig : EditorAppConfigBase ) : EditorAppConfigBase {
52
- return {
55
+ const config : EditorAppConfigBase = {
53
56
$type : userAppConfig . $type ,
54
57
languageId : userAppConfig . languageId ,
55
58
code : userAppConfig . code ?? '' ,
@@ -59,8 +62,18 @@ export abstract class EditorAppBase {
59
62
codeOriginalUri : userAppConfig . codeOriginalUri ?? undefined ,
60
63
readOnly : userAppConfig . readOnly ?? false ,
61
64
domReadOnly : userAppConfig . domReadOnly ?? false ,
62
- awaitExtensionReadiness : userAppConfig . awaitExtensionReadiness ?? undefined
65
+ overrideAutomaticLayout : userAppConfig . overrideAutomaticLayout ?? true ,
66
+ awaitExtensionReadiness : userAppConfig . awaitExtensionReadiness ?? undefined ,
63
67
} ;
68
+ config . editorOptions = {
69
+ ...userAppConfig . editorOptions ,
70
+ automaticLayout : userAppConfig . overrideAutomaticLayout ?? true
71
+ } ;
72
+ config . diffEditorOptions = {
73
+ ...userAppConfig . diffEditorOptions ,
74
+ automaticLayout : userAppConfig . overrideAutomaticLayout ?? true
75
+ } ;
76
+ return config ;
64
77
}
65
78
66
79
haveEditor ( ) {
@@ -75,14 +88,14 @@ export abstract class EditorAppBase {
75
88
return this . diffEditor ;
76
89
}
77
90
78
- protected async createEditor ( container : HTMLElement , editorOptions ?: editor . IStandaloneEditorConstructionOptions ) : Promise < void > {
79
- this . editor = createConfiguredEditor ( container , editorOptions ) ;
80
- await this . updateEditorModel ( ) ;
81
- }
82
-
83
- protected async createDiffEditor ( container : HTMLElement , diffEditorOptions ?: editor . IStandaloneDiffEditorConstructionOptions ) : Promise < void > {
84
- this . diffEditor = createConfiguredDiffEditor ( container , diffEditorOptions ) ;
85
- await this . updateDiffEditorModel ( ) ;
91
+ async createEditors ( container : HTMLElement ) : Promise < void > {
92
+ if ( this . getConfig ( ) . useDiffEditor ) {
93
+ this . diffEditor = createConfiguredDiffEditor ( container , this . getConfig ( ) . diffEditorOptions ) ;
94
+ await this . updateDiffEditorModel ( ) ;
95
+ } else {
96
+ this . editor = createConfiguredEditor ( container , this . getConfig ( ) . editorOptions ) ;
97
+ await this . updateEditorModel ( ) ;
98
+ }
86
99
}
87
100
88
101
protected disposeEditor ( ) {
@@ -231,8 +244,7 @@ export abstract class EditorAppBase {
231
244
}
232
245
233
246
abstract init ( ) : Promise < void > ;
234
- abstract specifyService ( ) : editor . IEditorOverrideServices ;
235
- abstract createEditors ( container : HTMLElement ) : Promise < void > ;
247
+ abstract specifyServices ( ) : editor . IEditorOverrideServices ;
236
248
abstract getConfig ( ) : EditorAppConfigBase ;
237
249
abstract disposeApp ( ) : void ;
238
250
abstract isAppConfigDifferent ( orgConfig : EditorAppConfigBase , config : EditorAppConfigBase , includeModelData : boolean ) : boolean ;
0 commit comments