百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
R

react-markdown-editor

> 前端框架
开源

一个带有预览的平分编辑器,由React.js和TypeScript执行.

378 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

一个带有预览的平分编辑器,由React.js和TypeScript执行.

A markdown editor with preview, implemented with React.js and TypeScript.

Migrate from @uiw/react-markdown-editor 4.x to 5.x.

Install

bash
npm i @uiw/react-markdown-editor

Document

Official document demo preview (中国镜像网站)

Basic Usage

javascript
import React from 'react';
import MarkdownEditor from '@uiw/react-markdown-editor';

const mdStr = `# This is a H1  \n## This is a H2  \n###### This is a H6`;

const Dome = () => {
  return (
     {

      }}
    />
  )
};

export default Dome;

Controlled Usage

javascript
import React, { useState } from 'react';
import MarkdownEditor from '@uiw/react-markdown-editor';

const mdStr = `# This is a H1  \n## This is a H2  \n###### This is a H6`;
export default function App() {
  const [markdown, setMarkdown] = useState(mdStr);
  return (
     setMarkdown(value)}
    />
  );
}

Only Markdown Preview

This markdown preview sub-component is a direct export @uiw/react-markdown-preview component, API documentation, please check @uiw/react-markdown-preview.

javascript
import React from 'react';
import MarkdownEditor from '@uiw/react-markdown-editor';

const mdStr = `# This is a H1  \n## This is a H2  \n###### This is a H6`;
function App() {
  return (
    
  );
}

export default App;

Custom Toolbars

…

Disable preview feature

javascript
import React from "react";
import MarkdownEditor from '@uiw/react-markdown-editor';

const Dome = () => (
  
);

export default Dome;

Support Nextjs

Use examples in nextjs.

bash
npm install next-remove-imports
npm install @uiw/react-markdown-editor
javascript
// next.config.js
const removeImports = require('next-remove-imports')();
module.exports = removeImports({});
javascript
import dynamic from 'next/dynamic';
import '@uiw/react-markdown-editor/markdown-editor.css';
import '@uiw/react-markdown-preview/markdown.css';

const MarkdownEditor = dynamic(
  () => import("@uiw/react-markdown-editor").then((mod) => mod.default),
  { ssr: false }
);

function HomePage() {
  return (
    

  );
}

export default HomePage;

Support dark-mode/night-mode

By default, the dark-mode is automatically switched according to the system. If you need to switch manually, just set the data-color-mode="dark" parameter for html Element.

xml
javascript
document.documentElement.setAttribute('data-color-mode', 'dark')
document.documentElement.setAttribute('data-color-mode', 'light')

Inherit custom color variables by adding .wmde-markdown-var selector.

javascript
const Demo = () => {
  return (
    

      
    
  )
}

Props

  • value (string) - the raw markdown that will be converted to html (required)
  • visible?: boolean - Shows a preview that will be converted to html.
  • toolbars?: ICommand[] | string[] - Tool display settings.
  • toolbarsMode?: ICommand[] | string[] - Tool display settings.
  • onChange?:function(editor: IInstance, data: CodeMirror.EditorChange, value: string) - called when a change is made
  • onBlur?: function(editor: IInstance, event: Event) - event occurs when an object loses focus
  • onPreviewMode?: (isHide: boolean) => void - Edit mode and preview mode switching event
  • previewProps - react-markdown options
…
…
…

Development

bash
npm run watch # Listen create type and .tsx files.
npm run start # Preview code example.

npm run doc

Related

  • @uiw/react-textarea-code-editor: A simple code editor with syntax highlighting.
  • @uiw/react-codemirror: CodeMirror component for React. @codemirror
  • @uiw/react-monacoeditor: Monaco Editor component for React.
  • @uiw/react-md-editor: A simple markdown editor with preview, implemented with React.js and TypeScript.
  • @uiw/react-markdown-preview: React component preview markdown text in web browser.

Contributors

As always, thanks to our amazing contributors!

Made with action-contributors.

License

Licensed under the MIT License.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScriptcodemirrorcodemirror-editoreditorhighlight

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类前端框架
定价开源

> 相关工具

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架