diff --git a/src/workbench/browser/src/app/pages/api/test/body/api-test-body.component.html b/src/workbench/browser/src/app/pages/api/test/body/api-test-body.component.html index 0064fa0da..585767713 100644 --- a/src/workbench/browser/src/app/pages/api/test/body/api-test-body.component.html +++ b/src/workbench/browser/src/app/pages/api/test/body/api-test-body.component.html @@ -20,8 +20,8 @@ - +
+ [maxLine]="20" [eventList]="['type', 'format', 'copy', 'search']">
diff --git a/src/workbench/browser/src/app/shared/components/monaco-editor/monaco-editor.component.html b/src/workbench/browser/src/app/shared/components/monaco-editor/monaco-editor.component.html index bc313977f..8bdc8e03d 100644 --- a/src/workbench/browser/src/app/shared/components/monaco-editor/monaco-editor.component.html +++ b/src/workbench/browser/src/app/shared/components/monaco-editor/monaco-editor.component.html @@ -4,5 +4,5 @@ {{ item.label }} - + diff --git a/src/workbench/browser/src/app/shared/components/monaco-editor/monaco-editor.component.ts b/src/workbench/browser/src/app/shared/components/monaco-editor/monaco-editor.component.ts index 02ff719ee..1b9b00f40 100644 --- a/src/workbench/browser/src/app/shared/components/monaco-editor/monaco-editor.component.ts +++ b/src/workbench/browser/src/app/shared/components/monaco-editor/monaco-editor.component.ts @@ -104,11 +104,11 @@ export class EoMonacoEditorComponent implements AfterViewInit, OnInit, OnChanges async ngOnChanges() { // * update root type if (this.eventList.includes('type') && !this.hiddenList.includes('type')) { - const type = whatTextType(this.$$code || ''); - this.editorType = type; - if (this.autoFormat) { - // this.$$code = await this.formatCode(); - } + requestIdleCallback(() => { + const type = whatTextType(this.$$code || ''); + this.editorType = type; + window.monaco?.editor.setModelLanguage(this.codeEdtor.getModel(), type); + }); } } ngOnInit() { @@ -134,10 +134,15 @@ export class EoMonacoEditorComponent implements AfterViewInit, OnInit, OnChanges this.completionItemProvider?.dispose(); } + modelChangeFn(code) { + // console.log('modelChangeFn', code); + } + private setCode(val: string) { if (val === this.$$code) { return; } + let code = ''; try { code = typeof val === 'string' ? val : JSON.stringify(val);