-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSimEditor.jsx
More file actions
77 lines (65 loc) · 1.65 KB
/
SimEditor.jsx
File metadata and controls
77 lines (65 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import React from 'react';
import ReactDOM from 'react-dom';
import 'simple-module';
import 'simple-uploader';
import Simditor from 'simditor';
import 'simditor/styles/simditor.css';
class SimEditor extends React.Component {
constructor(props) {
super(props);
this.state = {};
}
componentDidMount() {
const textbox = ReactDOM.findDOMNode(this.refs.textarea);
const $textbox = $(textbox);
const editor = this.editor = new Simditor({
textarea: $textbox,
toolbar: [
'title',
'bold',
'italic',
'underline',
'strikethrough',
'fontScale',
'color',
'ol', // ordered list
'ul', // unordered list
'blockquote',
'code', // code block
'table',
'link',
'image',
'hr', // horizontal ruler
'indent',
'outdent',
'alignment',
],
placeholder: '',
defaultImage: '',
pasteImage: true,
imageButton: 'upload',
upload: {
url: '/file/uploadImageForSimEditor?fileElementId=upload_file',
fileKey: 'upload_file',
connectionCount: 3,
leaveConfirm: '还在上传图片,确定要离开吗?',
},
});
editor.setValue(this.props.content);
// 修复上传打开慢的问题
$('.toolbar-item-image input[type="file"]')
.removeAttr('multiple')
.attr('accept', 'image/gif, image/jpeg, image/jpg, image/png');
}
render() {
return (
<div>
<textarea ref="textarea" />
</div>
);
}
}
SimEditor.defaultProps = {
content: '',
};
export default SimEditor;