All Projects → RIP21 → React Simplemde Editor

RIP21 / React Simplemde Editor

Licence: mit
React wrapper for simplemde markdown editor

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to React Simplemde Editor

Pine
A modern, native macOS markdown editor
Stars: ✭ 2,818 (+508.64%)
Mutual labels:  markdown, editor
Mua
An open source markdown editor for Android.
Stars: ✭ 318 (-31.32%)
Mutual labels:  markdown, editor
Mak
A universal notepad. (WIP)
Stars: ✭ 270 (-41.68%)
Mutual labels:  markdown, editor
Tui.editor
🍞📝 Markdown WYSIWYG Editor. GFM Standard + Chart & UML Extensible.
Stars: ✭ 14,016 (+2927.21%)
Mutual labels:  markdown, editor
Marktext
📝A simple and elegant markdown editor, available for Linux, macOS and Windows.
Stars: ✭ 22,894 (+4844.71%)
Mutual labels:  markdown, editor
Cattaz
Realtime collaborative tool which can run custom applications in a Wiki page
Stars: ✭ 191 (-58.75%)
Mutual labels:  markdown, editor
Phodit
Phodal's markdown/ebook editor with MicroFrontend & Web Components
Stars: ✭ 301 (-34.99%)
Mutual labels:  markdown, editor
Rich Markdown Editor
The open source React and Prosemirror based markdown editor that powers Outline. Want to try it out? Create an account:
Stars: ✭ 2,468 (+433.05%)
Mutual labels:  markdown, editor
React Md Editor
A simple markdown editor with preview, implemented with React.js and TypeScript.
Stars: ✭ 374 (-19.22%)
Mutual labels:  markdown, editor
For Editor
for-editor - A markdown editor based on React
Stars: ✭ 358 (-22.68%)
Mutual labels:  markdown, editor
Vue Markdown Editor
A markdown editor built on Vue
Stars: ✭ 169 (-63.5%)
Mutual labels:  markdown, editor
Markdowneditor
Lightweight markdown editor written for windows,only one GREEN exe file
Stars: ✭ 403 (-12.96%)
Mutual labels:  markdown, editor
Python Markdown Editor
Standalone editor for your markdown files
Stars: ✭ 164 (-64.58%)
Mutual labels:  markdown, editor
Vditor
♏ 一款浏览器端的 Markdown 编辑器,支持所见即所得(富文本)、即时渲染(类似 Typora)和分屏预览模式。An In-browser Markdown editor, support WYSIWYG (Rich Text), Instant Rendering (Typora-like) and Split View modes.
Stars: ✭ 3,773 (+714.9%)
Mutual labels:  markdown, editor
Pervane
Plain text file based note taking and knowledge base building tool, markdown editor, simple browser IDE.
Stars: ✭ 159 (-65.66%)
Mutual labels:  markdown, editor
Text
📑 Collaborative document editing using Markdown
Stars: ✭ 282 (-39.09%)
Mutual labels:  markdown, editor
Vditor
♏ 一款浏览器端的 Markdown 编辑器。
Stars: ✭ 1,742 (+276.24%)
Mutual labels:  markdown, editor
Mpeditor
微信markdown编辑器
Stars: ✭ 146 (-68.47%)
Mutual labels:  markdown, editor
Stackedit
In-browser Markdown editor
Stars: ✭ 18,744 (+3948.38%)
Mutual labels:  markdown, editor
Editormd
Markdown 编辑器 Editor.md for Typecho
Stars: ✭ 389 (-15.98%)
Mutual labels:  markdown, editor

React SimpleMDE (EasyMDE) Markdown Editor

NPM version

React component wrapper for EasyMDE (the most fresh SimpleMDE fork).

Only two dependencies, React (peer) and EasyMDE (explicit).

New in v4

  • Now uses EasyMDE (the most fresh SimpleMDE fork) instead of simplemde itself. Possible breaking changes, so I bumped version to v4.
  • One obvious breaking change. Is how CSS is have to be imported. It used to be simplemde/dist/simplemde.min.css now it will be easymde/dist/easymde.min.css

