Custom widget editors
Create custom editors for widgets, add the editor to the new widget menu or customize the menu
Last updated
Was this helpful?
Create custom editors for widgets, add the editor to the new widget menu or customize the menu
Last updated
Was this helpful?
When a new widget type is created using the , it will use the standard pipes widget editor by default. However, the developer may register a custom editor to be used for a widget type.
Here we will guide on how to do some of the most common tasks in the creation of a new widget using examples. For a detailed documentation of the available API please look at the JSDocs in the source code available at live/services/editor-menu
.
To create a widget editor, there are three main things a developer should do: create an editor component, register it using the EditorService and register an item in the "New chart" menu in the dashboard using the EditorMenuService.
The editor component receives as props the data (aLiveWidget
object), the stores and actions and the meta
array.
For the editor to be registered, it must provide a Higher Order wrapper component that receives the store and actions as parameters, as well as the meta
array.
Once registered, the url /#/widget/new?dashboard=123&type=my-simple-chart-editor
will be available to create a widget (in the dashboard 123
, in this example).
For the widget editor to be accessible in the dashboard menu, it must be registered using the EditorMenuService API. Since 2.28.0 images (210px x 100px) are used to represent the editors instead of icons. Editors added using the API below will be added to the "Standard charts" tab. If you want to customize the tabs, use the method described in the next section.
Starting in Live 2.28.0 you can use the following API to add a widget editor to the "Standard chart" tab.
In previous versions, the following API should be used.
While using the API described previously is recommended, it is possible to customize the tabs, creating new tabs, removing existing tabs and replacing the default "Standard Charts" tab. Notice internally we call tabs "groups" since the visual representation of these groups may change from tabs to some other representation.
If there are no widget editors in the standard tab, it will not be shown in the interface nor listed in the API.
The developer may replace the standard tab to rename it or change the order of the tabs. All existing editors added to the standard tab will be moved to the new standard tab and new editors added using the default API will be added to the new standard tab as well.
The developer may add a new tab to the menu and add editors to it
The developer may remove a tab if he so wishes, but is responsible for adding the editors in that tab to some other tab
Following the example from the , we will add an editor to the 'my-simple-chart'
widget type: