Skip to content

Commit 2c49bcd

Browse files
authored
improve build (#91)
* improve build * minify umd format * fix exports declaration
1 parent 3ac2fe5 commit 2c49bcd

Some content is hidden

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

41 files changed

+6326
-1190
lines changed

.babelrc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"@babel/preset-env"
55
],
66
"plugins": [
7-
"@babel/plugin-proposal-object-rest-spread",
8-
"@babel/plugin-proposal-class-properties"
7+
"@babel/plugin-transform-runtime"
98
]
109
}

.eslintrc.json

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "eslint:recommended",
2+
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
33
"env": {
44
"es6": true,
55
"browser": true,
@@ -17,40 +17,28 @@
1717
"settings": {
1818
"react": { "version": "detect" }
1919
},
20-
"plugins": [
21-
"react"
22-
],
20+
"plugins": ["react"],
2321
"rules": {
2422
"eqeqeq": 2,
2523
"no-const-assign": 2,
2624
"prefer-const": 2,
27-
"semi": [2, "always"],
28-
2925
"array-bracket-spacing": [1, "never"],
30-
"arrow-spacing": 1,
31-
"brace-style": [1, "1tbs", {"allowSingleLine": true}],
32-
"comma-style": [1, "last"],
33-
"indent": [1, 2],
34-
"keyword-spacing": 1,
35-
"linebreak-style": [1, "unix"],
3626
"no-console": 1,
3727
"no-unused-vars": 1,
3828
"no-trailing-spaces": 1,
39-
"object-curly-spacing": [1, "always", {"objectsInObjects": false, "arraysInObjects": false}],
4029
"padded-blocks": [1, "never"],
41-
"space-before-blocks": 1,
42-
"space-in-parens": 1,
43-
"space-infix-ops": 1,
44-
4530
"react/jsx-uses-react": 2,
4631
"react/jsx-uses-vars": 2,
4732
"react/jsx-no-undef": 2,
4833
"react/no-did-mount-set-state": 2,
4934
"react/no-did-update-set-state": 2,
5035
"react/no-direct-mutation-state": 2,
5136
"react/no-unknown-property": 2,
52-
"react/sort-comp": [1, {
53-
"order": ["static-methods", "lifecycle", "render", "everything-else"]
54-
}]
37+
"react/sort-comp": [
38+
1,
39+
{
40+
"order": ["static-methods", "lifecycle", "render", "everything-else"]
41+
}
42+
]
5543
}
5644
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ npm-debug.log
22
node_modules/
33
.DS_Store
44
dist/
5+
demo-dist/

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
demo/
22
src/
33
test/
4+
demo-dist/

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist/
2+
node_modules/

.prettierrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"singleQuote": true
3+
}

demo/ClickCounterAtom.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { classToDOMAtom } from '../src';
2+
import { classToDOMAtom } from 'react-mobiledoc-editor';
33

