josdejong / svelte-jsoneditor

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

Way to disable Sort, Transform, Format, Compact #326

Closed MitchBuell closed 6 months ago

MitchBuell commented 8 months ago

I'm using this tool to view and edit JSON that is test data and there are some features that I don't want available. They don't have to be removed, just disabled is enough. I would like to disable the Sort, Transform, Format, and Compact features. So far I used onRenderMenu to remove those 4 buttons from the toolbar, but Sort and Transform remain available in the right click context menu when in tree view. I don't want to remove the context menu entirely, just remove or disable Sort and Transform. It appears that these features already have the code to disable them as readOnly seems to do that.

Is there a way to disable these 4 features? Or can an API be added that possibly leverages the existing disabling that readOnly uses?

josdejong commented 8 months ago

Thanks for your inputs Mitch.

There is an open issue to implement an onRenderContextMenu similar to onRenderMenu, see #82.

For the time being, I think you can hide or disable these buttons yourself using CSS (like :nth-child), and then display:none or pointer-events: none !important; cursor: not-allowed !important;

Note that there are also quick keys to do some of these tasks, maybe good to check those out yourself too. I'm not sure though whether you can override those somehow.