Features
Libraries
The CodeMirror pane the code and diagram editors type into, highlighted by Shiki in the editor theme.
editor-code-mirror is a library the code and diagram editors type into; it has no preview of its own.
Installation#
bash
pnpm dlx shadcn@latest add @zui/editor-code-mirrorUsage#
tsx
import { CodeMirrorPane } from '@/components/editor/shared/code-mirror';tsx
<div className="h-64 rounded-lg border">
<CodeMirrorPane language="typescript" value={source} onValueChange={setSource} />
</div>The pane fills the height it is given, so size its wrapper. value with onValueChange holds the text, or
defaultValue starts it; language takes a Shiki language id, and plain text without one. readOnly,
wrap, placeholder, tabSize, useTabs and showLineNumbers change the live pane without remounting it,
and size is default or sm.