Prerequisites
Before you begin, make sure you have the following in place:- A modern browser (Chrome 90+, Firefox 88+, Safari 14+, or Edge 90+) for the runtime environment.
- Node.js 16+ and npm (or yarn / pnpm) if you plan to install via a package manager. You can skip this requirement entirely if you prefer the CDN approach.
Steps
Install Lumen Editor
Add the package to your project using your preferred package manager.Then import the editor class and its stylesheet at the top of your entry file. The stylesheet import is required — it provides the toolbar styles and theme variables.
Add an HTML container
Lumen Editor mounts into any existing element on your page. Add a
<div> (or any block element) with an id that you will pass to the constructor. Give it a minimum height so it is visible before the user starts typing.Initialize the editor with options
Create a new
Editor instance, passing your container selector as the first argument and an options object as the second. The example below demonstrates the full set of supported options so you can pick the ones relevant to your use case.Every option is optional. Calling
new Editor('#editor', {}) is perfectly valid and gives you a working editor with sensible defaults.Listen for changes and read content
Subscribe to the You can also listen for other built-in events:
change event to react whenever the user edits the document. Use getHTML() to retrieve sanitized HTML or getText() for plain text.| Event | Fired when |
|---|---|
change | The document content changes |
selectionchange | The cursor or selection moves |
history:change | The undo/redo stack updates |
view:toggle | The editor switches between WYSIWYG and raw HTML view |
autosave | An auto-save write completes |
error | An internal error occurs (receives an object with a code property) |
What’s Next?
You now have a working Lumen Editor instance. From here you can:- Explore all install methods (yarn, pnpm, CDN) on the Installation page.
- Learn how to extend the editor with the plugin system by writing a simple
(editor) => { ... }function. - Tighten security or customise the sanitizer allowlist for your content requirements.