Extensions
Everything the editor can do is an extension: keymaps, input rules and commands.
Bundled extensions
| Name | Type | Description |
|---|---|---|
| StarterKit() | Extension | Headings, lists, quote, marks, shortcuts and Markdown input rules. |
| LinkExtension() | Extension | setLink / unsetLink commands and optional open-on-click. |
| PlaceholderExtension() | Extension | Shows placeholder text while the document is empty. |
| ImageExtension() | Extension | File picker, validation, drag & drop, paste and upload handling. |
Markdown shortcuts
StarterKit registers input rules for `# `, `## `, `### `, `> `, `- ` and `1. `.
Writing your own
ts
import type { Extension } from "@tlob/babloom-core";
export function HighlightExtension(): Extension {
return {
name: "highlight",
keymap: {
"Mod-Shift-h": (editor) => editor.insertHTML("<mark>" + window.getSelection() + "</mark>"),
},
inputRules: [
{ match: /^==\s(.*)$/, handler: (editor) => editor.insertHTML("<mark></mark>") },
],
commands: {
clearHighlights: (editor) =>
editor.element?.querySelectorAll("mark").forEach((m) => m.replaceWith(m.textContent ?? "")),
},
onCreate: (editor) => console.log("highlight ready", editor.name),
};
}Register it like any other extension and call it with editor.command("clearHighlights").