Skip to content

Inline Code Plugin

The InlineCodePlugin adds inline <code> formatting for marking up code snippets, variable names, or technical terms within running text.

Inline code formatting in the editor

import { InlineCodePlugin } from '@notectl/core/plugins/inline-code';
new InlineCodePlugin()
interface InlineCodeConfig {
/** Show toolbar button. Default: true */
readonly toolbar?: boolean;
/** Override keyboard shortcut. Set to null to disable. Default: 'Mod-E' */
readonly keymap?: string | null;
/** Enable backtick InputRule. Default: true */
readonly inputRule?: boolean;
/** Override locale strings. */
readonly locale?: InlineCodeLocale;
}
// Disable toolbar button (keyboard/input rule only)
new InlineCodePlugin({ toolbar: false })
// Custom keyboard shortcut
new InlineCodePlugin({ keymap: 'Mod-Shift-C' })
// Disable keyboard shortcut
new InlineCodePlugin({ keymap: null })
// Disable backtick input rule
new InlineCodePlugin({ inputRule: false })
CommandDescriptionReturns
toggleInlineCodeToggle code mark on selectionboolean
editor.executeCommand('toggleInlineCode');
ShortcutAction
Ctrl+E / Cmd+EToggle inline code
PatternResult
`text`Wraps text with the code mark and removes the backticks

The backtick rule is disabled inside code blocks to preserve literal backtick characters.

PropertyDefaultDescription
--notectl-code-bgvar(--notectl-surface-raised)Background color
--notectl-code-colorvar(--notectl-fg)Text color

Override via CSS on the editor element:

notectl-editor {
--notectl-code-bg: #f0f0f0;
--notectl-code-color: #d63384;
}

Or responsive with media queries:

@media (prefers-color-scheme: light) {
notectl-editor {
--notectl-code-bg: #edf0f5;
--notectl-code-color: #334155;
}
}
@media (prefers-color-scheme: dark) {
notectl-editor {
--notectl-code-bg: #313244;
--notectl-code-color: #cdd6f4;
}
}

Use the inlineCode key in the theme object:

const editor = await createEditor({
theme: {
name: 'custom',
primitives: { /* ... */ },
inlineCode: {
background: '#f0f0f0',
foreground: '#d63384',
},
},
});

In Windows High Contrast mode (forced-colors: active), inline code receives a visible 1px solid border to remain distinguishable without relying on background color.

MarkHTML TagRank
code<code>3

The plugin recognizes two HTML patterns on paste:

PatternExample
<code> element<code>text</code>
<span> with monospace font<span style="font-family: monospace">text</span>

The monospace span rule covers paste content from Google Docs and similar editors that use inline styles instead of semantic <code> tags.

Inline code is mutually exclusive with formatting marks. When code is applied, existing formatting marks are automatically stripped. When the cursor is inside code-marked text, formatting commands are blocked.

Excluded marksAllowed marks
bold, italic, underline, strikethrough, highlight, font, fontSize, superscript, subscriptlink

This matches the convention used by editors like VS Code, GitHub, and Notion, where inline code is rendered in a monospace font without additional styling.

The inline code button (</> icon) renders in the format toolbar group with an isActive check. When the cursor is inside code-marked text, the button appears highlighted.

8 locales are bundled: English (default), German, Spanish, French, Chinese, Russian, Arabic, Hindi, and Portuguese. Locales are lazy-loaded based on the editor’s language setting.

import type { InlineCodeLocale } from '@notectl/core/plugins/inline-code';
const customLocale: InlineCodeLocale = {
label: 'Code',
tooltip: (shortcut) => `Code (${shortcut})`,
};
new InlineCodePlugin({ locale: customLocale })