### quick-start.md Overview
Source: https://github.com/uiwjs/react-md-editor/blob/master/_autodocs/MANIFEST.md
The quick-start.md file provides a guide for getting started with the editor, covering installation, minimal and complete examples, and various usage patterns.
```markdown
### 2. quick-start.md (509 lines)
**Purpose:** Getting started guide
**Contents:**
- Installation instructions
- Minimal example
- Complete feature example
- Preview-only usage
- Dark mode implementation
- Custom commands
- Controlled vs uncontrolled
- Edit-only and preview-only modes
- Responsive layout
- Syntax highlighting options
- Auto-save pattern
- Character limit implementation
- Next.js integration
- Statistics monitoring
- RTL support
- Programmatic control
- CSS management
- Troubleshooting guide
**Sections:** 18
**Code Examples:** 20
```
--------------------------------
### Example: Using getState
Source: https://github.com/uiwjs/react-md-editor/blob/master/_autodocs/text-area-api.md
Demonstrates how to get and log the current state of a textarea using the orchestrator.
```typescript
const orchestrator = new TextAreaCommandOrchestrator(textareaElement);
const state = orchestrator.getState();
if (state) {
console.log('Current text:', state.text);
console.log('Selected:', state.selectedText);
console.log('Cursor:', state.selection);
}
```
--------------------------------
### Install KaTeX for Custom Preview
Source: https://github.com/uiwjs/react-md-editor/blob/master/core/README.md
Install the KaTeX library to enable custom math rendering within the markdown editor.
```bash
npm install katex
```
--------------------------------
### Install Mermaid for Custom Preview
Source: https://github.com/uiwjs/react-md-editor/blob/master/core/README.md
Install the mermaid library to enable custom diagram previews within the markdown editor.
```bash
npm install mermaid
```
--------------------------------
### Install Dependencies
Source: https://github.com/uiwjs/react-md-editor/blob/master/core/README.md
Install project dependencies using npm.
```bash
$ npm install # Installation dependencies
$ npm run build # Compile all package
```
--------------------------------
### Start Documentation Site
Source: https://github.com/uiwjs/react-md-editor/blob/master/core/README.md
Launch the local documentation site for the project.
```bash
npm run start
```
--------------------------------
### Responsive Layout Example
Source: https://github.com/uiwjs/react-md-editor/blob/master/_autodocs/quick-start.md
Implement a responsive layout for the markdown editor, ensuring it fits well within a container and adapts to different screen sizes. This example uses flexbox for layout.
```tsx
import MDEditor from '@uiw/react-md-editor';
export default function App() {
const [value, setValue] = useState('');
return (
Markdown Editor
);
}
```
--------------------------------
### Install React-MD-Editor with yarn
Source: https://github.com/uiwjs/react-md-editor/blob/master/_autodocs/quick-start.md
Use this command to install the package using yarn.
```bash
yarn add @uiw/react-md-editor
```
--------------------------------
### Install React-MD-Editor with npm
Source: https://github.com/uiwjs/react-md-editor/blob/master/_autodocs/quick-start.md
Use this command to install the package using npm.
```bash
npm install @uiw/react-md-editor
```
--------------------------------
### Install KaTeX for Mathematical Expressions
Source: https://github.com/uiwjs/react-md-editor/blob/master/_autodocs/markdown-preview.md
Install the necessary packages, katex and rehype-rewrite, to enable rendering of mathematical expressions using KaTeX within the markdown preview.
```bash
npm install katex rehype-rewrite
```
--------------------------------
### Install Mermaid for Diagram Rendering
Source: https://github.com/uiwjs/react-md-editor/blob/master/_autodocs/markdown-preview.md
Install the mermaid and rehype-rewrite packages to enable the rendering of diagrams defined using Mermaid syntax within the markdown preview.
```bash
npm install mermaid rehype-rewrite
```
--------------------------------
### Basic MDEditor Integration Example
Source: https://github.com/uiwjs/react-md-editor/blob/master/_autodocs/md-editor-component.md
A basic example demonstrating how to use the MDEditor component in a React application. It includes state management for the editor's value and sets a fixed height and live preview mode.
```typescript
import React, { useState } from 'react';
import MDEditor from '@uiw/react-md-editor';
export default function App() {
const [value, setValue] = useState('**Hello world!**');
return (
);
}
```
--------------------------------
### Build Project
Source: https://github.com/uiwjs/react-md-editor/blob/master/README.md
Compile all packages in the project using npm. This command is used after installing dependencies.
```bash
npm run build # Compile all package
```
--------------------------------
### Run Next.js Development Server
Source: https://github.com/uiwjs/react-md-editor/blob/master/example/nextjs/README.md
Use these commands to start the local development server for your Next.js project. Open http://localhost:3000 in your browser to view the application.
```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```
--------------------------------
### Internationalization Example
Source: https://github.com/uiwjs/react-md-editor/blob/master/core/README.md
Demonstrates how to use internationalized commands for the editor by importing them from '@uiw/react-md-editor/commands-cn'.
```jsx
import React, { useContext } from "react";
import MDEditor, { commands } from "@uiw/react-md-editor";
import { getCommands, getExtraCommands } from "@uiw/react-md-editor/commands-cn";
export default function App() {
const [value, setValue] = React.useState("**Hello world!!!**");
return (
setValue(val)}
/>
);
}
```
--------------------------------
### Complete React-MD-Editor Feature Example
Source: https://github.com/uiwjs/react-md-editor/blob/master/_autodocs/quick-start.md
An advanced example showcasing various features of MDEditor, including custom commands, event handlers for statistics and height changes, and live preview. Remember to import CSS and necessary components.
```tsx
import React, { useState, useRef } from 'react';
import MDEditor, { commands } from '@uiw/react-md-editor';
import '@uiw/react-md-editor/markdown-editor.css';
import '@uiw/react-markdown-preview/markdown.css';
export default function App() {
const [value, setValue] = useState('# Welcome to Markdown Editor\n\nStart typing...');
const editorRef = useRef();
const handleChange = (val) => {
setValue(val);
};
const handleStats = (stats) => {
console.log('Lines:', stats.lineCount, 'Characters:', stats.length);
};
const handleHeightChange = (newHeight, oldHeight) => {
console.log(`Height changed from ${oldHeight} to ${newHeight}`);
};
return (
);
}
```
--------------------------------
### README.md Overview
Source: https://github.com/uiwjs/react-md-editor/blob/master/_autodocs/MANIFEST.md
The README.md file serves as the master index and overview for the project, guiding users through documentation navigation and providing a project overview.
```markdown
# Documentation Manifest
## Complete Technical Reference for @uiw/react-md-editor
**Project:** React MD Editor
**Version:** 4.1.1
**Generated:** 2026-07-05
**Documentation Format:** Markdown
**Total Files:** 11
**Total Lines:** 5,542
**Total Size:** 152 KB
---
## File Contents
### 1. README.md (387 lines)
**Purpose:** Master index and overview
**Contents:**
- Documentation navigation guide
- Project overview and features
- Quick reference examples
- Component structure
- State management overview
- Default keyboard shortcuts
- API surface summary
- Performance considerations
- Browser support
- Customization points
- Common integrations
- Troubleshooting reference
**Sections:** 15+
**Code Examples:** 4
```
--------------------------------
### Install Dependencies for Next.js
Source: https://github.com/uiwjs/react-md-editor/blob/master/core/README.md
Install next-remove-imports and a specific version of react-md-editor for Next.js projects.
```bash
npm install next-remove-imports
npm install @uiw/react-md-editor@v3.6.0
```
--------------------------------
### Install rehype-sanitize
Source: https://github.com/uiwjs/react-md-editor/blob/master/_autodocs/markdown-preview.md
Install the rehype-sanitize package to enable HTML sanitization for your Markdown preview.
```bash
npm install rehype-sanitize
```
--------------------------------
### Help Command
Source: https://github.com/uiwjs/react-md-editor/blob/master/_autodocs/commands.md
Opens the markdown syntax help documentation. This command provides quick access to markdown formatting guides.
```typescript
commands.help: ICommand = {
name: 'help',
keyCommand: 'help',
}
```
--------------------------------
### Internationalization Example for React MD Editor
Source: https://github.com/uiwjs/react-md-editor/blob/master/README.md
Demonstrates how to internationalize the React MD Editor using commands from '@uiw/react-md-editor/commands-cn'. Requires React and MDEditor.
```jsx
import React, { useContext } from "react";
import MDEditor, { commands } from "@uiw/react-md-editor";
import { getCommands, getExtraCommands } from "@uiw/react-md-editor/commands-cn";
export default function App() {
const [value, setValue] = React.useState("**Hello world!!!**");
return (
setValue(val)}
/>
);
}
```
--------------------------------
### Complete Plugin Example with Context API
Source: https://github.com/uiwjs/react-md-editor/blob/master/_autodocs/context-api.md
Demonstrates how to create a full-featured plugin using the EditorContext to read and modify editor state. It includes updating stats on content change and adding buttons for custom actions like inserting the current date or clearing all content. The plugin is conditionally rendered based on the fullscreen state.
```typescript
import React, { useContext, useState } from 'react';
import { EditorContext } from '@uiw/react-md-editor';
function AdvancedPlugin() {
const {
markdown,
preview,
dispatch,
fullscreen,
textarea,
} = useContext(EditorContext);
const [stats, setStats] = useState({ lines: 0, chars: 0 });
// Update stats on content change
React.useEffect(() => {
if (markdown) {
setStats({
lines: markdown.split('\n').length,
chars: markdown.length,
});
}
}, [markdown]);
const handleInsertDate = () => {
const today = new Date().toLocaleDateString();
dispatch({ markdown: (markdown || '') + `\n\n*Last updated: ${today}*` });
};
const handleClearAll = () => {
if (window.confirm('Clear all content?')) {
dispatch({ markdown: '' });
}
};
if (fullscreen) return null; // Hide plugin in fullscreen
return (
Stats: {stats.lines} lines, {stats.chars} chars
);
}
// Usage in MDEditor
export function App() {
const [value, setValue] = React.useState('');
return (
);
}
```
--------------------------------
### Example: Customizing Toolbar with Command Groups
Source: https://github.com/uiwjs/react-md-editor/blob/master/_autodocs/commands.md
Demonstrates how to use the `group` function to create a dropdown for titles and combine it with other commands like dividers and bold text in the MDEditor component.
```jsx
import MDEditor, { commands } from '@uiw/react-md-editor';
```
--------------------------------
### Display Markdown Preview in a Modal
Source: https://github.com/uiwjs/react-md-editor/blob/master/_autodocs/markdown-preview.md
Integrate the Markdown preview into a modal or dialog component. This example shows how to toggle visibility and style the modal for display.
```tsx
const [showPreview, setShowPreview] = useState(false);
<>
{showPreview && (
)}
>
```
--------------------------------
### Headless Editor Implementation
Source: https://github.com/uiwjs/react-md-editor/blob/master/_autodocs/advanced-features.md
Create a custom editor using only the API layer without the built-in UI. This example demonstrates how to manage text changes, handle keyboard events for indentation and shortcuts, and integrate with custom display elements.
```tsx
import React, { useRef, useEffect, useState } from 'react';
import {
TextAreaCommandOrchestrator,
handleKeyDown,
shortcuts,
getCommands,
TextAreaTextApi,
} from '@uiw/react-md-editor';
function HeadlessEditor() {
const textareaRef = useRef(null);
const preRef = useRef(null);
const orchestratorRef = useRef(null);
const [value, setValue] = useState('');
useEffect(() => {
if (textareaRef.current) {
orchestratorRef.current = new TextAreaCommandOrchestrator(
textareaRef.current
);
}
}, []);
const onKeyDown = (e: React.KeyboardEvent) => {
// Handle tab indentation, enter list items, etc.
handleKeyDown(e, 2, false);
// Handle command shortcuts (Ctrl+B, Ctrl+I, etc.)
if (orchestratorRef.current) {
shortcuts(e, getCommands(), orchestratorRef.current);
}
};
const onChange = (e: React.ChangeEvent) => {
setValue(e.target.value);
};
return (
{value}
);
}
```
--------------------------------
### Basic Usage of React MD Editor
Source: https://github.com/uiwjs/react-md-editor/blob/master/www/public/bundle.html
Demonstrates the basic setup for using MDEditor and MDEditor.Markdown components. It shows how to manage the editor's value using React's useState hook.
```javascript
import MDEditor from '@uiw/react-md-editor';
function Demo() {
const [value, setValue] = React.useState("**Hello world!!!**");
return (
);
}
ReactDOM.render(, document.getElementById('container'));
```
--------------------------------
### Headless Markdown Editor with Keyboard Shortcuts
Source: https://github.com/uiwjs/react-md-editor/blob/master/core/README.md
Build a custom markdown editor UI using headless utilities. This example demonstrates a textarea that supports markdown keyboard shortcuts and newline handling.
```jsx
import React from "react";
import {
handleKeyDown,
shortcuts,
TextAreaCommandOrchestrator,
getCommands,
} from '@uiw/react-md-editor';
export default function App() {
const [value, setValue] = React.useState("**Hello world!!!**");
const textareaRef = React.useRef(null);
const orchestratorRef = React.useRef(null);
React.useEffect(() => {
if (textareaRef.current) {
orchestratorRef.current = new TextAreaCommandOrchestrator(textareaRef.current);
}
}, []);
const onKeyDown = (e) => {
handleKeyDown(e, 2, false);
if (orchestratorRef.current) {
shortcuts(e, getCommands(), orchestratorRef.current);
}
};
return (