|
@@ -36,9 +36,13 @@ require("antd/es/message/style");
|
36
|
36
|
|
37
|
37
|
require("antd/es/input/style");
|
38
|
38
|
|
39
|
|
-var _react = require("react");
|
|
39
|
+var _dayjs = require("dayjs");
|
40
|
40
|
|
41
|
|
-var _react2 = _interopRequireDefault(_react);
|
|
41
|
+var _dayjs2 = _interopRequireDefault(_dayjs);
|
|
42
|
+
|
|
43
|
+var _shortid = require("shortid");
|
|
44
|
+
|
|
45
|
+var _shortid2 = _interopRequireDefault(_shortid);
|
42
|
46
|
|
43
|
47
|
var _propTypes = require("prop-types");
|
44
|
48
|
|
|
@@ -48,34 +52,32 @@ var _classnames = require("classnames");
|
48
|
52
|
|
49
|
53
|
var _classnames2 = _interopRequireDefault(_classnames);
|
50
|
54
|
|
51
|
|
-var _reactIntlUniversal = require("react-intl-universal");
|
52
|
|
-
|
53
|
|
-var _reactIntlUniversal2 = _interopRequireDefault(_reactIntlUniversal);
|
54
|
|
-
|
55
|
|
-var _dayjs = require("dayjs");
|
|
55
|
+var _react = require("react");
|
56
|
56
|
|
57
|
|
-var _dayjs2 = _interopRequireDefault(_dayjs);
|
|
57
|
+var _react2 = _interopRequireDefault(_react);
|
58
|
58
|
|
59
|
|
-var _shortid = require("shortid");
|
|
59
|
+var _reactIntlUniversal = require("react-intl-universal");
|
60
|
60
|
|
61
|
|
-var _shortid2 = _interopRequireDefault(_shortid);
|
|
61
|
+var _reactIntlUniversal2 = _interopRequireDefault(_reactIntlUniversal);
|
62
|
62
|
|
63
|
|
-var _constant = require("../../constant");
|
|
63
|
+var _Emoji = require("./Emoji");
|
64
|
64
|
|
65
|
|
-var _helper = require("../../helper");
|
|
65
|
+var _Emoji2 = _interopRequireDefault(_Emoji);
|
66
|
66
|
|
67
|
67
|
var _Upload = require("./Upload");
|
68
|
68
|
|
69
|
69
|
var _Upload2 = _interopRequireDefault(_Upload);
|
70
|
70
|
|
71
|
|
-var _Emoji = require("./Emoji");
|
72
|
|
-
|
73
|
|
-var _Emoji2 = _interopRequireDefault(_Emoji);
|
74
|
|
-
|
75
|
71
|
var _Comment = require("../../Comment");
|
76
|
72
|
|
77
|
73
|
var _Comment2 = _interopRequireDefault(_Comment);
|
78
|
74
|
|
|
75
|
+var _utils = require("./../../utils");
|
|
76
|
+
|
|
77
|
+var _constant = require("../../constant");
|
|
78
|
+
|
|
79
|
+var _helper = require("../../helper");
|
|
80
|
+
|
79
|
81
|
require("./index.css");
|
80
|
82
|
|
81
|
83
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -139,6 +141,7 @@ var Editor = function (_React$Component) {
|
139
|
141
|
_this.resetState = _this.resetState.bind(_this);
|
140
|
142
|
_this.handleEmojiScroll = _this.handleEmojiScroll.bind(_this);
|
141
|
143
|
_this.handlePressEnter = _this.handlePressEnter.bind(_this);
|
|
144
|
+ _this.invokeFileListChange = _this.invokeFileListChange.bind(_this);
|
142
|
145
|
return _this;
|
143
|
146
|
}
|
144
|
147
|
|
|
@@ -213,8 +216,7 @@ var Editor = function (_React$Component) {
|
213
|
216
|
if (fileList.length > this.props.maxUpload) {
|
214
|
217
|
list = fileList.slice(0, this.props.maxUpload);
|
215
|
218
|
}
|
216
|
|
- this.props.handleChangeFileList(list);
|
217
|
|
- this.setState({ fileList: list });
|
|
219
|
+ this.invokeFileListChange(list);
|
218
|
220
|
}
|
219
|
221
|
|
220
|
222
|
/**
|
|
@@ -252,16 +254,37 @@ var Editor = function (_React$Component) {
|
252
|
254
|
}
|
253
|
255
|
return item;
|
254
|
256
|
});
|
255
|
|
- this.props.handleChangeFileList(fileList);
|
256
|
|
- this.setState({ fileMap: fileMap, fileList: fileList });
|
|
257
|
+ this.setState({ fileMap: fileMap });
|
|
258
|
+ this.invokeFileListChange(fileList);
|
257
|
259
|
}
|
258
|
260
|
|
259
|
261
|
/**
|
260
|
|
- * 粘贴回调
|
|
262
|
+ * **统一处理fileList的修改**
|
|
263
|
+ * 1. upload
|
|
264
|
+ * 2. paste
|
|
265
|
+ * PS: 移动端需要做额外操作
|
|
266
|
+ * -- evo 20200223
|
261
|
267
|
*/
|
262
|
268
|
|
|
269
|
+ }, {
|
|
270
|
+ key: "invokeFileListChange",
|
|
271
|
+ value: function invokeFileListChange(fileList) {
|
|
272
|
+ this.props.handleChangeFileList(fileList);
|
|
273
|
+ this.setState({ fileList: fileList });
|
|
274
|
+ if (_utils.isMobile) {
|
|
275
|
+ var file = fileList[0];
|
|
276
|
+ if (file && file.status === 'done' && !file.thumbUrl.includes('data:image')) {
|
|
277
|
+ this.setState({ uploadVisible: false });
|
|
278
|
+ }
|
|
279
|
+ }
|
|
280
|
+ }
|
263
|
281
|
}, {
|
264
|
282
|
key: "handlePaste",
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+ /**
|
|
286
|
+ * 粘贴回调
|
|
287
|
+ */
|
265
|
288
|
value: function handlePaste(e) {
|
266
|
289
|
var _this2 = this;
|
267
|
290
|
|
|
@@ -293,10 +316,7 @@ var Editor = function (_React$Component) {
|
293
|
316
|
type: file.type,
|
294
|
317
|
uid: new Date().valueOf()
|
295
|
318
|
});
|
296
|
|
- _this2.props.handleChangeFileList(fileList);
|
297
|
|
- _this2.setState({
|
298
|
|
- fileList: fileList
|
299
|
|
- });
|
|
319
|
+ _this2.invokeFileListChange(fileList);
|
300
|
320
|
}).catch(function (e) {
|
301
|
321
|
var msg = e.message || _constant.ERROR_DEFAULT;
|
302
|
322
|
if (_this2.props.showError) {
|
|
@@ -525,13 +545,7 @@ var Editor = function (_React$Component) {
|
525
|
545
|
},
|
526
|
546
|
content: _react2.default.createElement(
|
527
|
547
|
"div",
|
528
|
|
- {
|
529
|
|
- style: {
|
530
|
|
- width: 336, // 一行显示3张
|
531
|
|
- minHeight: 100,
|
532
|
|
- margin: "0 auto"
|
533
|
|
- }
|
534
|
|
- },
|
|
548
|
+ { className: "comment-img-popover" },
|
535
|
549
|
_react2.default.createElement(_Upload2.default, {
|
536
|
550
|
onRef: function onRef(node) {
|
537
|
551
|
return _this4.uploadRef = node;
|
|
@@ -548,14 +562,14 @@ var Editor = function (_React$Component) {
|
548
|
562
|
),
|
549
|
563
|
title: _react2.default.createElement(
|
550
|
564
|
"div",
|
551
|
|
- { style: { margin: "5px auto" } },
|
|
565
|
+ { className: "comment-img-title" },
|
552
|
566
|
_react2.default.createElement(
|
553
|
567
|
"span",
|
554
|
568
|
null,
|
555
|
569
|
_reactIntlUniversal2.default.get("editor.uploadTip"),
|
556
|
570
|
maxUpload >= 2 ? _react2.default.createElement(
|
557
|
571
|
"span",
|
558
|
|
- { style: { color: "#666", fontWeight: 400 } },
|
|
572
|
+ { className: "comment-img-title-counter" },
|
559
|
573
|
_reactIntlUniversal2.default.get("editor.uploadCount", {
|
560
|
574
|
count: maxUpload - uploadFileList.length
|
561
|
575
|
})
|