mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-25 06:14:59 +00:00
58 lines
1.1 KiB
Lua
58 lines
1.1 KiB
Lua
-- JSON Editor utilities
|
|
|
|
---@class JsonEditor
|
|
local M = {}
|
|
|
|
---@class EditorOptions
|
|
---@field read_only? boolean
|
|
|
|
---@class UIComponent
|
|
---@field type string
|
|
---@field props? table
|
|
---@field children? table
|
|
|
|
---@class ValidationResult
|
|
---@field valid boolean
|
|
---@field errors table
|
|
|
|
---@class FormatAction
|
|
---@field action string
|
|
---@field language string
|
|
|
|
---@param value? string
|
|
---@param options? EditorOptions
|
|
---@return UIComponent
|
|
function M.render(value, options)
|
|
return {
|
|
type = "code_editor",
|
|
props = {
|
|
language = "json",
|
|
value = value or "{}",
|
|
read_only = options and options.read_only or false,
|
|
line_numbers = true,
|
|
auto_format = true
|
|
}
|
|
}
|
|
end
|
|
|
|
---@param json_string string
|
|
---@return ValidationResult
|
|
function M.validate(json_string)
|
|
-- JSON validation placeholder
|
|
return {
|
|
valid = true,
|
|
errors = {}
|
|
}
|
|
end
|
|
|
|
---@param json_string string
|
|
---@return FormatAction
|
|
function M.format(json_string)
|
|
return {
|
|
action = "format",
|
|
language = "json"
|
|
}
|
|
end
|
|
|
|
return M
|