New community widget - Custom widget builder

Not to get too meta, but you can now use a custom widget to build custom widgets!

custom-widget-builder

Developed by @jarek (who does work at Grist Labs), who has been using this widget to build and test widgets on the fly. Think of it as a “widget fiddle”.

  • Build with HTML/JavaScript.
  • Documentation available within the widget itself (via “Open Configuration” > “Help”).
  • Remember to save your work, as there’s no autosave!

Now available as a community widget within Grist:

Some extra technical notes:

  • The widget itself is iframe inside an iframe, so some things (like locale) don’t get sent to your widget at the moment.
  • The “Open configuration” button won’t work for your widget, as the editor is intercepting it to open itself.
  • Since the editor intercepts certain messages, some development servers/browser extensions might cause issues if they are doing similar things.

Note: check out @jperon’s Pug/Python widget for a similar tool for building with Python.

9 Likes

Can the custom widgets created with this be shared, or even be copied to other documents you have youself?

I would love to know how far can we go with this Custom Widget Builder.

I suppose a lot of custom widgets already created depend on external libraries… for example… map widgets, the Advanced Charts widget, etc, right? And therefore those can´t be recreated with the custom widget builder??

This is great! Thanks for sharing, this’ll make quick prototyping a lot easier.

However, might I suggest the following for further improvement:

  • Store the HTML and JS in a record, via mapped columns, rather than in the widget settings. This would allow us to have a table dedicated to holding custom widgets, and open up easy ways of pulling in other data from the document.
  • Provide an option for iframeless operation, where ideally you’d have the <head> part of the HTML pre-configured (with the grist plugin api already included, of course) so that users would have to supply just the document body. This DOM could be dynamically appended rather than stuffed into an iframe.
1 Like

creating a widget through this, the configuration of where the data comes from… is it through the widget itself or the Creator Panel, like when creating a “normal” custom widget, as per instructions here?

You need to recreate it manually, just by copying JS and HTML content.

@Rogerio_Penna All limitation, that I can think of, were already mentioned, apart from that you can do whatever you want, in the end it just single HTML file rendered inside an iframe. Almost all custom widgets in the gallery can be recreated here (except this one and the one that inspects API, as this widget hijacks the Open configuration button).

The configuration is the same as in the instruction. This widget doesn’t change anything in the configuration.

Thanks for suggestion, but this way, you won’t be able to subscribe to onRecords event as the custom widget would need to be backed by this dedicated table. Alternatively, it could pull files from a different table, but then, it would require a full document access.

I’m not sure I understand it. In the HTML tab, you don’t need to add <html><head> tags at all. A widget with just a JS content (with all HTML removed) is perfectly fine, api library is added for you:

grist.ready({ requiredAccess: 'read table' });
grist.onRecords(table => {
  document.body.innerText = JSON.stringify(table);
});

ok, but I suppose it has several advantages over just using the HTML widget reading formulas from columns, right?