BaseKit – inksane
inksane
Kits

BaseKit

The standard Markdown features, editing shortcuts, history, and placeholder support.

BaseKit bundles the standard editor extensions. It uses the same extension API as individual features and lives in @inksane/core, so you do not need to install another package.

Core does not load the kit automatically. Register it through the editor’s extensions option.

Setup

Create a mount element, then import Editor and BaseKit:

<div id="editor"></div>
import { Editor } from "@inksane/core";
import { BaseKit } from "@inksane/core/extensions/base-kit";

const editor = new Editor({
  element: document.getElementById("editor")!,
  content: "# Hello inksane",
  extensions: [BaseKit()],
});

The kit supplies Markdown formatting, commands, and keyboard shortcuts. It also enables history and the editor’s placeholder and tabSize options. It does not provide typography or a toolbar. See Styling for themes and content styles.

React bindings accept the same extensions: [BaseKit()] option through useInksane or InksaneProvider.

Options

All features are enabled by default. Set an option to false to disable it. The link option also accepts a configuration object. BaseKitOptions is exported from @inksane/core/extensions/base-kit, and LinkOptions from @inksane/core/extensions/link.

OptionTypeDefaultFeature
boldbooleantrueBold
italicbooleantrueItalic
strikethroughbooleantrueStrikethrough
linkboolean | LinkOptionstrueLink
imagebooleantrueImage
codebooleantrueInline code and code blocks
headingbooleantrueHeadings
listbooleantrueBullet and ordered lists
taskListbooleantrueTask lists
footnotesbooleantrueFootnotes
blockquotebooleantrueBlockquotes
horizontalRulebooleantrueHorizontal rules
htmlbooleantrueHTML rendering
historybooleantrueUndo and redo
keybindsbooleantrueTab indentation
defaultKeymapbooleantrueEditing and search shortcuts
placeholderbooleantruePlaceholder support

Pass link options directly through the kit. onLinkRequest supplies the URL when Mod-k creates a link. Return null to cancel. Without this handler, Mod-k stays unbound.

import { Editor } from "@inksane/core";
import { BaseKit } from "@inksane/core/extensions/base-kit";

const editor = new Editor({
  element: document.getElementById("editor")!,
  extensions: [
    BaseKit({
      bold: false,
      link: {
        onLinkRequest: ({ text }) => window.prompt(`Link for "${text}"`),
      },
    }),
  ],
});

Placeholder and indentation

The kit options enable the features. The editor options set the placeholder text and indentation size:

import { Editor } from "@inksane/core";
import { BaseKit } from "@inksane/core/extensions/base-kit";

const editor = new Editor({
  element: document.getElementById("editor")!,
  placeholder: "Write some Markdown",
  tabSize: 4,
  extensions: [BaseKit()],
});

BaseKit({ defaultKeymap: false }) disables standard editing and search shortcuts while keeping the kit’s Tab indentation. To disable both keymap extensions, pass BaseKit({ defaultKeymap: false, keybinds: false }).

Collaboration history

When using the collaboration extension, pass BaseKit({ history: false }). Yjs owns undo and redo, so the standard CodeMirror history must stay disabled.

Replace a feature

Disable a feature in the kit before registering its replacement separately. Extensions are deduplicated by name, so an extension whose name is already registered is skipped. For example, to provide a separate link extension:

import { Editor } from "@inksane/core";
import { BaseKit } from "@inksane/core/extensions/base-kit";
import { LinkExtension } from "@inksane/core/extensions/link";

const editor = new Editor({
  element: document.getElementById("editor")!,
  extensions: [
    BaseKit({ link: false }),
    LinkExtension({
      onLinkRequest: () => window.prompt("Link URL"),
    }),
  ],
});

To build an editor without a kit, choose individual extensions. See the extension overview for command types and migration from automatic defaults.