New in v3

  • The initialValue prop has been removed and replaced with a value prop, allowing direct changes to the value to be made after the component mounts.
  • v3.6.8 if rendering server-side, you can set static ids to avoid errors in rendering synchronization.
  • v3.6.17 TypeScript typings added.
  • v3.6.19 All props will be passed to the wrapper now (except a id, onChange and few others that are ignored)
  • v3.6.21 React 17 support (UNSAFE methods are no longer used)

New in v2

Version 1.0 did not have SimpleMDE options configured well, this readme reflects the changes made to better include options. This is still a very new project. Testing, feedback and PRs are welcome and appreciated.

Install

npm install --save react-simplemde-editor

Demo

https://react-simplemde-edtior.netlify.com/

or view it locally:

git clone https://github.com/RIP21/react-simplemde-editor.git
cd react-simplemde-editor
yarn install
yarn demo
open browser with localhost:3000

Usage

View the demo code for a full example.

Not required, but useless without it, the onChange callback is the only option you need to set.

import React from "react";
import SimpleMDE from "react-simplemde-editor";
import "easymde/dist/easymde.min.css";

<SimpleMDE onChange={this.handleChange} />;

The data from SimpleMDE is passed to the handleChange function and you do not need to reference the event.

handleChange = value => {
  this.setState({ mdeValue: value });
};

Options

Set additional SimpleMDE options with an options prop.

Note - while SimpleMDE options has an initialValue option, this component only takes a value prop which is set as the initialValue on first render.

Note - if you don't specify a custom id it will automatically generate an id for you.

import React from "react";
import SimpleMDE from "react-simplemde-editor";
import "easymde/dist/easymde.min.css";

<SimpleMDE
  id="your-custom-id"
  label="Your label"
  onChange={this.handleChange}
  value={this.state.textValue}
  options={{
    autofocus: true,
    spellChecker: false
    // etc.
  }}
/>;

You can include key maps using the extraKeys prop. Read more at https://codemirror.net/doc/manual.html#option_extraKeys

extraKeys = {
  Up: function(cm) {
    cm.replaceSelection(" surprise. ");
  },
  Down: function(cm) {
    cm.replaceSelection(" surprise again! ");
  }
};

<SimpleMDE
  value={this.state.textValue}
  onChange={this.handleChange}
  extraKeys={extraKeys}
/>;

Custom preview rendering example

import ReactDOMServer from "react-dom/server";

<SimpleMDE
  value={this.state.text}
  onChange={this.setText}
  options={{
    previewRender(text) {
      return ReactDOMServer.renderToString(
        <ReactMarkdown
          source={text}
          renderers={{
            CodeBlock: CodeRenderer,
            Code: CodeRenderer
          }}
        />
      );
    }
  }}
/>;

Additional listeners for events of CodeMirror

See full list of events: https://codemirror.net/doc/manual.html#events

<SimpleMDE
  value={this.state.text}
  onChange={this.handleChange}
  events={{
    'blur': (e) => {},
    'focus': (e) => {},
    //... Add any codeMirror events
  }}
/>

Autosaving example

import React, { Component } from "react";
import SimpleMDEReact from "react-simplemde-editor";

class Autosaving extends Component {
  defaultProps = {
    delay: 1000,
    value: ""
  };

  state = {
    value: localStorage.getItem(`smde_${this.props.id}`) || this.props.value
  };

  render() {
    const { options, delay, id, ...rest } = this.props;
    return (
      <SimpleMDEReact
        {...rest}
        id={id}
        value={this.state.value}
        options={{
          autosave: {
            enabled: true,
            uniqueId: id,
            delay
          },
          ...options
        }}
      />
    );
  }
}

Retrieve simplemde instance to be able to manipulate it.

<SimpleMDE
  getMdeInstance= { this.getInstance } // <-- set callback prop
  value={this.state.text}
  onChange={this.handleChange}
  }
/>
getInstance = instance => {
  // You can now store and manipulate the simplemde instance.
  instance.togglePreview();
};
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].