React Markdown Editor Component

11.5.0 · abandoned · verified Sun Apr 19

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.

Common errors

Warnings

Install

Imports

Quickstart

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;

view raw JSON →