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

Customize the configuration of CodeMirror in `text` mode #214

Closed topliceanu closed 6 months ago

topliceanu commented 1 year ago

Hi 👋 I'm looking for something similar to the solution in this issue https://github.com/josdejong/jsoneditor/issues/1082 Thanks!

josdejong commented 1 year ago

Thanks, that is a good suggestion. It would be helpful if you can adjust configuration of the CodeMirror editor (used for text mode) yourself.

I think we should introduce a callback onCreateCodeMirror, which allows you to adjust configuration of the created code mirror instance, and allows you to simply return a different instance if that is handier.

onCreateCodeMirror: (codeMirrorView: EditorView) => EditorView | undefined

It would be good to also create an example in the /src/routes/examples section demonstrating how to change some of the configuration, like line wrapping. Anyone able to help implementing this callback? Help would be welcome.

As for your actual case: the extension doing the text wrapping is located here:

https://github.com/josdejong/svelte-jsoneditor/blob/af6f5f2f69414b5018050ac9f97b90dadac2676a/src/lib/components/modes/textmode/TextMode.svelte#L492

josdejong commented 6 months ago

Moving this idea to the Discussions > Ideas section since we are not actively working on it. Help implementing this would be very welcome.