@richkitjs/extension-code-block
v0.3.1
Published
Code blocks for RichKit with syntax highlighting (16 languages built in, add any highlight.js grammar), language picker, line numbers, copy button and Tab indenting.
Maintainers
Readme
@richkitjs/extension-code-block
Code block extension for @richkitjs/core, a headless ProseMirror-based rich text editor.
Install
npm install @richkitjs/extension-code-block @richkitjs/coreMost users should install @richkitjs/starter-kit instead, which bundles all extensions.
Syntax highlighting
Code blocks are highlighted with lowlight. To keep bundles small, 16 common grammars are registered by default: bash, css, diff, go, java, javascript, json, markdown, php, python, rust, shell, sql, typescript, xml and yaml.
Register more through the languages option:
import { CodeBlock } from '@richkitjs/extension-code-block'
import { common } from 'lowlight'
import ruby from 'highlight.js/lib/languages/ruby'
CodeBlock.configure({ languages: { ruby } }) // one extra grammar
CodeBlock.configure({ languages: common }) // lowlight's 37-language setDocs
See the repository for usage and API documentation.
License
MIT — free for any use, commercial or not.
Need DOCX, track changes, comments, AI or the Pro editors (Notion, Classic, Question…)? Those are RichKit Pro.
