Skip to content

Commit caddad7

Browse files
committed
integrate
1 parent d3b32d4 commit caddad7

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

AddImageButton/index.js renamed to AddImageByURLButton.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import ReactDOM from 'react-dom';
33
import insertDataBlock from 'draft-js-buttons-plugin/lib/utils/insertDataBlock.js';
44
import axios from 'axios';
55

6-
const token = `?token=f9403fc5f537b4ab332d`;
6+
const token = '?token=token';
7+
const serverURL = 'http://localhost:25478';
78

89
export default class imageButton extends Component {
910
onClick = e => {
@@ -15,10 +16,10 @@ export default class imageButton extends Component {
1516
const file = e.target.files[0];
1617
const params = new FormData();
1718
params.append('file', file);
18-
const response = await axios.post(`http://localhost:25478/upload${token}`, params, {
19+
const response = await axios.post(`${serverURL}/upload${token}`, params, {
1920
headers: { 'Content-Type': `multipart/form-data; boundary=${params._boundary}` }
2021
});
21-
const imageData = { src: `http://localhost:25478/${response.data.path}${token}`, type: 'placeholder' };
22+
const imageData = { src: `${serverURL}/${response.data.path}${token}`, type: 'placeholder' };
2223
this.props.setEditorState(insertDataBlock(this.props.getEditorState(), imageData, 'image'));
2324
};
2425

@@ -29,7 +30,7 @@ export default class imageButton extends Component {
2930
render() {
3031
const { theme } = this.props;
3132
return (
32-
<div className={theme.buttonWrapper} onMouseDown={this.preventBubblingUp}>
33+
<div className={theme.buttonWrapper} onMouseDown={this.preventBubblingUp} style={{ color: 'inherit' }}>
3334
<button className={theme.button} onClick={this.onClick} type="button">
3435
<svg width="24" height="24" viewBox="0 0 24 24">
3536
<path
@@ -41,7 +42,7 @@ export default class imageButton extends Component {
4142
</button>
4243

4344
<div className={theme.addImage}>
44-
<input type="file" ref="fileInput" onChange={::this.inputChange} style={{ display: 'none' }} />
45+
<input type="file" ref="fileInput" onChange={this.inputChange} style={{ display: 'none' }} />
4546
</div>
4647
</div>
4748
);

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
yarn && yarn start
66

77
# 2. run file upload/donwload sever locally
8-
docker run --rm -p 25478:25478 -v $HOME/tmp:/var/root mayth/simple-upload-server app -token f9403fc5f537b4ab332d /var/root
8+
docker run --rm -p 25478:25478 --name demoserver -v $HOME/tmp:/var/root mayth/simple-upload-server app -token token /var/root
99
# > time="2019-11-26T16:25:31Z" level=info msg="starting up simple-upload-server"
1010
# > time="2019-11-26T16:25:31Z" level=info msg="start listening" ip=0.0.0.0 port=25478 root=/var/root token=f9403fc5f537b4ab332d upload_limit=5242880
1111

1212
# 3. upload test
13-
curl --form file=@`pwd`/demo1.gif 'http://localhost:25478/upload?token=f9403fc5f537b4ab332d'
13+
curl --form file=@`pwd`/demo1.gif 'http://localhost:25478/upload?token=token'
1414
# > {"ok":true,"path":"/files/demo1.gif"}
1515

1616
# 4. quit google chrome and re-run with cors-disabled

index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
position: relative;
1313
z-index: 1;
1414
}
15+
[style='color: inherit;'] button {
16+
background-color: red;
17+
}
1518
</style>
1619
</head>
1720
<body>

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { EditorState, ContentState } from 'draft-js';
44
import Editor, { composeDecorators } from 'draft-js-plugins-editor';
55
import createImagePlugin from 'draft-js-image-plugin';
66
import createResizeablePlugin from 'draft-js-resizeable-plugin';
7-
import { BlockquoteButton } from 'draft-js-buttons';
87
import createSideToolbarPlugin from 'draft-js-side-toolbar-plugin';
9-
import AddImageButton from './AddImageButton';
8+
import AddImageByURLButton from './AddImageByURLButton';
9+
import { AddImageButton } from 'draft-js-buttons-plugin';
1010
import 'draft-js-side-toolbar-plugin/lib/plugin.css';
1111

1212
const resizeablePlugin = createResizeablePlugin();
@@ -28,8 +28,8 @@ class ExampleEditor extends Component {
2828
<SideToolbar>
2929
{externalProps => (
3030
<div>
31+
<AddImageByURLButton {...externalProps} />
3132
<AddImageButton {...externalProps} />
32-
<BlockquoteButton {...externalProps} />
3333
</div>
3434
)}
3535
</SideToolbar>

0 commit comments

Comments
 (0)