ソースを参照

feature: 编辑器内部值支持预处理函数preRenderValue

Roxas 4 年 前
コミット
38edbfc2c7

+ 8
- 3
lib/App.js ファイルの表示

766
           commentId: this.state.commentId,
766
           commentId: this.state.commentId,
767
           userId: this.state.content.user_id,
767
           userId: this.state.content.user_id,
768
           content: this.state.content,
768
           content: this.state.content,
769
-          handleClose: this.handleClose
769
+          handleClose: this.handleClose,
770
+          preRenderValue: this.props.preRenderValue
770
         })
771
         })
771
       );
772
       );
772
     }
773
     }
797
   onUpdateComment: _propTypes2.default.func,
798
   onUpdateComment: _propTypes2.default.func,
798
   locales: _propTypes2.default.string, //  传入的语言环境, en-US/zh-CN
799
   locales: _propTypes2.default.string, //  传入的语言环境, en-US/zh-CN
799
   onCountChange: _propTypes2.default.func, // 评论数量变更时的回调
800
   onCountChange: _propTypes2.default.func, // 评论数量变更时的回调
800
-  onCommentFail: _propTypes2.default.func // 评论失败时的回调
801
+  onCommentFail: _propTypes2.default.func, // 评论失败时的回调
802
+  preRenderValue: _propTypes2.default.func // 编辑器渲染前对值需要做的工作
801
 };
803
 };
802
 
804
 
803
 App.defaultProps = {
805
 App.defaultProps = {
820
   onUpdateComment: function onUpdateComment() {},
822
   onUpdateComment: function onUpdateComment() {},
821
   onBeforeUpdateComment: function onBeforeUpdateComment() {},
823
   onBeforeUpdateComment: function onBeforeUpdateComment() {},
822
   onCountChange: function onCountChange() {},
824
   onCountChange: function onCountChange() {},
823
-  onCommentFail: function onCommentFail() {}
825
+  onCommentFail: function onCommentFail() {},
826
+  preRenderValue: function preRenderValue(v) {
827
+    return v;
828
+  }
824
 };
829
 };
825
 
830
 
826
 exports.Editor = _Editor2.default;
831
 exports.Editor = _Editor2.default;

+ 1
- 1
lib/App.js.map
ファイル差分が大きすぎるため省略します
ファイルの表示


+ 1
- 1
lib/components/EditComment/EditComment.js ファイルの表示

193
             commentId: this.props.commentId,
193
             commentId: this.props.commentId,
194
             userId: this.props.content.user_id,
194
             userId: this.props.content.user_id,
195
             fileList: this.state.fileList,
195
             fileList: this.state.fileList,
196
-            value: this.state.value,
196
+            value: this.props.preRenderValue && this.props.preRenderValue(this.state.value),
197
             onChange: function onChange(value) {
197
             onChange: function onChange(value) {
198
               _this2.setState({
198
               _this2.setState({
199
                 value: value
199
                 value: value

+ 1
- 1
lib/components/EditComment/EditComment.js.map
ファイル差分が大きすぎるため省略します
ファイルの表示


+ 2
- 2
lib/components/Editor/Upload.js ファイルの表示

232
             onClick: _this3.handleCloseClick.bind(_this3, index),
232
             onClick: _this3.handleCloseClick.bind(_this3, index),
233
             key: file.uid,
233
             key: file.uid,
234
             style: {
234
             style: {
235
-              left: index % 3 * 112 + 110 + "px",
236
-              top: Math.floor(index / 3) * 112 + 26 + "px"
235
+              left: index % 3 * 112 + 98 + "px",
236
+              top: Math.floor(index / 3) * 112 + 16 + "px"
237
             }
237
             }
238
           });
238
           });
239
         }),
239
         }),

+ 3
- 0
lib/index.js ファイルの表示

194
     sendMessage: function sendMessage(id) {
194
     sendMessage: function sendMessage(id) {
195
       console.log("sendMessage", id);
195
       console.log("sendMessage", id);
196
     },
196
     },
