Skip to content

Getting Started

Pick your setup: Vanilla JS/TS for a themed editor with toolbar and bubble menu out of the box, Angular, React, or Vue for ready-made components with auto-rendered toolbar and menus, or Headless for a bare editor you style yourself.

Click to try it out
  1. Terminal window
    pnpm add @domternal/core @domternal/theme
  2. import { Editor, StarterKit, defaultIcons } from '@domternal/core';
    import '@domternal/theme';
    const editorEl = document.getElementById('editor')!;
    // Toolbar
    const toolbar = document.createElement('div');
    toolbar.className = 'dm-toolbar';
    toolbar.innerHTML = `<div class="dm-toolbar-group">
    <button class="dm-toolbar-button" data-mark="bold">${defaultIcons.textB}</button>
    <button class="dm-toolbar-button" data-mark="italic">${defaultIcons.textItalic}</button>
    <button class="dm-toolbar-button" data-mark="underline">${defaultIcons.textUnderline}</button>
    </div>`;
    editorEl.before(toolbar);
    // Editor
    const editor = new Editor({
    element: editorEl,
    extensions: [StarterKit],
    content: '<p>Hello world</p>',
    });
    // Toggle marks on click (event delegation)
    toolbar.addEventListener('click', (e) => {
    const btn = (e.target as Element).closest<HTMLButtonElement>('[data-mark]');
    if (!btn) return;
    editor.chain().focus().toggleMark(btn.dataset.mark!).run();
    });
    // Active state sync
    editor.on('transaction', () => {
    toolbar.querySelectorAll<HTMLButtonElement>('[data-mark]').forEach((btn) => {
    btn.classList.toggle('dm-toolbar-button--active', editor.isActive(btn.dataset.mark!));
    });
    });

    StarterKit provides paragraphs, headings, lists, blockquotes, code blocks, task lists, inline formatting, keyboard shortcuts, and undo/redo. The @domternal/theme package adds editor styles, a toolbar layout, and 45 built-in icons via defaultIcons.

    For full control, skip StarterKit and import only the extensions you need.

Every extension in the kit can be disabled with false or configured with options:

StarterKit.configure({
codeBlock: false, // disable an extension
heading: { levels: [1, 2, 3, 4] }, // limit heading levels
history: { depth: 50 }, // configure undo stack
link: { openOnClick: false }, // keep links non-clickable while editing
linkPopover: false, // disable the built-in link popover
})

The full list of bundled extensions:

CategoryIncluded
NodesDocument, Text, Paragraph, Heading, Blockquote, CodeBlock, BulletList, OrderedList, ListItem, TaskList, TaskItem, HorizontalRule, HardBreak
MarksBold, Italic, Underline, Strike, Code, Link
BehaviorsBaseKeymap, History, Dropcursor, Gapcursor, TrailingNode, ListKeymap, LinkPopover, SelectionDecoration

Now that your editor is running, explore the rest of the toolkit:

  • StarterKit - see above for the full list of bundled extensions and how to configure them
  • Extensions - add tables, images, emoji, mentions, and syntax-highlighted code blocks via standalone packages
  • Theming - customize colors, spacing, and fonts with 70+ CSS custom properties on .dm-editor
  • Editor API - chain commands, listen to events, and read or update content programmatically
  • StackBlitz Example - a full working vanilla editor with all extensions you can edit in the browser