Registry / web-framework / react-mde

react-mde

JSON →
library11.5.0jsnpmunverified

react-mde is a React component that provides a feature-rich Markdown editor, aiming for parity with the GitHub Markdown editor experience. It functions as a controlled component, requiring both a `value` prop for the Markdown content and an `onChange` handler for updates. A key differentiator is its extensibility; it allows developers to provide a custom `generateMarkdownPreview` function, making it agnostic to the chosen Markdown parsing library (e.g., Showdown or react-markdown). The component also supports custom icons and configurable toolbar commands. It relies on Draft.js for advanced text editing features like history management and mentions. The current stable version is 11.5.0, published approximately five years ago. Due to the lack of recent updates and noted unresolved issues, such as mobile compatibility tied to an unaddressed Draft.js problem, the project appears to be unmaintained.

npm install react-mde
INSTALL
IMPORT
SIG · REACT-MDE
R
react-mde
web-frameworkjavascriptv11.5.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ReactMde
import ReactMde from 'react-mde';
import { ReactMde } from 'react-mde'; import * as ReactMde from 'react-mde';
ReactMde is a default export.
CSS Styles
import 'react-mde/lib/styles/css/react-mde-all.css';
import 'react-mde/lib/styles/css/react-mde.css';
The `react-mde-all.css` file includes all necessary styles. Individual CSS files can be imported for granular control.
Showdown Converter (example)
import * as Showdown from 'showdown'; const converter = new Showdown.Converter({ tables: true, simplifiedAutoLink: true });
import Showdown from 'showdown';
Showdown is a popular choice for client-side Markdown parsing, often imported as a namespace.

Demonstrates a basic controlled `ReactMde` component, managing Markdown content and tab selection with React hooks and integrating Showdown for preview generation.

import React, { useState, useCallback } from 'react'; import ReactMde from 'react-mde'; import * as Showdown from 'showdown'; import 'react-mde/lib/styles/css/react-mde-all.css'; const converter = new Showdown.Converter({ tables: true, simplifiedAutoLink: true, strikethrough: true, tasklists: true, }); function MyMarkdownEditor() { const [value, setValue] = useState('**Hello world!!!**'); const [selectedTab, setSelectedTab] = useState<'write' | 'preview'>('write'); const generatePreview = useCallback((markdown) => { return Promise.resolve(converter.makeHtml(markdown)); }, []); return ( <div style={{ maxWidth: 800, margin: 'auto', padding: '20px' }}> <ReactMde value={value} onChange={setValue} selectedTab={selectedTab} onTabChange={setSelectedTab} generateMarkdownPreview={generatePreview} minEditorHeight={200} minPreviewHeight={200} /> </div> ); } export default MyMarkdownEditor;
Debug
Known issues
breakingThe project appears to be unmaintained. The latest version (11.5.0) was published approximately five years ago, indicating a lack of ongoing support, bug fixes, or compatibility updates for newer React versions or browser changes.
fix
Consider migrating to a more actively maintained Markdown editor component for long-term project health. If staying with react-mde, be prepared to fork and maintain it yourself or accept potential compatibility and security risks.
affects: >=11.5.0
gotchaReact-mde does not automatically sanitize the HTML output generated for the Markdown preview. Using client-side Markdown parsers like Showdown without explicit sanitization can expose your application to Cross-Site Scripting (XSS) vulnerabilities if user-supplied content contains malicious scripts.
fix
Always sanitize the HTML generated by your `generateMarkdownPreview` function, especially if dealing with untrusted user input. Integrate a dedicated HTML sanitization library (e.g., `dompurify`) or ensure your Markdown parser has built-in sanitization features enabled.
affects: >=1.0.0
gotchaMobile support for react-mde is noted as problematic and depends on fixes for Draft.js, which are not being actively addressed by Draft.js maintainers (Facebook). This means the editor may not function correctly or provide a good user experience on mobile devices.
fix
For mobile experiences, consider implementing a conditional rendering strategy to replace react-mde with a standard `<textarea>` or a mobile-specific input, or use an alternative editor that explicitly supports mobile. Test thoroughly on target mobile devices.
affects: >=1.0.0
gotchaStyling requires importing a CSS file. If `react-mde/lib/styles/css/react-mde-all.css` is not imported, the editor will appear unstyled and potentially non-functional visually.
fix
Ensure you include `import 'react-mde/lib/styles/css/react-mde-all.css';` in your entry file or component where `ReactMde` is used. For more granular control, individual CSS files can be imported, but `react-mde-all.css` is generally recommended for quick setup.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'react-mde' or its corresponding type declarations.
The `react-mde` package is not installed or incorrectly imported.
fix
Run `npm install react-mde showdown` (or `yarn add react-mde showdown`). Ensure the import path is `import ReactMde from 'react-mde';`.
TypeError: Cannot read properties of undefined (reading 'makeHtml') or similar error related to markdown conversion.
The `generateMarkdownPreview` prop is either missing, returns an invalid value, or the Markdown converter (e.g., Showdown) is not correctly initialized or installed.
fix
Ensure `showdown` is installed (`npm install showdown`) and correctly imported. The `generateMarkdownPreview` function must return a `Promise<string | ReactElement>`. Example: `generateMarkdownPreview={markdown => Promise.resolve(converter.makeHtml(markdown))}`.
Error: A component is changing an uncontrolled input of type text to be controlled.
The `ReactMde` component is being used with a `value` prop that changes from `undefined` to a defined string, or vice-versa, without a corresponding `key` prop to force re-mounting.
fix
Always initialize the `value` prop with a non-null/non-undefined string, typically an empty string (`''`) or initial Markdown content. Ensure `value` and `onChange` are consistently provided for controlled component behavior.
Upgrade
Version history
11.5.0latest on npm
Audit
Dependencies
reactrequiredPeer dependency for rendering React components.
react-domrequiredPeer dependency for rendering React components to the DOM.
draft-jsrequiredCore dependency for rich text editing features like history management and mentions.
showdownoptionalCommonly used optional dependency for client-side Markdown to HTML conversion in the preview pane.
Agent activity
4 hits · last 30 days
node
4
Resources