Browse Source

add default show upload props

Roxas 4 years ago
parent
commit
3f2f41970b
1 changed files with 12 additions and 2 deletions
  1. 12
    2
      src/components/Editor/index.js

+ 12
- 2
src/components/Editor/index.js View File

@@ -59,7 +59,7 @@ class Editor extends React.Component {
59 59
       value: props.value || "", // 编辑器里面的值
60 60
       fileList: props.fileList || [], // 图片列表
61 61
       fileMap: {}, // 已经上传的图片路径和 uid 的映射 { uid: path }
62
-      uploadVisible: false
62
+      uploadVisible: false // 上传图片弹窗是否可视
63 63
     };
64 64
     this.handleChange = this.handleChange.bind(this);
65 65
     this.handleClickEmoji = this.handleClickEmoji.bind(this);
@@ -75,7 +75,7 @@ class Editor extends React.Component {
75 75
   }
76 76
 
77 77
   componentDidMount() {
78
-    const { app, onRef } = this.props;
78
+    const { app, onRef, uploadDefaultShow } = this.props;
79 79
     if (
80 80
       app.currentUser &&
81 81
       (app.currentUser.user_id > 0 || app.currentUser.id > 0)
@@ -85,6 +85,14 @@ class Editor extends React.Component {
85 85
     if (isFunction(onRef)) {
86 86
       onRef(this);
87 87
     }
88
+    if (uploadDefaultShow) {
89
+      const uploadFileList = this.props.fileList || this.state.fileList;
90
+      if (uploadFileList.length > 0) {
91
+        this.setState({
92
+          uploadVisible: true,
93
+        });
94
+      }
95
+    }
88 96
   }
89 97
 
90 98
   handleEmojiScroll(e) {
@@ -539,6 +547,7 @@ Editor.propTypes = {
539 547
   button: PropTypes.node,
540 548
   emojiToolIcon: PropTypes.node,
541 549
   imageToolIcon: PropTypes.node,
550
+  uploadDefaultShow: PropTypes.bool,
542 551
   showError: PropTypes.bool,
543 552
   onError: PropTypes.func,
544 553
   maxLength: PropTypes.number,
@@ -553,6 +562,7 @@ Editor.defaultProps = {
553 562
   // placeholder: "说点什么吧",
554 563
   showEmoji: true,
555 564
   showUpload: true,
565
+  uploadDefaultShow: true,
556 566
   multiple: true,
557 567
   emojiPopoverPlacement: "bottomLeft",
558 568
   closeUploadWhenBlur: false,