import { Component, inject } from '@angular/core';
import { YelonFormModule, SFSchema } from '@yelon/form';
import type { MonacoEditorWidgetSchema } from '@yelon/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: [YelonFormModule]
})
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));
}
}