Skip to main content
The example keeps the note in localStorage; your app replaces that with its own storage.
1

Install the package

Inkkit is ESM-only and is imported through a bundler. Pin an exact version; see Versioning.
2

Add a root element

Declare UTF-8, which WebKit needs to load the bundle, and give the editor an element of its own:
Inkkit adds the class inkkit-root to the element and owns everything inside it.
3

Mount, load and save

This example imports @aicayzer/inkkit, which renders Mermaid diagrams. To leave Mermaid out of your page, import @aicayzer/inkkit/core instead; see Compatibility.
  • changed only prompts a save. At the moment you write, call snapshot(generation) and write its text.
  • A snapshot that throws saved nothing. Keep the document open and don’t treat it as unchanged. composition and operation-pending clear when text input or an image import finishes; for the other codes, see Save the document.
  • generation names this load. Pass it to every call that takes one, and give each later load a greater one. See Documents and saving.
  • Inkkit binds no formatting keys. Supply them in keymap, by the same names as the format commands. Mod is Command on Apple platforms and Control elsewhere. Undo, redo and moving blocks have default keys. To change bindings later, call setKeymap, which replaces the whole map. See Bind shortcuts.
  • error receives failures that no call is waiting for, such as an edit the person makes that Inkkit refuses because it would not save as shown.
  • close saves first, then awaits destroy() before it removes the root. If the save fails, the editor stays open.

Next steps