josdejong / svelte-jsoneditor

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

OnSelect not working inside dialog box #428

Closed echan00 closed 1 month ago

echan00 commented 1 month ago

I believe OnSelect is not hooked up when selecting items in the dialog box.

I downloaded the repo to test on the existing examples. OnSelect works for table and tree mode. Once in the dialog box (text, tree and table mode) OnSelect is no longer called on selection

josdejong commented 1 month ago

With "the dialog box", do you mean for example the modal that opens when you right clicking an object and select "Edit object", which opens a modal with a title "Edit nested content"?

The OnSelect indeed only fires for the main editor, not for other instances like in a modal, that is intended behavior. Can you explain why you need that?

echan00 commented 1 month ago

Yes correct, I was referring to the dialog box that opens to allow you to edit in "table" mode.

The reason I need this is so that I can do something with the data that is being selected by the user. For example, open a url, play an audio/video file, etc.. that corresponds to the data being selected.

josdejong commented 1 month ago

Ok clear.

How about using onRenderValue to add a button in case of audio/video urls, or show a thumbnail/preview for those values? Then the user can click this to see the video or open the url? Another possibility is to use onRenderContextMenu to add a button in teh context menu to open the url.

echan00 commented 1 month ago

Oh, this looks great. I'll play with it and let you know how it goes.

echan00 commented 1 month ago

Works. Ended up implementing a hacky version taking advantage of onRenderContextMenu and onRenderValue

josdejong commented 1 month ago

Sounds good 💪