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

Is it possible to have readonly keys? #262

Closed nitzcard closed 1 year ago

nitzcard commented 1 year ago

Is it possible to define a template schema that we will see in the UI (like a form), the schema keys can't be deleted so the user have to fill them.

josdejong commented 1 year ago

I would like to implement an option onRenderKey, similar to onRenderValue. That would allow rendering a readOnly version.

This will not be enough to make the editor work like a form: to achieve that, you also need to disable most actions like insert, duplicate remove. We can discuss that in detail in https://github.com/josdejong/svelte-jsoneditor/discussions/261.

ChrisABryant commented 1 year ago

I made the keys uneditable and disabled context menu via the css posted in https://github.com/josdejong/svelte-jsoneditor/issues/260

josdejong commented 1 year ago

Please be aware that that is not a 100% solution: you can still edit a key via quick-keys. With the arrow keys you can move around the selected key or or value. If you select a key, you can still edit it by pressing Enter.