44
/**
55
* Component-based atoms are rendered with these props:
@@ -19,21 +19,19 @@ class Counter extends React.Component {
1919
const { payload, save, value } = this.props;
2020
const clicks = (payload.clicks || 0) + 1;
2121
save(value, { ...payload, clicks }); // updates payload.clicks, rerenders button
22-
}
22+
};
2323

2424
render() {
2525
const { payload } = this.props;
2626

2727
return (
28-
<button onClick={this.handleClick}>
29-
Clicks: {payload.clicks || 0}
30-
</button>
28+
<button onClick={this.handleClick}>Clicks: {payload.clicks || 0}</button>
3129
);
3230
}
3331
}
3432

35-
Counter.displayName = 'Counter'
33+
Counter.displayName = 'Counter';
3634

3735
const ClickCounterAtom = classToDOMAtom(Counter);
3836

39-
export default ClickCounterAtom;
37+
export default ClickCounterAtom;

demo/ImageCard.js

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { classToDOMCard } from '../src';
2+
import { classToDOMCard } from 'react-mobiledoc-editor';
33

44
/**
55
* Component-based cards are rendered with these props:
@@ -27,21 +27,39 @@ import { classToDOMCard } from '../src';
2727
class ImageCard extends React.Component {
2828
render() {
2929
const { isInEditor, payload, save, edit, isEditing } = this.props;
30-
30+
3131
if (isEditing) {
3232
return (
3333
<div>
34-
<input type="text" ref={r => (this.srcEl = r)} defaultValue={payload.src} /><br />
35-
<input type="text" ref={r => (this.captionEl = r)} defaultValue={payload.caption} /><br />
36-
<button onClick={() => save({ src: this.srcEl.value, caption: this.captionEl.value })}>Save</button>
34+
<input
35+
type="text"
36+
ref={(r) => (this.srcEl = r)}
37+
defaultValue={payload.src}
38+
/>
39+
<br />
40+
<input
41+
type="text"
42+
ref={(r) => (this.captionEl = r)}
43+
defaultValue={payload.caption}
44+
/>
45+
<br />
46+
<button
47+
onClick={() =>
48+
save({ src: this.srcEl.value, caption: this.captionEl.value })
49+
}
50+
>
51+
Save
52+
</button>
3753
</div>
3854
);
3955
} else {
4056
const onClick = isInEditor ? edit : null;
4157
return (
4258
<div>
43-
<img src={payload.src} onClick={onClick} /><br />
44-
<small>{payload.caption}</small><br />
59+
<img src={payload.src} onClick={onClick} />
60+
<br />
61+
<small>{payload.caption}</small>
62+
<br />
4563
{isInEditor && <button onClick={onClick}>Edit</button>}
4664
</div>
4765
);

demo/index.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
<!doctype html>
1+
<!DOCTYPE html>
22
<html>
33
<head>
4-
<meta charset="UTF-8">
4+
<meta charset="UTF-8" />
55
<title>MobileDoc</title>
66
<style type="text/css">
77
/* Core Mobiledoc CSS is imported via webpack in index.js */
8-
.active { font-weight: bold; }
8+
.active {
9+
font-weight: bold;
10+
}
911
</style>
1012
</head>
1113
<body>
1214
<div id="root"></div>
13-
<script src="main.js"></script>
1415
</body>
1516
</html>

demo/index.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom';
3+
import 'mobiledoc-kit/dist/mobiledoc.css';
34

4-
import * as ReactMobiledoc from '../src';
5+
import * as ReactMobiledoc from 'react-mobiledoc-editor';
56
import ImageCard from './ImageCard';
67
import ClickCounterAtom from './ClickCounterAtom';
78

8-
99
const config = {
1010
cards: [ImageCard],
1111
atoms: [ClickCounterAtom],
12-
placeholder: "Welcome to Mobiledoc!",
13-
willCreateEditor:() => { console.log('creating editor...'); },
14-
didCreateEditor:(e) => { console.log('created editor:', e); },
12+
placeholder: 'Welcome to Mobiledoc!',
13+
willCreateEditor: () => {
14+
console.log('creating editor...');
15+
},
16+
didCreateEditor: (e) => {
17+
console.log('created editor:', e);
18+
},
1519
};
1620

17-
const imgPayload = { caption: "Edit this right meow!", src: "http://www.placekitten.com/200/200" };
18-
21+
const imgPayload = {
22+
caption: 'Edit this right meow!',
23+
src: 'http://www.placekitten.com/200/200',
24+
};
1925

2026
const ImageButton = (props) => {
2127
const { isEditing } = props;
@@ -25,7 +31,6 @@ const ImageButton = (props) => {
2531
return <button onClick={onClick}>Image Card</button>;
2632
};
2733

28-
2934
const ClickCounterButton = () => {
3035
const { editor } = React.useContext(ReactMobiledoc.ReactMobileDocContext);
3136
const onClick = () => editor.insertAtom('Counter', '', { clicks: 0 });
@@ -37,7 +42,11 @@ const App = () => {
3742

3843
return (
3944
<div>
40-
<ReactMobiledoc.Container {...config} mobiledoc={state} onChange={setState}>
45+
<ReactMobiledoc.Container
46+
{...config}
47+
mobiledoc={state}
48+
onChange={setState}
49+
>
4150
<ReactMobiledoc.Toolbar />
4251
<ImageButton />
4352
<ClickCounterButton />
@@ -49,5 +58,3 @@ const App = () => {
4958
};
5059

5160
ReactDOM.render(<App />, document.getElementById('root'));
52-
53-
require("!style-loader!css-loader!../node_modules/mobiledoc-kit/dist/mobiledoc.css");

0 commit comments

Comments
 (0)