@autokinesis/react-markdown-editor
v0.0.1
Published
React markdown editor + preview components with light/dark themes, syntax highlighting, admonitions, and customizable styles.
Readme
@autokinesis/react-markdown-editor
React markdown editor + preview components with light/dark themes, syntax highlighting, admonitions, and customizable styles.
Install
npm install @autokinesis/react-markdown-editorPeer dependency:
react >= 18
Exports
Editor(alias ofMarkdownEditor): combined toolbar + textareaEditorToolbar(alias ofMarkdownEditorToolbar): standalone toolbarEditorTextarea(alias ofMarkdownEditorTextarea): standalone textareaPreview: markdown renderer
Types:
MarkdownThemeMarkdownEditorPropsMarkdownEditorToolbarPropsMarkdownEditorTextareaPropsPreviewProps
Quick Start (Combined Editor + Preview)
import { useState } from 'react'
import { Editor, Preview } from '@autokinesis/react-markdown-editor'
export default function Page() {
const [markdown, setMarkdown] = useState('# Hello')
return (
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 16 }}>
<Editor value={markdown} onChange={setMarkdown} theme="dark" />
<Preview doc={markdown} theme="dark" />
</div>
)
}Independent Composition (Toolbar and Textarea Separately)
Use this when your app header/layout controls where the toolbar should render.
import { useRef, useState } from 'react'
import { EditorToolbar, EditorTextarea, Preview } from '@autokinesis/react-markdown-editor'
export default function ComposedEditor() {
const [markdown, setMarkdown] = useState('')
const textareaRef = useRef<HTMLTextAreaElement>(null)
return (
<>
<EditorToolbar
value={markdown}
onChange={setMarkdown}
targetRef={textareaRef}
theme="dark"
/>
<EditorTextarea
ref={textareaRef}
value={markdown}
onChange={setMarkdown}
theme="dark"
placeholder="Write markdown..."
/>
<Preview doc={markdown} theme="dark" />
</>
)
}Standalone Preview
import { Preview } from '@autokinesis/react-markdown-editor'
<Preview doc={markdownText} theme="light" />Theme
theme is supported on editor and preview components:
lightdark
Admonition Syntax
Supported admonition input format is generic tag syntax only:
<admonition kind="warning" type="block" title="Warning">
Plain text with **bold** and `inline code`.
</admonition>
<admonition kind="risk" type="outline" title="Risk">
- Full markdown works in outline mode
- Lists, tables, fenced code blocks, etc.
</admonition>Supported kind values:
warningtipnotecriticalriskai-considerationassumptiondecisiondependency
Supported type values:
blockoutline
Styling and Customization
You can customize appearance by:
- Passing
classNameand scoping overrides:
<Preview doc={doc} className="my-preview" theme="dark" />.my-preview .ak-codeblock__lang {
border-radius: 999px;
}Overriding CSS variables (
--ak-*) at wrapper level.Targeting package classnames directly (examples):
.ak-editor__toolbar.ak-editor__textarea.ak-markdown.ak-admonition.ak-codeblock.ak-codeblock__lang
Notes
- Syntax highlighting is enabled for fenced code blocks.
- Language pill appears only when a language is explicitly provided in fenced blocks.
- Unknown/blocked image URLs render an inline fallback label.
