josdejong/jsoneditor

Allow custom rendering of fields and values

开放

#738 创建于 2019年7月13日

 (8 条评论) (4 个反应) (0 位负责人)JavaScript (2,078 个派生)batch import
featurehelp wanted

仓库指标

星标
 (12,263 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

This topic is (indirectly) discussed here and there already. This is an explicit issue to address this feature.

It would be great to allow custom rendering of both the field (property) and values. That would allow you for example to:

The API and usage could look something like:

onRenderValue({ path, field, value, schema, onChange }) => {
  const html = document.createElement('INPUT')
  html.value = value
  html.onchange = function (event) {
    onChange(event.target.value)
  }
  
  return {
    html, 
    update: (value) => {
      html.value = value
    },
    destroy: () => { 
      // clean up any instantiated DOM stuff if needed
    }
  }
}

// onRenderField similar to onRenderValue

贡献者指南