197
+    preRenderValue: function preRenderValue(value) {
198
+      return "" + value;
199
+    },
197
     editorProps: {
200
     editorProps: {
198
       onCommentSuccess: function onCommentSuccess(data) {
201
       onCommentSuccess: function onCommentSuccess(data) {
199
         console.log(data);
202
         console.log(data);

+ 1
- 1
lib/index.js.map
ファイル差分が大きすぎるため省略します
ファイルの表示


+ 4
- 4
lib/version.json ファイルの表示

1
 {
1
 {
2
     "name":       "comment",
2
     "name":       "comment",
3
-    "buildDate":  1574306910894,
3
+    "buildDate":  1577536315907,
4
     "version":    "1.0.4",
4
     "version":    "1.0.4",
5
-    "numCommits": 195,
6
-    "hash":       "db0a99c",
7
-    "dirty":      false
5
+    "numCommits": 197,
6
+    "hash":       "92e9ffb",
7
+    "dirty":      true
8
 }
8
 }

+ 5
- 2
src/App.js ファイルの表示

617
               userId={this.state.content.user_id}
617
               userId={this.state.content.user_id}
618
               content={this.state.content}
618
               content={this.state.content}
619
               handleClose={this.handleClose}
619
               handleClose={this.handleClose}
620
+              preRenderValue={this.props.preRenderValue}
620
             />
621
             />
621
           )}
622
           )}
622
         </CommentContext.Provider>
623
         </CommentContext.Provider>
647
   onUpdateComment: PropTypes.func,
648
   onUpdateComment: PropTypes.func,
648
   locales: PropTypes.string, //  传入的语言环境, en-US/zh-CN
649
   locales: PropTypes.string, //  传入的语言环境, en-US/zh-CN
649
   onCountChange: PropTypes.func, // 评论数量变更时的回调
650
   onCountChange: PropTypes.func, // 评论数量变更时的回调
650
-  onCommentFail: PropTypes.func // 评论失败时的回调
651
+  onCommentFail: PropTypes.func, // 评论失败时的回调
652
+  preRenderValue: PropTypes.func // 编辑器渲染前对值需要做的工作
651
 };
653
 };
652
 
654
 
653
 App.defaultProps = {
655
 App.defaultProps = {
673
   onUpdateComment: () => {},
675
   onUpdateComment: () => {},
674
   onBeforeUpdateComment: () => {},
676
   onBeforeUpdateComment: () => {},
675
   onCountChange: () => {},
677
   onCountChange: () => {},
676
-  onCommentFail: () => {}
678
+  onCommentFail: () => {},
679
+  preRenderValue: v => v
677
 };
680
 };
678
 
681
 
679
 export { Editor, RenderText };
682
 export { Editor, RenderText };

+ 4
- 1
src/components/EditComment/EditComment.js ファイルの表示

111
               commentId={this.props.commentId}
111
               commentId={this.props.commentId}
112
               userId={this.props.content.user_id}
112
               userId={this.props.content.user_id}
113
               fileList={this.state.fileList}
113
               fileList={this.state.fileList}
114
-              value={this.state.value}
114
+              value={
115
+                this.props.preRenderValue &&
116
+                this.props.preRenderValue(this.state.value)
117
+              }
115
               onChange={value => {
118
               onChange={value => {
116
                 this.setState({
119
                 this.setState({
117
                   value
120
                   value

+ 3
- 0
src/index.js ファイルの表示

159
     sendMessage: id => {
159
     sendMessage: id => {
160
       console.log("sendMessage", id);
160
       console.log("sendMessage", id);
161
     },
161
     },
162
+    preRenderValue: value => {
163
+      return `${value}`;
164
+    },
162
     editorProps: {
165
     editorProps: {
163
       onCommentSuccess: data => {
166
       onCommentSuccess: data => {
164
         console.log(data);
167
         console.log(data);