josdejong / svelte-jsoneditor

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

Transform modal: Return javascript query from modal (and populate modal with existing query) #393

Open conorw opened 5 months ago

conorw commented 5 months ago

This control is exactly what I was looking for... with one exception:

Is it possible to expose the JavaScript query that is generated in the transform modal? Likewise, is it possible to populate the transform modal with an existing query?

josdejong commented 5 months ago

Thanks, good to hear. I'm not sure what you mean: do you mean copy/paste as an end user? (You can just edit the contents of the query in the "Query" input field). Or do you mean a programmatic API?

conorw commented 5 months ago

apologies @josdejong , I should have explained better: Ideally, I want to be able to save the javascript transformation code that is built in the transformation modal dialog. Hopefully the following quick and dirty PR should explain better https://github.com/josdejong/svelte-jsoneditor/pull/394

josdejong commented 5 months ago

Ah, yes, so you want to be able to programmatically initialize the query when opening the transform modal, and, I guess, get a callback with the applied query when the user clicks "Transform" in the modal. I like to open up the API for this!

We have to think through what API we want exactly. Some first thoughts: