Tiptap mark for inline code (`code`).
It mirrors Tiptap's built-in Code mark — backtick input and paste rules, <code> rendering, Mod-e — and keeps code-mode entry and exit out of the document: a collapsed caret enters through a ProseMirror stored mark, never a placeholder character, and ArrowRight at the document end exits without inserting a space.
bun add @docs.plus/extension-inline-codeRequires @tiptap/core ^3.22.3 and @tiptap/pm ^3.22.3 (Tiptap 3.x).
The 0.x line was monorepo-internal and never published. Upgrading from @tiptap/extension-code? See Migrating and the CHANGELOG.
import { Editor } from '@tiptap/core'
import StarterKit from '@tiptap/starter-kit'
import { InlineCode } from '@docs.plus/extension-inline-code'
const editor = new Editor({
extensions: [
// Disable StarterKit's built-in `code` mark — see Caveats.
StarterKit.configure({ code: false }),
InlineCode
]
})Type between single backticks (`like this`) to format text as inline code; pasted backtick text converts the same way.
| Option | Type | Default | Description |
|---|---|---|---|
HTMLAttributes |
Record<string, any> |
{} |
Attributes merged onto rendered <code> tags. |
InlineCode.configure({
HTMLAttributes: { class: 'my-custom-class' }
})| Command | Description |
|---|---|
setInlineCode() |
Apply the mark. |
toggleInlineCode() |
Toggle the mark. |
unsetInlineCode() |
Remove the mark. |
On a collapsed caret these seed a stored mark, so the next character you type is code — no placeholder character enters the document.
| Shortcut | Action |
|---|---|
Mod-e |
Toggle inline code. |
ArrowRight |
At the end of the document, leave code mode so the next character is plain. |
excludes: '_'— applying inline code removes every other mark from the selection (bold, italic, links); code text never stacks other marks. Upstream@tiptap/extension-codeparity.- StarterKit's
codemark claims the same<code>tag andMod-e. InlineCode registers at priority 101 and wins backtick input, paste, andMod-e; because the marks exclude each other,toggleInlineCodeover acodespan replacescodewithinlineCode— visually identical (both render<code>), butisActive('code')flips toisActive('inlineCode'). Keep the schema to a single<code>mark withStarterKit.configure({ code: false }). code: trueon the mark spec suppresses other extensions' input rules (typography, bold) inside code spans.Mod-eis the only shortcut —Mod-Shift-cwas removed in 2.0.0.
StarterKit.configure({ code: false }).- Replace
toggleCode/setCodewithtoggleInlineCode/setInlineCode. - Drop
Mod-Shift-cfrom docs — onlyMod-eremains.
Exports: InlineCode (default), InlineCodeOptions. Commands: setInlineCode, toggleInlineCode, unsetInlineCode.
Sibling packages: extensions/README.md.
Bug reports and PRs welcome. Setup, test commands, and the playground harness live in CONTRIBUTING.md.
MIT — see LICENSE.