import { Component, inject } from '@angular/core';
import { DelonFormModule, SFSchema } from '@delon/form';
import type { MonacoEditorWidgetSchema } from '@delon/form/widgets-third/monaco-editor';
import { NzMessageService } from 'ng-zorro-antd/message';
@Component({
selector: 'form-monaco-editor-simple',
template: `<sf [schema]="schema" (formSubmit)="submit($event)" />`,
standalone: true,
imports: [DelonFormModule]
})
export class FormMonacoEditorSimpleComponent {
private readonly msg = inject(NzMessageService);
schema: SFSchema = {
properties: {
json: {
type: 'string',
title: 'JSON',
default: `{"string": "abc","number": 1 }`,
ui: {
widget: 'monaco-editor',
options: { language: 'json' }
} as MonacoEditorWidgetSchema
}
}
};
submit(value: {}): void {
this.msg.success(JSON.stringify(value));
}
}