Module object shape
Every toolbar button corresponds to a module object with five fields:| Field | Type | Description |
|---|---|---|
name | string | Unique identifier for the command, used to reference it in the toolbar config. |
group | string | Logical grouping: 'inline', 'block', 'history', 'insert', or any custom string. Used for styling and separator logic. |
icon | string | HTML string rendered inside the toolbar button — can be an emoji, a Unicode character, or an inline SVG. |
label | string | Tooltip text shown on hover. Also used as the accessible label for the button. |
exec | (editor: Editor) => void | Function called when the button is clicked. Receives the editor instance. |
The
icon field is rendered as raw HTML inside the button element, so you can pass a full <svg>...</svg> string for crisp, scalable icons at any size — not just emoji or text characters.Writing a custom module
Define a module object that follows the shape above. The example below adds a highlight command that applies a yellow background to the selected text:exec function receives the live editor instance, so you can call any public editor method, read the current selection, or dispatch DOM commands just like the built-in modules do.
Merging with built-in modules
Lumen Editor exports amodules object whose values are all the built-in module definitions. Spread them alongside your custom module so the editor retains its default commands:
highlight available for use in the toolbar config.
Adding to the toolbar config
Thetoolbar option is an array of groups, where each group is an array of command name strings. Add your module’s name to whichever group makes the most sense: