Everything createEditor gives you.
Options
| Name | Type | Description |
|---|
| element | HTMLElement | Host element made contenteditable. |
| content | string | BabloomDoc | Initial HTML or JSON document. |
| extensions | Extension[] | Extensions to register. |
| editable | boolean | Defaults to true. |
| autofocus | boolean | Focus the editor on mount. |
| onUpdate | ({ editor }) => void | Fired after every document change. |
| onSelectionUpdate | ({ editor }) => void | Fired when the selection moves. |
| onFocus / onBlur | ({ editor }) => void | Focus lifecycle callbacks. |
Commands
| Name | Type | Description |
|---|
| toggleBold / Italic / Underline / Strike / Code | Editor | Toggle inline marks. |
| setBlock(tag) | Editor | p, h1, h2, h3 or blockquote. |
| toggleBulletList / toggleOrderedList | Editor | List toggles. |
| setHorizontalRule() | Editor | Insert a divider. |
| setLink(href) / unsetLink() | Editor | Link marks. |
| insertImage({ src, alt, width }) | Editor | Insert an image node. |
| insertHTML(html) | Editor | Insert raw HTML at the caret. |
| clearFormatting() | Editor | Remove all marks from the selection. |
| undo() / redo() / can(action) | Editor | boolean | History. |
| command(name, ...args) | Editor | Run an extension command. |
State
| Name | Type | Description |
|---|
| isActive(name) | boolean | bold, italic, underline, strike, code, link, heading1-3, blockquote, bulletList, orderedList. |
| getHTML() / getJSON() / getText() | string | BabloomDoc | Serialize the document. |
| setContent(content) | Editor | Replace the document. |
| setEditable(boolean) | Editor | Toggle read-only mode. |
| focus() / destroy() | void | Lifecycle. |
Events
const off = editor.on("update", ({ editor }) => save(editor.getJSON()));
editor.on("selection", () => refreshToolbar());
editor.on("image:upload:error", ({ error }) => toast.error(error.message));
off(); // unsubscribe