Skip to content

Code Highlight Plugin

Code blocks can be syntax highlighted using one of two plugins: CodeHighlightPrismPlugin (backed by Prism) or CodeHighlightShikiPlugin (backed by Shiki). Include exactly one of them in your editor.

CodeHighlightPrismPlugin

Uses Prism for syntax highlighting.

Usage

<Composer {initialConfig}>
<div class="editor-shell">
<ToolbarRichText />
<div class="editor-container">
<div class="editor-scroller">
<div class="editor">
<ContentEditable />
</div>
</div>
<RichTextPlugin />
<CodeHighlightPrismPlugin />
</div>
</div>
</Composer>

CodeHighlightShikiPlugin

Uses Shiki under the hood. Shiki produces more accurate highlighting and supports a much wider range of themes and languages (including TextMate grammars).

Usage

<Composer {initialConfig}>
<div class="editor-shell">
<ToolbarRichText />
<div class="editor-container">
<div class="editor-scroller">
<div class="editor">
<ContentEditable />
</div>
</div>
<RichTextPlugin />
<CodeHighlightShikiPlugin />
</div>
</div>
</Composer>

Code Block Actions

Both plugins are compatible with CodeActionMenuPlugin, which adds Copy and Prettier action buttons to code blocks. Include it alongside whichever highlight plugin you choose.

<CodeHighlightShikiPlugin />
<CodeActionMenuPlugin />

Choosing between Prism and Shiki

PrismShiki
PluginCodeHighlightPrismPluginCodeHighlightShikiPlugin
Highlighting enginePrismShiki / TextMate grammars
Theme supportLimited (no support to change themes in the editor)Extensive
Package sizeFew KBs~1.4 MB

Use CodeHighlightPrismPlugin for a lightweight setup. Use CodeHighlightShikiPlugin when you need richer theme or language support.