josdejong / svelte-jsoneditor

A web-based tool to view, edit, format, repair, query, transform, and validate JSON
https://jsoneditoronline.org
Other
820 stars 108 forks source link

How to get the selected JSONPath by clicking on a node? #263

Closed baarbaracrr closed 1 year ago

baarbaracrr commented 1 year ago

It won't let me add the onSelect function and it would be great if something like the onClassName function would help me with this. I am working with angular, and this is what I have in my typescript

this.jsoneditor = new JSONEditor({
        target: this.jsonEditorContainer.nativeElement,
        props: {
          content,
          mode: Mode.tree,
          onClassName: (path: JSONPath, value: JSONValue) => {
            console.log(path);
            return '';
          },
          onChange: (updatedContent, previousContent, { contentErrors, patchResult }) => {
            console.log('onChange', { updatedContent, previousContent, contentErrors, patchResult })
          },
          readOnly: true
        }
      });

My html content is this:

<div #jsonEditorContainer></div>
josdejong commented 1 year ago

So what is your question exactly? An onSelect function does not yet exist, see #163.