Open PanderMusubi opened 9 years ago
Interesting idea. I suppose this will be useful in combination with an event listener focus
, which is fired every time the focus has moved to an other element.
To lookup a JSONPath is also the feature, which i wanted to request. It would be very helpful.
Interesting, so where would I start to implement this kind of feature. Any file in particular I should refer to?
I have only experience in Python and Java with this. A search like https://duckduckgo.com/?q=javascript+json+path comes up with already a few good ways.
Thanks @tomkcey for your offer!
I guess this issue is about two features:
node.getPath()
, and convert it to a jsonpath using util.stringifyPath
.node.scrollTo
and after that node.focus
, something like:
node.scrollTo(function () {
node.focus();
});
So I think we have to expose this as a new method editor.focus(jsonpath)
, which parses the path using util.parsePath
, then finds the corresponding node using editor.node.findNodeByPath(...)
.
Does that make sense?
It does, but as I alluded to in the other issue's reply, I might have found a solution already for my limited needs. In fact, if my modifications in your source code don't break anything, it was only a matter of passing two parameters further down the onChange or onAction scopes. I'll get back to you in the coming weeks, then you can review my modifications and see if you can implement them in the code.
:+1:
I see that editor.focus(jsonpath)
is considered to be implemented. Is there any progress on it?
In my project I use external json validation which returns a json path when it finds an error and I need to set focus and highlight the erroneous node in the jsoneditor using this path.
I haven't heard back from Thomas about it. @tomkcey is implementing this feature still on your radar?
Hope to see this implemented. Some ideas: Perhaps under or over both views an input field for entering a path and with enter the results are highlighted. A button next to this field called "copy from selection" would copy paste the path from the selected element of that view in the field.
Please support lookup of JSONPath for where the cursor is. Additionally, select (of highlight) JSON for a specified JSONPath.