Browse Source

add default show upload props

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