narro 5 years ago
parent
commit
6f99498da9

+ 3
- 0
CHANGELOG.md View File

@@ -1,5 +1,8 @@
1 1
 # CHANGELOG
2 2
 
3
+## 0.5.8
4
+- [x] Editor增加autoFocus属性
5
+
3 6
 ## 0.5.7
4 7
 - [x] fix: 修复评论内容不换行超出区域的问题
5 8
 

+ 1
- 1
README.md View File

@@ -54,7 +54,7 @@ import Comment, { Editor, RenderText } from 'comment';
54 54
 | showError           | boolean                         | true          | false    | 是否使用Antd的Message组件提示错误信息, 主要是上传图片出错的情况                                   |
55 55
 | onError             | function(msg,{response})        |               | false    | 错误回调, 出错了会被调用, 主要是上传图片出错的情况                                                |
56 56
 | maxLength           | number                          | 140           | false    | 限制最大输入字数                                                                                  |
57
-
57
+| autoFocus           | boolean                         | false         | false    | 编辑器自动聚焦                                                                                    |
58 58
 
59 59
 
60 60
 ### 什么时候不要使用 value/onChange/onSubmit

+ 1
- 2
lib/components/ContentItem/index.js View File

@@ -183,9 +183,8 @@ var CommentItem = function (_Component) {
183 183
               __html: (0, _helper.renderContent)(this.renderTextWithReply(newContent, content))
184 184
             }
185 185
           }),
186
-
187 186
           // image为空时不渲染comment-item-image
188
-          imageList.length > 0 && imageList[0] !== '' && _react2.default.createElement(
187
+          imageList.length > 0 && imageList[0] !== "" && _react2.default.createElement(
189 188
             "div",
190 189
             { className: "comment-item-image" },
191 190
             imageList.map(function (item, index) {

+ 1
- 1
lib/components/ContentItem/index.js.map
File diff suppressed because it is too large
View File


+ 4
- 2
lib/components/Editor/index.js View File

@@ -265,7 +265,8 @@ var Editor = function (_React$Component) {
265 265
           button = _props.button,
266 266
           emojiToolIcon = _props.emojiToolIcon,
267 267
           imageToolIcon = _props.imageToolIcon,
268
-          maxLength = _props.maxLength;
268
+          maxLength = _props.maxLength,
269
+          autoFocus = _props.autoFocus;
269 270
 
270 271
       var handleSubmit = this.handleSubmit;
271 272
       var disabledSubmit = btnDisabled || !this.props.value && !this.state.value && !this.state.fileList.length;
@@ -296,7 +297,8 @@ var Editor = function (_React$Component) {
296 297
               return _this3.handleChange(e.target.value);
297 298
             },
298 299
             rows: rows,
299
-            placeholder: placeholder
300
+            placeholder: placeholder,
301
+            autoFocus: autoFocus
300 302
           }),
301 303
           _react2.default.createElement(
302 304
             "div",

+ 1
- 1
lib/components/Editor/index.js.map
File diff suppressed because it is too large
View File


+ 1
- 0
lib/index.js View File

@@ -93,6 +93,7 @@ var Index = function (_Component) {
93 93
         },
94 94
         _react2.default.createElement(_App.Editor, {
95 95
           maxUpload: 4,
96
+          autoFocus: true,
96 97
           beforeSubmit: function beforeSubmit() {
97 98
             return new Promise(function (resolve) {
98 99
               resolve(true);

+ 1
- 1
lib/index.js.map
File diff suppressed because it is too large
View File


+ 1
- 1
package.json View File

@@ -1,6 +1,6 @@
1 1
 {
2 2
   "name": "comment",
3
-  "version": "0.5.7",
3
+  "version": "0.5.8",
4 4
   "main": "lib/App.js",
5 5
   "description": "通用评论",
6 6
   "keywords": [

+ 3
- 1
src/components/Editor/index.js View File

@@ -165,7 +165,8 @@ class Editor extends React.Component {
165 165
       button,
166 166
       emojiToolIcon,
167 167
       imageToolIcon,
168
-      maxLength
168
+      maxLength,
169
+      autoFocus
169 170
     } = this.props;
170 171
     const handleSubmit = this.handleSubmit;
171 172
     const disabledSubmit =
@@ -188,6 +189,7 @@ class Editor extends React.Component {
188 189
             onChange={e => this.handleChange(e.target.value)}
189 190
             rows={rows}
190 191
             placeholder={placeholder}
192
+            autoFocus={autoFocus}
191 193
           />
192 194
 
193 195
           <div className="comment-toolbar">

+ 1
- 0
src/index.js View File

@@ -51,6 +51,7 @@ class Index extends Component {
51 51
       >
52 52
         <Editor
53 53
           maxUpload={4}
54
+          autoFocus
54 55
           beforeSubmit={() => {
55 56
             return new Promise(resolve => {
56 57
               resolve(true);