jsonlens icon indicating copy to clipboard operation
jsonlens copied to clipboard

Add format button the editor

Open rafaeltab opened this issue 1 year ago • 3 comments

Since you're using the monaco editor, you can already do json auto formatting using Shift + Alt + F, add a button for the people that don't know the shortcut, and show a tooltip with the shortcut when you hover over it.

editor.getAction("editor.action.formatDocument").run();

rafaeltab avatar May 13 '24 11:05 rafaeltab

Thanks for the suggestion and implementation details. I will add it if this issue gets some more upvotes. I am personally not sure whether to have a button just for formatting along with tooltip.

mohitkumartoshniwal avatar May 13 '24 12:05 mohitkumartoshniwal

I noticed that it wasn't there within the first minute of usage. I wanted to write some json in the editor, but the formatting was weird. I looked for the button, and realized that it was the monaco editor so I could probably just use the default shortcut. I think any json editor should really have a format button, and many popular platforms seem to agree. Firebase for example has a format button.

An alternative would be a button to create a popover with some shortcuts that can be used in the editor such as F1 for opening the command pallette, or Shift + Alt + F for formatting. It could contain controls for the graph view also.

rafaeltab avatar May 13 '24 12:05 rafaeltab

Yeah, the popover also looks interesting. I will think some more on having just a button for formatting or introducing a popover since I was planning to add shortcuts some time later for the whole application anyways. I will keep this issue open in the meantime. Thanks for the suggestion. It's quite helpful.

mohitkumartoshniwal avatar May 13 '24 14:05 mohitkumartoshniwal