Coder Social home page Coder Social logo

wenj91 / react-markdown-editor Goto Github PK

View Code? Open in Web Editor NEW

This project forked from uiwjs/react-markdown-editor

0.0 2.0 0.0 6.74 MB

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

Home Page: https://uiwjs.github.io/react-markdown-editor/

License: MIT License

TypeScript 81.77% CSS 17.47% HTML 0.76%

react-markdown-editor's Introduction

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

react-markdown-editor's People

Contributors

jaywcjlove avatar renovate-bot avatar dependabot[bot] avatar renovate[bot] avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.