Browse Source

add default show upload props with timeout

Roxas 4 years ago
parent
commit
1226c385fd

+ 30
- 26
lib/components/Editor/index.js View File

148
   _createClass(Editor, [{
148
   _createClass(Editor, [{
149
     key: "componentDidMount",
149
     key: "componentDidMount",
150
     value: function componentDidMount() {
150
     value: function componentDidMount() {
151
+      var _this2 = this;
152
+
151
       var _props = this.props,
153
       var _props = this.props,
152
           app = _props.app,
154
           app = _props.app,
153
           onRef = _props.onRef,
155
           onRef = _props.onRef,
162
       if (uploadDefaultShow) {
164
       if (uploadDefaultShow) {
163
         var uploadFileList = this.props.fileList || this.state.fileList;
165
         var uploadFileList = this.props.fileList || this.state.fileList;
164
         if (uploadFileList.length > 0) {
166
         if (uploadFileList.length > 0) {
165
-          this.setState({
166
-            uploadVisible: true
167
-          });
167
+          setTimeout(function () {
168
+            _this2.setState({
169
+              uploadVisible: true
170
+            });
171
+          }, 1000);
168
         }
172
         }
169
       }
173
       }
170
     }
174
     }
299
   }, {
303
   }, {
300
     key: "handlePaste",
304
     key: "handlePaste",
301
     value: function handlePaste(e) {
305
     value: function handlePaste(e) {
302
-      var _this2 = this;
306
+      var _this3 = this;
303
 
307
 
304
       if (this.state.fileList.length >= this.props.maxUpload) {
308
       if (this.state.fileList.length >= this.props.maxUpload) {
305
         return;
309
         return;
322
       reader.readAsDataURL(file);
326
       reader.readAsDataURL(file);
323
       reader.onloadend = function () {
327
       reader.onloadend = function () {
324
         // DRIVER_LICENSE_PATH oss 的存储路径位置
328
         // DRIVER_LICENSE_PATH oss 的存储路径位置
325
-        UploadToOss(_this2.props.app.oss, _constant.DRIVER_LICENSE_PATH, file).then(function (data) {
326
-          var fileList = _this2.state.fileList.concat({
329
+        UploadToOss(_this3.props.app.oss, _constant.DRIVER_LICENSE_PATH, file).then(function (data) {
330
+          var fileList = _this3.state.fileList.concat({
327
             url: _constant.OSS_LINK + data.name,
331
             url: _constant.OSS_LINK + data.name,
328
             thumbUrl: _constant.OSS_LINK + data.name,
332
             thumbUrl: _constant.OSS_LINK + data.name,
329
             type: file.type,
333
             type: file.type,
330
             uid: new Date().valueOf()
334
             uid: new Date().valueOf()
331
           });
335
           });
332
-          _this2.invokeFileListChange(fileList);
336
+          _this3.invokeFileListChange(fileList);
333
         }).catch(function (e) {
337
         }).catch(function (e) {
334
           var msg = e.message || _constant.ERROR_DEFAULT;
338
           var msg = e.message || _constant.ERROR_DEFAULT;
335
-          if (_this2.props.showError) {
339
+          if (_this3.props.showError) {
336
             _message3.default.error(msg);
340
             _message3.default.error(msg);
337
           }
341
           }
338
-          if (_this2.props.onError) {
339
-            _this2.props.onError(msg, { response: e.response });
342
+          if (_this3.props.onError) {
343
+            _this3.props.onError(msg, { response: e.response });
340
           }
344
           }
341
         });
345
         });
342
       };
346
       };
351
   }, {
355
   }, {
352
     key: "handleSubmit",
356
     key: "handleSubmit",
353
     value: function handleSubmit() {
357
     value: function handleSubmit() {
354
-      var _this3 = this;
358
+      var _this4 = this;
355
 
359
 
356
       var maxLength = this.props.maxLength;
360
       var maxLength = this.props.maxLength;
357
       var _state = this.state,
361
       var _state = this.state,
380
       if (this.props.beforeSubmit) {
384
       if (this.props.beforeSubmit) {
381
         Promise.resolve(this.props.beforeSubmit({ text: value, files: files })).then(function (res) {
385
         Promise.resolve(this.props.beforeSubmit({ text: value, files: files })).then(function (res) {
382
           if (!(res === false)) {
386
           if (!(res === false)) {
383
-            _this3.props.onSubmit({ text: value, files: files }, function (res, action) {
384
-              _this3.resetState();
385
-              if (action === "comment" && _this3.props.onCommentSuccess) {
386
-                _this3.props.onCommentSuccess(res);
387
+            _this4.props.onSubmit({ text: value, files: files }, function (res, action) {
388
+              _this4.resetState();
389
+              if (action === "comment" && _this4.props.onCommentSuccess) {
390
+                _this4.props.onCommentSuccess(res);
387
               }
391
               }
388
             });
392
             });
389
           }
393
           }
390
         });
394
         });
391
       } else {
395
       } else {
392
         this.props.onSubmit({ text: value, files: files }, function (res, action) {
396
         this.props.onSubmit({ text: value, files: files }, function (res, action) {
393
-          _this3.resetState();
394
-          if (action === "comment" && _this3.props.onCommentSuccess) {
395
-            _this3.props.onCommentSuccess(res);
397
+          _this4.resetState();
398
+          if (action === "comment" && _this4.props.onCommentSuccess) {
399
+            _this4.props.onCommentSuccess(res);
396
           }
400
           }
397
         });
401
         });
398
       }
402
       }
456
   }, {
460
   }, {
457
     key: "render",
461
     key: "render",
458
     value: function render() {
462
     value: function render() {
459
-      var _this4 = this;
463
+      var _this5 = this;
460
 
464
 
461
       var _props4 = this.props,
465
       var _props4 = this.props,
462
           value = _props4.value,
466
           value = _props4.value,
503
             _react2.default.createElement(TextArea, {
507
             _react2.default.createElement(TextArea, {
504
               value: inputValue,
508
               value: inputValue,
505
               onChange: function onChange(e) {
509
               onChange: function onChange(e) {
506
-                _this4.handleChange(e.target.value);
510
+                _this5.handleChange(e.target.value);
507
               },
511
               },
508
               rows: rows,
512
               rows: rows,
509
               placeholder: placeholder,
513
               placeholder: placeholder,
532
                       _react2.default.createElement(_Emoji2.default, {
536
                       _react2.default.createElement(_Emoji2.default, {
533
                         onClick: this.handleClickEmoji,
537
                         onClick: this.handleClickEmoji,
534
                         ref: function ref(node) {
538
                         ref: function ref(node) {
535
-                          _this4.emoji = node;
539
+                          _this5.emoji = node;
536
                         },
540
                         },
537
                         emojiList: this.props.app.emojiList
541
                         emojiList: this.props.app.emojiList
538
                       })
542
                       })
552
                     autoAdjustOverflow: false,
556
                     autoAdjustOverflow: false,
553
                     overlayStyle: { zIndex: 9999 },
557
                     overlayStyle: { zIndex: 9999 },
554
                     onVisibleChange: function onVisibleChange(visible) {
558
                     onVisibleChange: function onVisibleChange(visible) {
555
-                      _this4.setState({
559
+                      _this5.setState({
556
                         uploadVisible: visible
560
                         uploadVisible: visible
557
                       });
561
                       });
558
                     },
562
                     },
561
                       { className: "comment-img-popover" },
565
                       { className: "comment-img-popover" },
562
                       _react2.default.createElement(_Upload2.default, {
566
                       _react2.default.createElement(_Upload2.default, {
563
                         onRef: function onRef(node) {
567
                         onRef: function onRef(node) {
564
-                          return _this4.uploadRef = node;
568
+                          return _this5.uploadRef = node;
565
                         },
569
                         },
566
                         multiple: multiple,
570
                         multiple: multiple,
567
                         onChangeFileList: this.handleChangeFileList,
571
                         onChangeFileList: this.handleChangeFileList,
592
                   },
596
                   },
593
                   imageToolIcon ? _react2.default.cloneElement(imageToolIcon, {
597
                   imageToolIcon ? _react2.default.cloneElement(imageToolIcon, {
594
                     onClick: function onClick() {
598
                     onClick: function onClick() {
595
-                      return _this4.handleShowUpload(true);
599
+                      return _this5.handleShowUpload(true);
596
                     }
600
                     }
597
                   }) : _react2.default.createElement(_icon2.default, {
601
                   }) : _react2.default.createElement(_icon2.default, {
598
                     type: "picture",
602
                     type: "picture",
599
                     className: "comment-toolbar-icon",
603
                     className: "comment-toolbar-icon",
600
                     style: { marginLeft: 20 },
604
                     style: { marginLeft: 20 },
601
                     onClick: function onClick() {
605
                     onClick: function onClick() {
602
-                      return _this4.handleShowUpload(true);
606
+                      return _this5.handleShowUpload(true);
603
                     }
607
                     }
604
                   })
608
                   })
605
                 ) : null
609
                 ) : null
613
                   _button2.default,
617
                   _button2.default,
614
                   {
618
                   {
615
                     onClick: function onClick() {
619
                     onClick: function onClick() {
616
-                      return _this4.handleSubmit();
620
+                      return _this5.handleSubmit();
617
                     },
621
                     },
618
                     type: "primary",
622
                     type: "primary",
619
                     loading: btnLoading,
623
                     loading: btnLoading,

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


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

88
     if (uploadDefaultShow) {
88
     if (uploadDefaultShow) {
89
       const uploadFileList = this.props.fileList || this.state.fileList;
89
       const uploadFileList = this.props.fileList || this.state.fileList;
90
       if (uploadFileList.length > 0) {
90
       if (uploadFileList.length > 0) {
91
-        this.setState({
92
-          uploadVisible: true,
93
-        });
91
+        setTimeout(() => {
92
+          this.setState({
93
+            uploadVisible: true
94
+          });
95
+        }, 1000);
94
       }
96
       }
95
     }
97
     }
96
   }
98
   }