跳至主要内容

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";