1- react-markdown-editor-lite
2- ========
1+ # react-markdown-editor-lite
32
43[ ![ NPM package] [ npm-version-image ]] [ npm-url ]
54[ ![ NPM downloads] [ npm-downloads-image ]] [ npm-url ]
@@ -8,24 +7,25 @@ react-markdown-editor-lite
87
98[ 中文说明] ( README_CN.md )
109
11- * A light-weight(20KB zipped) Markdown editor of React component
12- * Supports TypeScript
13- * Supports custom markdown parser
14- * Full markdown support
15- * Supports pluggable function bars
16- * Full control over UI
17- * Supports image uploading and dragging
18- * Supports synced scrolling between editor and preview
19- * 一款轻量的基于React的Markdown编辑器, 压缩后代码只有20KB
20- * 支持TypeScript
21- * 支持自定义Markdown解析器
22- * 支持常用的Markdown编辑功能 ,如加粗,斜体等等...
23- * 支持插件化的功能键
24- * 界面可配置, 如只显示编辑区或预览区
25- * 支持图片上传或拖拽
26- * 支持编辑区和预览区同步滚动
10+ - A light-weight(20KB zipped) Markdown editor of React component
11+ - Supports TypeScript
12+ - Supports custom markdown parser
13+ - Full markdown support
14+ - Supports pluggable function bars
15+ - Full control over UI
16+ - Supports image uploading and dragging
17+ - Supports synced scrolling between editor and preview
18+ - 一款轻量的基于 React 的 Markdown 编辑器, 压缩后代码只有 20KB
19+ - 支持 TypeScript
20+ - 支持自定义 Markdown 解析器
21+ - 支持常用的 Markdown 编辑功能 ,如加粗,斜体等等...
22+ - 支持插件化的功能键
23+ - 界面可配置, 如只显示编辑区或预览区
24+ - 支持图片上传或拖拽
25+ - 支持编辑区和预览区同步滚动
2726
2827## Demo
28+
2929Online demo <br >[ https://harrychen0506.github.io/react-markdown-editor-lite/ ] ( https://harrychen0506.github.io/react-markdown-editor-lite/ )
3030
3131Default configuration
@@ -36,7 +36,6 @@ Pluggable bars
3636
3737![ image] ( https://github.com//HarryChen0506/react-markdown-editor-lite/blob/master/image/react-markdown-editor-lite-v1.0.0-plugins.PNG?raw=true )
3838
39-
4039## Install
4140
4241``` shell
@@ -46,18 +45,20 @@ yarn add react-markdown-editor-lite
4645```
4746
4847## Basic usage
48+
4949Following steps:
50- * Import react-markdown-editor-lite
51- * Register plugins if required
52- * Initialize a markdown parser, such as markdown-it
53- * Start usage
50+
51+ - Import react-markdown-editor-lite
52+ - Register plugins if required
53+ - Initialize a markdown parser, such as markdown-it
54+ - Start usage
5455
5556``` js
5657// import react, react-markdown-editor-lite, and a markdown parser you like
57- import * as React from ' react'
58- import * as ReactDOM from ' react-dom'
59- import MarkdownIt from ' markdown-it'
60- import MdEditor from ' react-markdown-editor-lite'
58+ import React from ' react' ;
59+ import * as ReactDOM from ' react-dom' ;
60+ import MarkdownIt from ' markdown-it' ;
61+ import MdEditor from ' react-markdown-editor-lite' ;
6162// import style manually
6263import ' react-markdown-editor-lite/lib/index.css' ;
6364
@@ -68,24 +69,20 @@ import 'react-markdown-editor-lite/lib/index.css';
6869const mdParser = new MarkdownIt (/* Markdown-it options */ );
6970
7071// Finish!
71- function handleEditorChange ({html, text}) {
72- console .log (' handleEditorChange' , html, text)
72+ function handleEditorChange ({ html, text }) {
73+ console .log (' handleEditorChange' , html, text);
7374}
74- export default ( props ) => {
75+ export default props => {
7576 return (
76- < MdEditor
77- style= {{ height: " 500px" }}
78- renderHTML= {(text ) => mdParser .render (text)}
79- onChange= {handleEditorChange}
80- / >
81- )
82- }
77+ < MdEditor style= {{ height: ' 500px' }} renderHTML= {text => mdParser .render (text)} onChange= {handleEditorChange} / >
78+ );
79+ };
8380```
8481
85- * Props and configurations see [ here] ( ./docs/configure.md )
86- * APIs see [ here] ( ./docs/api.md )
87- * Plugins developer see [ here] ( ./docs/plugin.md )
88- * Full demo see [ src/demo/index.tsx] ( https://github.com/HarryChen0506/react-markdown-editor-lite/blob/master/src/demo/index.tsx )
82+ - Props and configurations see [ here] ( ./docs/configure.md )
83+ - APIs see [ here] ( ./docs/api.md )
84+ - Plugins developer see [ here] ( ./docs/plugin.md )
85+ - Full demo see [ src/demo/index.tsx] ( https://github.com/HarryChen0506/react-markdown-editor-lite/blob/master/src/demo/index.tsx )
8986
9087## Usage in server-side render
9188
@@ -100,29 +97,55 @@ import dynamic from 'next/dynamic';
10097import ' react-markdown-editor-lite/lib/index.css' ;
10198
10299const MdEditor = dynamic (() => import (' react-markdown-editor-lite' ), {
103- ssr: false
100+ ssr: false ,
104101});
105102
106103export default function () {
107- return (
108- < MdEditor
109- style= {{ height: " 500px" }}
110- renderHTML= {/* Render function */ }
111- / >
112- )
104+ return < MdEditor style= {{ height: ' 500px' }} renderHTML= {/* Render function */ } / > ;
105+ }
106+ ```
107+
108+ With plugins:
109+
110+ ``` js
111+ import dynamic from ' next/dynamic' ;
112+ import ' react-markdown-editor-lite/lib/index.css' ;
113+
114+ const MdEditor = dynamic (
115+ () => {
116+ return new Promise (resolve => {
117+ Promise .all ([
118+ import (' react-markdown-editor-lite' ),
119+ import (' ./my-plugin' ),
120+ /** Add more plugins, and use below */
121+ ]).then (res => {
122+ res[0 ].default .use (res[1 ].default );
123+ resolve (res[0 ].default );
124+ });
125+ });
126+ },
127+ {
128+ ssr: false ,
129+ },
130+ );
131+
132+ export default function () {
133+ return < MdEditor style= {{ height: ' 500px' }} renderHTML= {/* Render function */ } / > ;
113134}
114135```
115136
116137Full example see [ here] ( https://codesandbox.io/s/next-js-80bne )
117138
118139## Import in Browser
119- Since 1.1.0, You can add ` script ` and ` link ` tags in your browser and use the global variable ` ReactMarkdownEditorLite ` .
140+
141+ Since 1.1.0, You can add ` script ` and ` link ` tags in your browser and use the global variable ` ReactMarkdownEditorLite ` .
120142
121143You can download these files directly from [ ![ cdnjs] [ cdnjs-image ]] [ cdnjs-url ] [ ![ jsdelivr] [ jsdelivr-image ]] [ jsdelivr-url ] [ ![ unpkg] [ unpkg-image ]] [ unpkg-url ]
122144
123145Note: you should import react before ` ReactMarkdownEditorLite ` .
124146
125147For example, in webpack, you import ReactMarkdownEditorLite by ` script ` tag in your page, and write webpack config like this:
148+
126149``` js
127150externals: {
128151 react: ' React' ,
@@ -138,22 +161,24 @@ externals: {
138161* [ In Next.js] ( https://codesandbox.io/s/next-js-80bne )
139162
140163## Authors
164+
141165- ShuangYa [ github/sylingd] ( https://github.com/sylingd )
142166- HarryChen0506 [ github/HarryChen0506] ( https://github.com/HarryChen0506 )
143167
144168## License
169+
145170[ MIT] ( LICENSE )
146171
147172[ npm-version-image ] : https://img.shields.io/npm/v/react-markdown-editor-lite.svg
148- [ npm-downloads-image ] : http ://img.shields.io/npm/dm/react-markdown-editor-lite.svg?style=flat
173+ [ npm-downloads-image ] : https ://img.shields.io/npm/dm/react-markdown-editor-lite.svg?style=flat
149174[ npm-url ] : https://www.npmjs.com/package/react-markdown-editor-lite
150175[ workflow-image ] : https://img.shields.io/github/workflow/status/HarryChen0506/react-markdown-editor-lite/main
151176[ workflow-url ] : https://github.com/HarryChen0506/react-markdown-editor-lite/actions?query=workflow%3Amain
152- [ license-image ] : http ://img.shields.io/badge/license-MIT-blue.svg?style=flat
177+ [ license-image ] : https ://img.shields.io/badge/license-MIT-blue.svg?style=flat
153178[ license-url ] : LICENSE
154179[ jsdelivr-image ] : https://img.shields.io/jsdelivr/npm/hm/react-markdown-editor-lite
155180[ jsdelivr-url ] : https://www.jsdelivr.com/package/npm/react-markdown-editor-lite?path=lib
156181[ cdnjs-image ] : https://img.shields.io/cdnjs/v/react-markdown-editor-lite?style=flat
157182[ cdnjs-url ] : https://cdnjs.com/libraries/react-markdown-editor-lite
158183[ unpkg-image ] : https://img.shields.io/npm/v/react-markdown-editor-lite?label=unpkg&style=flat
159- [ unpkg-url ] : https://unpkg.com/browse/react-markdown-editor-lite/lib/
184+ [ unpkg-url ] : https://unpkg.com/browse/react-markdown-editor-lite/lib/
0 commit comments