vankop/jsoneditor-react

Would like to see tooltips based on the schema?

Closed this issue · 1 comments

wbern commented

As mentioned here by me: josdejong/jsoneditor#321

Is there a nice way to implement it using this library perhaps?

Unfortunately, you can't achieve mapping field to it's title/description by using this lib.

My suggetion is to use ref to get your jsoneditor React component instance and use this code to implement this feature by yourself.

For instance:

YourSmartComponent.jsx

import React from 'react';
import { JsonEditor } from 'jsoneditor-react';

class SmartComponent extends React.Component {
      setJsonEditorRef = instance => this.editor = instance;

     componentDidMount() {
          if (this.editor) {
                  this.transformEditorOnTreeView();
          }
    }

    componentDidUpdate() {
          if (this.editor) {
                  this.transformEditorOnTreeView();
          }
    }

     transformEditorOnTreeView() {
           const jsonEditor = this.editor.jsonEditor;
           const node = this.editor.htmlElementRef;

          if (jsonEditor.getMode() !== 'tree') return;

          // Your manipulations with dom
     }

      render() {
             return <JsonEditor ref={this.setJsonEditorRef} {...otherProps} />;
      }
}