josdejong/jsoneditor

Allow custom rendering of fields and values

Ouverte

#738 ouverte le 13 juil. 2019

 (8 commentaires) (4 réactions) (0 personne assignée)JavaScript (2 078 forks)batch import
featurehelp wanted

Métriques du dépôt

Stars
 (12 263 étoiles)
Métriques de merge PR
 (Métriques PR en attente)

Description

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

Guide contributeur