Skip to content

Commit 0ba874e

Browse files
authored
Merge pull request #222 from HarryChen0506/dev
Release 1.3.0
2 parents d595547 + 4fe5b75 commit 0ba874e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+8684
-3444
lines changed

.eslintrc

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,57 @@
11
{
2-
"parser": "babel-eslint",
3-
"extends": "airbnb",
2+
"extends": ["airbnb-typescript"],
43
"env": {
54
"browser": true,
65
"jest": true
76
},
87
"rules": {
98
"jsx-a11y/href-no-hash": [0],
109
"jsx-a11y/click-events-have-key-events": [0],
11-
"jsx-a11y/anchor-is-valid": [ "error", {
12-
"components": [ "Link" ],
13-
"specialLink": [ "to" ]
14-
}],
10+
"jsx-a11y/anchor-is-valid": [
11+
"error",
12+
{
13+
"components": ["Link"],
14+
"specialLink": ["to"]
15+
}
16+
],
17+
"jsx-a11y/no-noninteractive-element-interactions": "off",
18+
"jsx-a11y/mouse-events-have-key-events": "off",
1519
"jsx-a11y/no-static-element-interactions": [0],
20+
"jsx-a11y/no-autofocus": "off",
21+
"react/sort-comp": "off",
22+
"react/no-array-index-key": "off",
23+
"react/no-did-update-set-state": "off",
24+
"react/no-access-state-in-setstate": "off",
1625
"react/react-in-jsx-scope": [0],
1726
"react/forbid-prop-types": [0],
18-
"react/jsx-filename-extension": [1, { "extensions": [".js"] }],
27+
"react/require-default-props": [0],
28+
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx", ".ts", ".tsx"] }],
29+
"react/destructuring-assignment": [0],
1930
"import/extensions": [0],
2031
"import/no-unresolved": [0],
2132
"arrow-body-style": ["error", "as-needed", { "requireReturnForObjectLiteral": true }],
2233
"arrow-parens": ["error", "always"],
23-
"space-before-function-paren": ["error", {"anonymous": "always", "named": "never", "asyncArrow": "always"}],
34+
"space-before-function-paren": ["error", { "anonymous": "always", "named": "never", "asyncArrow": "always" }],
2435
"object-curly-newline": ["error", { "consistent": true }],
2536
"function-paren-newline": ["error", "consistent"],
26-
"class-methods-use-this": [0]
37+
"class-methods-use-this": [0],
38+
"no-use-before-define": "off",
39+
"@typescript-eslint/no-use-before-define": ["error"],
40+
"@typescript-eslint/no-explicit-any": "off",
41+
"@typescript-eslint/explicit-module-boundary-types": "off",
42+
"@typescript-eslint/naming-convention": "off",
43+
"@typescript-eslint/no-unused-vars": "off",
44+
"max-len": ["error", { "code": 200 }],
45+
"no-alert": "off",
46+
"max-classes-per-file": "off",
47+
"no-plusplus": "off",
48+
"no-restricted-syntax": "off",
49+
"no-console": "off",
50+
"default-case": "off",
51+
"consistent-return": "off",
52+
"no-return-assign": "off"
2753
},
2854
"parserOptions": {
29-
"ecmaFeatures": {
30-
"experimentalObjectRestSpread": true
31-
}
55+
"project": "./tsconfig.json"
3256
}
3357
}

.github/workflows/main.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,16 @@ jobs:
4747
- name: Coverage
4848
run: yarn run coverage
4949
- name: Upload bundles
50-
uses: actions/upload-artifact@v1
50+
uses: actions/upload-artifact@v2
5151
with:
5252
name: lib
53-
path: lib
53+
path: |
54+
esm
55+
cjs
56+
lib
57+
preview
5458
- name: Upload coverage
55-
uses: actions/upload-artifact@v1
59+
uses: actions/upload-artifact@v2
5660
with:
5761
name: coverage
5862
path: coverage

.gitignore

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ node_modules/
1919
.npm
2020

2121
# dist
22-
lib/
23-
lib/*
24-
dist/
25-
dist/*
22+
esm
23+
cjs
24+
lib
25+
dist
26+
preview
2627

2728
# Logs and databases #
2829
######################

.prettierrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"semi": true,
33
"singleQuote": true,
4-
"printWidth": 120,
4+
"printWidth": 200,
55
"trailingComma": "all"
66
}

README.md

Lines changed: 77 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
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+
2929
Online demo <br>[https://harrychen0506.github.io/react-markdown-editor-lite/](https://harrychen0506.github.io/react-markdown-editor-lite/)
3030

3131
Default 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+
4949
Following 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
6263
import 'react-markdown-editor-lite/lib/index.css';
6364

@@ -68,24 +69,20 @@ import 'react-markdown-editor-lite/lib/index.css';
6869
const 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';
10097
import 'react-markdown-editor-lite/lib/index.css';
10198

10299
const MdEditor = dynamic(() => import('react-markdown-editor-lite'), {
103-
ssr: false
100+
ssr: false,
104101
});
105102

106103
export 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

116137
Full 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

121143
You can download these files directly from [![cdnjs][cdnjs-image]][cdnjs-url] [![jsdelivr][jsdelivr-image]][jsdelivr-url] [![unpkg][unpkg-image]][unpkg-url]
122144

123145
Note: you should import react before `ReactMarkdownEditorLite`.
124146

125147
For example, in webpack, you import ReactMarkdownEditorLite by `script` tag in your page, and write webpack config like this:
148+
126149
```js
127150
externals: {
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

Comments
 (0)