josdejong/jsoneditor

Allow custom rendering of fields and values

Open

#738 建立於 2019年7月13日

在 GitHub 查看
 (8 留言) (4 反應) (0 負責人)JavaScript (2,034 fork)batch import
featurehelp wanted

倉庫指標

Star
 (10,781 star)
PR 合併指標
 (平均合併 15小時 36分鐘) (30 天內合併 3 個 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

貢獻者指南