MCPcopy Index your code
hub / github.com/uiwjs/react-md-editor

github.com/uiwjs/react-md-editor @v4.1.1 sqlite

repository ↗ · DeepWiki ↗ · release v4.1.1 ↗
99 symbols 275 edges 68 files 4 documented · 4% 7 cross-repo links
README

Special thanks to:

SubList

SubList - Bill Reminder & Renewal Alerts


Using my app is also a way to support me:

Zipora: Zip/RAR/7Z Unarchiver Scap: Screenshot & Markup Edit Screen Test Deskmark Keyzer Vidwall Hub VidCrop Vidwall Mousio Hint Mousio Musicer Audioer FileSentinel FocusCursor Videoer KeyClicker DayBar Iconed Menuist Quick RSS Quick RSS Web Serve Copybook Generator DevTutor for SwiftUI RegexMate Time Passage Iconize Folder Textsound Saver Create Custom Symbols DevHub Resume Revise Palette Genius Symbol Scribe


react-md-editor logo

Buy me a coffee Follow On X Downloads npm bundle size Coverage Status

Build & Deploy Open in unpkg Gitee npm version

A simple markdown editor with preview, implemented with React.js and TypeScript. This React Component aims to provide a simple Markdown editor with syntax highlighting support. This is based on textarea encapsulation, so it does not depend on any modern code editors such as Acs, CodeMirror, Monaco etc.

Features

  • 📑 Indent line or selected text by pressing tab key, with customizable indentation.
  • ♻️ Based on textarea encapsulation, does not depend on any modern code editors.
  • 🚧 Does not depend on the uiw component library.
  • 🚘 Automatic list on new lines.
  • 😻 GitHub flavored markdown support.
  • 🌒 Support dark-mode/night-mode @v3.11.0+.
  • 💡 Support next.js, Use examples in next.js.
  • Line/lines duplication (Ctrl+D) and movement (Alt+UpArrow/DownArrow) @v3.24.0+.

Quick Start

npm i @uiw/react-md-editor

or

yarn add @uiw/react-md-editor

Using

Open in CodeSandbox Open in Github gh-pages Open in Gitee gh-pages

```jsx mdx:preview import React from "react"; import MDEditor from '@uiw/react-md-editor';

export default function App() { const [value, setValue] = React.useState("Hello world!!!"); return (

  <MDEditor
    value={value}
    onChange={setValue}
  />
  <MDEditor.Markdown source={value} style={{ whiteSpace: 'pre-wrap' }} />

); }


### Headless Mode

The package exposes the necessary utilities to build a headless markdown editor with your own UI. This example creates a simple textarea that supports markdown keyboard shortcuts and correct handling of newlines.

```jsx mdx:preview
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 (
    <textarea
      ref={textareaRef}
      value={value}
      onChange={(e) => setValue(e.target.value)}
      onKeyDown={onKeyDown}
      style={{ width: '100%', height: 200, padding: 10 }}
    />
  );
}

Special Markdown syntax

Supports for CSS Style

Use HTML comments `` to let Markdown support style customization.

## Title


Markdown Supports **Style**

Ignore content display via HTML comments

Shown in GitHub readme, excluded in HTML.

# Hello World

Hello World

Good!

Output:

<h1>Hello World</h1>



Good!


Security

Please note markdown needs to be sanitized if you do not completely trust your authors. Otherwise, your app is vulnerable to XSS. This can be achieved by adding rehype-sanitize as a plugin.

```jsx mdx:preview import React from "react"; import MDEditor from '@uiw/react-md-editor'; import rehypeSanitize from "rehype-sanitize";

export default function App() { const [value, setValue] = React.useState(**Hello world!!!** <IFRAME SRC=\"javascript:javascript:alert(window.origin);\"></IFRAME>); return (

  <MDEditor
    value={value}
    onChange={setValue}
    previewOptions={{
      rehypePlugins: [[rehypeSanitize]],

Extension points exported contracts — how you extend this code

CommandOrchestrator (Interface)
(no doc) [2 implementers]
core/commands.d.ts
CommandOrchestrator (Interface)
(no doc) [2 implementers]
core/src/commands/index.ts
ICommandChildHandle (Interface)
(no doc)
core/commands.d.ts
IProps (Interface)
(no doc)
core/src/Types.ts
ICommandChildCommands (Interface)
(no doc)
core/commands.d.ts
Statistics (Interface)
(no doc)
core/src/Types.ts
ICommandBase (Interface)
(no doc)
core/commands.d.ts
MDEditorProps (Interface)
(no doc)
core/src/Types.ts

Core symbols most depended-on inside this repo

setSelectionRange
called by 45
core/src/commands/index.ts
executeCommand
called by 18
core/src/utils/markdownUtils.ts
selectWord
called by 16
core/src/utils/markdownUtils.ts
insertTextAtPosition
called by 6
core/src/utils/InsertTextAtPosition.ts
replaceSelection
called by 6
core/src/commands/index.ts
headingExecute
called by 6
core/src/commands/title.tsx
selectLine
called by 5
core/src/utils/markdownUtils.ts
stopPropagation
called by 4
core/src/components/TextArea/handleKeyDown.tsx

Shape

Function 58
Interface 25
Class 8
Method 8

Languages

TypeScript100%

Modules by API surface

core/src/commands/index.ts20 symbols
core/commands.d.ts11 symbols
core/src/utils/markdownUtils.ts9 symbols
core/src/Editor.factory.tsx8 symbols
core/src/components/Toolbar/index.tsx6 symbols
core/src/components/DragBar/index.tsx5 symbols
www/src/Button.tsx4 symbols
www/src/Example.tsx3 symbols
core/src/components/TextArea/handleKeyDown.tsx3 symbols
core/src/components/TextArea/Textarea.tsx3 symbols
core/src/components/TextArea/Markdown.tsx3 symbols
core/src/components/TextArea/Markdown.common.tsx3 symbols

Dependencies from manifests, versioned

@babel/runtime7.14.6 · 1×
@kkt/less-modules7.4.9 · 1×
@kkt/ncc1.0.14 · 1×
@kkt/raw-modules7.4.9 · 1×
@kkt/scope-plugin-options7.4.9 · 1×
@types/katex0.16.0 · 1×
@types/node20 · 1×
@types/react18.2.0 · 1×
@types/react-dom18.2.0 · 1×
@types/react-test-renderer18.0.0 · 1×
@uiw/react-markdown-preview5.2.0 · 1×

For agents

$ claude mcp add react-md-editor \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact