# YAML Editor

基于 Monaco Editor 的 YAML 编辑器组件，支持 Schema 驱动的智能补全和语法校验。

## 功能特性

- YAML 语法高亮
- Schema 驱动的智能补全
- YAML 语法验证
- 支持浅色/深色主题
- 支持多尺寸（small, middle, large）
- 只读和禁用模式
- Enter 键快捷执行回调（可选）
- Shift+Enter 换行

## 使用方法

```tsx
import { YamlMonacoEditor } from '@fc-components/monaco-editor';

function MyComponent() {
  const [value, setValue] = React.useState('');

  return (
    <YamlMonacoEditor
      value={value}
      onChange={setValue}
      theme="light"
    />
  );
}
```

### Schema 补全

通过 `schemas` 属性传入 JSON Schema，编辑器会自动提供字段名补全：

```tsx
<YamlMonacoEditor
  schemas={[
    {
      uri: 'http://example.com/schema.json',
      fileMatch: ['*'],
      schema: {
        type: 'object',
        properties: {
          name: { type: 'string' },
          version: { type: 'string' },
          replicas: { type: 'number' },
        },
      },
    },
  ]}
/>
```

## Props

| 参数               | 类型                                      | 默认值      | 说明                         |
| ------------------ | ----------------------------------------- | ----------- | ---------------------------- |
| `size`             | `'small' \| 'middle' \| 'large'`          | `'middle'`  | 编辑器尺寸                   |
| `theme`            | `'light' \| 'dark'`                       | `'light'`   | 主题                         |
| `value`            | `string`                                  | -           | 编辑器内容                   |
| `placeholder`      | `string`                                  | -           | 占位符文本                   |
| `enableAutocomplete`| `boolean`                                | `true`      | 启用代码补全                 |
| `readOnly`         | `boolean`                                 | `false`     | 只读模式                     |
| `disabled`         | `boolean`                                 | `false`     | 禁用编辑                     |
| `schemas`          | `YamlEditorSchema[]`                      | `[]`        | JSON Schema 数组，用于驱动补全 |
| `onChange`         | `(value: string) => void`                 | -           | 内容变化回调                 |
| `onEnter`          | `(value: string) => void`                 | -           | Enter 键触发                 |
| `onBlur`           | `(value: string) => void`                 | -           | 编辑器失焦回调               |
| `editorDidMount`   | `(editor) => void`                        | -           | 编辑器挂载完成回调           |