Syntax color JSON type field

Hola :smiley:,
Is there a way to make a simple code editor with syntax coloring based on language.
Like on Directus, for example if I have some settings in the JSON format,
it would be useful to have syntax color and detect errors.

Thanks

Hi @Sao.

It should be possible to build a custom widget that displays a code editor with the contents of the selected cell. A similar example of this is the markdown custom widget, which uses an open-source markdown library and the Grist API to allow you to view/edit column values in Markdown.

For a code editor, it should suffice to use an open-source library like Monaco Editor with the Grist API to build a custom widget similar to the Markdown widget. We use Monaco Editor it in the Inspect API custom widget for displaying example API code that can be edited.

Does this approach align with your use case, or were you looking for something different?

George

1 Like

oki thanks
and can it work with formulas ? I mean the one it’s written in python, to make the edition easier
so for example the actions / webhooks , I should make a custom widget to edit them, rigth ?

I don’t believe you can currently access the Python code of a formula column via the custom widget API, but you should be able to access the data computed by a formula if you’d like to display it in a custom widget.

The formula editor currently supports features like syntax highlighting, automatic indentation, and an error traceback, but it can certainly be improved; feel free to let us know about any suggestions or feature requests.

George

1 Like