Score
0
Watch 4 Star 35 Fork 7

uiw / react-markdown-editorTypeScript

Join us
Explore and code with more than 2 million developers,Free private repositories !:)
Sign up
基于React的Markdown 编辑器组件。 spread retract

http://uiw.gitee.io/react-markdown-editor/

Clone or download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README.md

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

Install

npm i @uiw/react-markdown-editor

Document

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

Basic Usage

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

const Dome = () => (
  <MarkdownEditor
    value={this.state.markdown}
    onChange={this.updateMarkdown}
  />
);

controlled usage

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


class App extends React.Component {
  constructor() {
    super();
    this.state = {
      markdown: '# This is a H1  \n## This is a H2  \n###### This is a H6',
    };
    this.updateMarkdown = this.updateMarkdown.bind(this);
  }

  updateMarkdown(editor, data, value) {
    this.setState({ markdown: value });
  }

  render() {
    return (
      <MarkdownEditor
        value={this.state.markdown}
        onChange={this.updateMarkdown}
      />
    );
  }
}

ReactDOM.render(
  <App />,
  document.getElementById('app')
);

Props

  • value (string) - the raw markdown that will be converted to html (required)
  • visble?:boolean - Shows a preview that will be converted to html.
  • toolbars?:array - Tool display settings.
  • toolbarsMode?:array - Tool display settings.
  • onChange (function(editor: IInstance, data: CodeMirror.EditorChange, value: string)) - called when a change is made (required)
  • previewProps - react-markdown options

Other Props Options

Development

npm run dev
npm run type-check:watch
npm run doc

License

MIT © Kenny Wong

Comments ( 0 )

Sign in for post a comment

TypeScript
1
https://gitee.com/uiw/react-markdown-editor.git
git@gitee.com:uiw/react-markdown-editor.git
uiw
react-markdown-editor
react-markdown-editor
master

Help Search