Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to configure a "form" mode, only allow editing values #342

Closed
see7788 opened this issue Nov 23, 2023 · 1 comment
Closed

How to configure a "form" mode, only allow editing values #342

see7788 opened this issue Nov 23, 2023 · 1 comment
Labels
question Further information is requested

Comments

@see7788
Copy link

see7788 commented Nov 23, 2023

How to configure it: Only the value can be modified, the key can not be modified, the key cannot be added, and the deletion is not allowed

@josdejong josdejong changed the title How to configure it: Only the value can be modified, the key can not be modified, the key cannot be added, and the deletion is not allowed How to configure a "form" mode, only allow editing values Nov 29, 2023
@josdejong
Copy link
Owner

The svelte-jsoneditor library is not very suitable for a "form" mode like you describe: only allowing edits of values.

I did a short experiment with creating an editor with readOnly=true, and then create a custom onRenderValue which ignores this readOnly prop, intercepts the onPatch event and applies that itself to the JSON data, but it comes with some difficulties (because of the readOnly mode of the editor, and also, quickkeys don't work etc).

Besides that, you'll need to disable text mode and table mode. You can hide the buttons from the menu using some CSS, though when loading invalid JSON, the editor will still show a button to switch to text mode, so it may be hard to take care of all those edge cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants