josdejong/jsoneditor

Allow custom rendering of fields and values

Open

#738 geöffnet am 13. Juli 2019

Auf GitHub ansehen
 (8 Kommentare) (4 Reaktionen) (0 zugewiesene Personen)JavaScript (2.034 Forks)batch import
featurehelp wanted

Repository-Metriken

Stars
 (10.781 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 15h 36m) (3 gemergte PRs in 30 T)

Beschreibung

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

Contributor Guide