Giter Site home page Giter Site logo

fjallen / react-markdown-editor-lite Goto Github PK

View Code? Open in Web Editor NEW

This project forked from harrychen0506/react-markdown-editor-lite

0.0 1.0 0.0 2.61 MB

a light-weight Markdown editor based on React. 一款轻量的基于React的markdown编辑器

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

License: MIT License

JavaScript 3.98% HTML 0.36% CSS 9.80% TypeScript 85.85%

react-markdown-editor-lite's Introduction

react-markdown-editor-lite

NPM package NPM downloads MIT License

中文文档

  • A light-weight(20KB zipped) Markdown editor of React component
  • Supports TypeScript
  • Supports custom markdown parser
  • Full markdown support
  • Supports pluggable function bars
  • Full control over UI
  • Supports image uploading and dragging
  • Supports synced scrolling between editor and preview
  • 一款轻量的基于React的Markdown编辑器, 压缩后代码只有20KB
  • 支持TypeScript
  • 支持自定义Markdown解析器
  • 支持常用的Markdown编辑功能,如加粗,斜体等等...
  • 支持插件化的功能键
  • 界面可配置, 如只显示编辑区或预览区
  • 支持图片上传或拖拽
  • 支持编辑区和预览区同步滚动

Demo

Online demo
https://harrychen0506.github.io/react-markdown-editor-lite/

Default configuration

image

Pluggable bars

image

Install

npm install react-markdown-editor-lite --save
# or
yarn add react-markdown-editor-lite

Basic usage

Following steps:

  • Import react-markdown-editor-lite
  • Register plugins if required
  • Initialize a markdown parser, such as markdown-it
  • Start usage
// import react, react-markdown-editor-lite, and a markdown parser you like
import * as React from 'react'
import * as ReactDOM from 'react-dom'
import MarkdownIt from 'markdown-it'
import MdEditor from 'react-markdown-editor-lite'
// import style manually
import 'react-markdown-editor-lite/lib/index.css';

// Register plugins if required
// MdEditor.use(YOUR_PLUGINS_HERE);

// Initialize a markdown parser
const mdParser = new MarkdownIt(/* Markdown-it options */);

// Finish!
function handleEditorChange({html, text}) {    
  console.log('handleEditorChange', html, text)
}
export default (props) => {
  return (
    <MdEditor
      value=""
      renderHTML={(text) => mdParser.render(text)}
      onChange={handleEditorChange}
      />
  )
}

Usage in Next.js

import dynamic from 'next/dynamic'
import 'react-markdown-editor-lite/lib/index.css';

const MdEditor = dynamic(() => import('react-markdown-editor-lite'), {
  ssr: false
});

export default function() {
  return (      
    <div style="height: 500px">
      <MdEditor
        value=""
        renderHTML={/* Render function */}
      />                
    </div>
  )
}

More

Authors

License

MIT

react-markdown-editor-lite's People

Contributors

sylingd avatar harrychen0506 avatar dcalvom avatar blunderchips avatar dalperin avatar dependabot[bot] avatar demozlx avatar aitayn avatar jonatanklosko avatar rdvojmoc avatar

Watchers

James Cloos 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.