跳到主要内容

API 参考

<SchemaEditor /> — 属性​

属性类型默认值说明
valuestring必填编辑器内容
onChange(value: string) => void—内容变化时调用
language"json" | "yaml" | "javascript"必填内容语言
schemaJsonSchema—用于补全和诊断的 JSON Schema(json/yaml)
snippetsstring[]—用于 JavaScript 行内预览补全的代码片段字符串
theme"light" | "dark""light"界面主题
readOnlybooleanfalse禁止编辑
placeholderstring—内容为空时的占位文本
showDiagnosticsbooleantrue显示诊断状态栏
enableInlineSuggestionsbooleantrue启用行内预览建议
enableCompletionbooleantrue启用弹出补全
diagnosticsDebounceMsnumber250诊断防抖延迟

核心导出 (@powerduck/schema-editor)​

函数说明
resolveSchemas(document)解析模式文档中的 $ref 指针
validateSchema(data, schema)根据模式验证数据
generateSample(schema)根据 JSON Schema 生成示例数据
getCompletionItems(model, position)获取光标位置处的补全项

类型​

import type { SchemaEditorProps } from "@powerduck/schema-editor/react";