This editor allows you to write code for a custom widget and "install" it inside a Grist document.
There are two tabs: JavaScript and HTML. The JavaScript tab is where you write code that interacts with the Grist plugin API, while the HTML tab is where you write the code that displays the results of the JavaScript code.
To open the editor, click the "Open configuration"
button in the creator panel or clear saved filter settings for this tab.
"Preview"
button, the widget (both the JavaScript and HTML code) will be saved in the document's metadata, and the editor will then replace itself with the widget you have created.
"Save"
button and save the configuration for a tab. It works similarly to saving filters in Grist.
The widget's state is persisted in the widget's metadata as JSON, with content encoded as two properties: _js
and _html
.
grist.setOptions({
_installed: true, // Flat indicating that the widget is installed.
_js: `...your js code....`,
_html: `...your html code...`,
});
In the final widget, the _html
field is inserted as is into an iframe, and the _js
field is embedded within a script tag afterwards.
For more details on custom widget development, please refer to the official Grist documentation.