EditorModule Interface
Every module — built-in or custom — implements the EditorModule interface:
A unique command identifier for the module. This is the string you reference in the
toolbar option array to place the button. It must be unique across all registered modules.The logical category of the command. Accepted values are
'inline', 'block', 'history', and 'insert'. The group does not affect rendering — it is metadata for your own organisation and for any third-party plugins that inspect the module registry.An HTML string rendered as the inner content of the toolbar button. You can use an SVG literal, a Unicode character, an
<img> tag, or any valid HTML fragment. The string is injected via innerHTML, so keep it trusted.The tooltip text displayed on hover and used as the button’s
aria-label. Keep labels short and descriptive — they are the primary accessibility affordance for the toolbar button.The function called when the toolbar button is clicked. Receives the live
Editor instance so you can call any public method — setHTML(), getHTML(), on(), focus(), etc. — or interact with document.execCommand for low-level formatting.Accessing Built-in Modules
Lumen Editor exports all built-in modules as a keyed record object:modules into your own array, override individual entries, or pick specific ones to keep the toolbar minimal:
Built-in Module Names
All 17 built-in modules and their groups:| Name | Group |
|---|---|
undo | history |
redo | history |
bold | inline |
italic | inline |
underline | inline |
strikethrough | inline |
h1 | block |
h2 | block |
h3 | block |
paragraph | block |
ul | block |
ol | block |
blockquote | block |
code | block |
link | insert |
image | insert |
html | insert |
Registering Custom Modules
To add a custom module, include it in themodules array alongside the built-ins, and add its name to the toolbar layout. The example below adds a Highlight button that applies a yellow background to selected text:
A module listed in the
toolbar array but absent from modules is silently skipped — no button is rendered and no error is thrown. Always make sure every command name in toolbar has a corresponding entry in modules.TypeScript Exports
Lumen Editor ships full TypeScript declarations. The following types are exported from thelumen-editor package and can be used to type plugins, modules, and editor options in your project: