Overview
Register extensions and kits, choose individual features, and migrate from automatic defaults.
Extensions register commands, keybindings, Markdown parser additions, decorations, HTML converters, and CodeMirror extensions. An extension can also bundle child extensions.
Core loads no feature extensions automatically. Without extensions, it still parses Markdown and
provides the editor lifecycle, document access, and the clearContent, cutContent, deleteContent,
focus, insertContent, and setContent commands.
Kits
A kit bundles several extensions into one configuration. BaseKit provides the
standard Markdown features, history, editing shortcuts, and placeholder support. Pass BaseKit()
through the editor’s extensions option for the standard setup.
See the BaseKit reference for setup, options, and replacing a kit feature.
Individual imports
Import only the extensions you want and pass them through extensions. Most feature extensions
are objects. LinkExtension and BaseKit are factories:
import { Editor } from "@inksane/core";
import { BoldExtension } from "@inksane/core/extensions/bold";
import { ItalicExtension } from "@inksane/core/extensions/italic";
const editor = new Editor({
element: mount,
extensions: [BoldExtension, ItalicExtension],
});All feature imports use the prefix @inksane/core/extensions/:
| Feature | Import suffix | Export |
|---|---|---|
| Bold | bold | BoldExtension |
| Italic | italic | ItalicExtension |
| Strikethrough | strikethrough | StrikethroughExtension |
| Link | link | LinkExtension |
| Image | image | ImageExtension |
| Code | code | CodeExtension |
| Heading | heading | HeadingExtension |
| List | list | ListExtension |
| Task list | task-list | TaskListExtension |
| Footnotes | footnotes | FootnoteExtension |
| Blockquote | blockquote | BlockquoteExtension |
| Horizontal rule | horizontal-rule | HorizontalRuleExtension |
| HTML | html | HtmlExtension |
| History | history | HistoryExtension |
| Tab indentation | keybinds | KeybindExtension |
| Editing and search shortcuts | keybinds | DefaultKeymapExtension |
| Placeholder | placeholder | PlaceholderExtension |
Disabling a feature removes its commands, keybindings, decorations, state queries, HTML converters,
and parser additions. Standard Markdown syntax remains available in the underlying parser. For
example, bold: false leaves **text** in the document but removes the bold feature’s editor
behavior. Disabling strikethrough also removes its GFM parser support, so ~~text~~ stays literal.
Commands and types
Importing a feature also loads its TypeScript command declarations. Importing BaseKit loads the
declarations for its child extensions. These types describe imported features, not which options
are enabled on a particular editor. A kit command can still appear in TypeScript when its feature
is disabled, even though that command is absent at runtime.
Add your own extension
Add custom extensions beside the kit or your selected features:
import { Editor, type Extension } from "@inksane/core";
import { BaseKit } from "@inksane/core/extensions/base-kit";
const MyExtension: Extension = {
name: "my-extension",
};
const editor = new Editor({
element: mount,
extensions: [BaseKit(), MyExtension],
});Names must be unique
Each distinct extension name must be unique across the complete extension tree. Duplicate names and circular child-extension graphs throw while the editor is created. Reusing the same child instance through multiple parents is deduplicated.
priority is optional and defaults to 0. Higher-priority extensions are initialized first.
Command names should be unique too. Priority does not resolve command-name collisions.
Migrate from automatic defaults
To preserve the previous standard setup, add extensions: [BaseKit()] to your editor options.
React bindings also accept this option.
| Previous setup | New setup |
|---|---|
| Automatic feature extensions | Register BaseKit() or individual extensions. |
LinkExtension imported from @inksane/core | Import it from @inksane/core/extensions/link. |
placeholderTheme imported from @inksane/core | Import it from @inksane/core/extensions/placeholder. |
Editor option defaultKeymap: false | Pass BaseKit({ defaultKeymap: false }) through extensions. |
| A configured extension replaces the default by name | Disable the kit feature before adding its replacement. |
LinkOptions and LinkRequestContext now come from the link subpath. PlaceholderThemeStyles
comes from the placeholder subpath. Core document commands remain available without a kit.