|
@@ -416,7 +416,8 @@ var Editor = function (_React$Component) {
|
416
|
416
|
emojiToolIcon = _props2.emojiToolIcon,
|
417
|
417
|
imageToolIcon = _props2.imageToolIcon,
|
418
|
418
|
maxLength = _props2.maxLength,
|
419
|
|
- autoFocus = _props2.autoFocus;
|
|
419
|
+ autoFocus = _props2.autoFocus,
|
|
420
|
+ app = _props2.app;
|
420
|
421
|
|
421
|
422
|
var placeholder = this.props.placeholder || _reactIntlUniversal2.default.get("editor.placeholder");
|
422
|
423
|
var btnSubmitText = this.props.btnSubmitText || _reactIntlUniversal2.default.get("editor.SubmitBtn");
|
|
@@ -424,146 +425,173 @@ var Editor = function (_React$Component) {
|
424
|
425
|
var disabledSubmit = this.checkDisabledSubmit();
|
425
|
426
|
var inputValue = value || this.state.value;
|
426
|
427
|
var uploadFileList = fileList || this.state.fileList;
|
|
428
|
+ var isLogin = app.currentUser && app.currentUser.user_id > 0;
|
427
|
429
|
return _react2.default.createElement(
|
428
|
430
|
"div",
|
429
|
431
|
{ className: "comment-editor-container", onPaste: this.handlePaste },
|
430
|
|
- _react2.default.createElement("div", {
|
431
|
|
- className: (0, _classnames2.default)({
|
432
|
|
- "comment-editor-toolbar": true,
|
433
|
|
- "comment-editor-toolbar-error": inputValue.length > maxLength
|
434
|
|
- })
|
435
|
|
- }),
|
436
|
|
- _react2.default.createElement(
|
437
|
|
- "div",
|
438
|
|
- { className: "comment-editor" },
|
439
|
|
- _react2.default.createElement(TextArea, {
|
440
|
|
- value: inputValue,
|
441
|
|
- onChange: function onChange(e) {
|
442
|
|
- return _this4.handleChange(e.target.value);
|
443
|
|
- },
|
444
|
|
- rows: rows,
|
445
|
|
- placeholder: placeholder,
|
446
|
|
- autoFocus: autoFocus
|
|
432
|
+ isLogin ? _react2.default.createElement(
|
|
433
|
+ _react.Fragment,
|
|
434
|
+ null,
|
|
435
|
+ _react2.default.createElement("div", {
|
|
436
|
+ className: (0, _classnames2.default)({
|
|
437
|
+ "comment-editor-toolbar": true,
|
|
438
|
+ "comment-editor-toolbar-error": inputValue.length > maxLength
|
|
439
|
+ })
|
447
|
440
|
}),
|
448
|
441
|
_react2.default.createElement(
|
449
|
442
|
"div",
|
450
|
|
- { className: "comment-toolbar" },
|
|
443
|
+ { className: "comment-editor" },
|
|
444
|
+ _react2.default.createElement(TextArea, {
|
|
445
|
+ value: inputValue,
|
|
446
|
+ onChange: function onChange(e) {
|
|
447
|
+ return _this4.handleChange(e.target.value);
|
|
448
|
+ },
|
|
449
|
+ rows: rows,
|
|
450
|
+ placeholder: placeholder,
|
|
451
|
+ autoFocus: autoFocus
|
|
452
|
+ }),
|
451
|
453
|
_react2.default.createElement(
|
452
|
454
|
"div",
|
453
|
|
- { className: "comment-toolbar-left" },
|
454
|
|
- showEmoji && _react2.default.createElement(
|
455
|
|
- _popover2.default,
|
456
|
|
- {
|
457
|
|
- trigger: "click",
|
458
|
|
- placement: emojiPopoverPlacement,
|
459
|
|
- autoAdjustOverflow: false,
|
460
|
|
- overlayStyle: { zIndex: 9999 },
|
461
|
|
- content: _react2.default.createElement(
|
462
|
|
- "div",
|
463
|
|
- {
|
464
|
|
- style: { width: 240, height: 205 },
|
465
|
|
- onWheel: this.handleEmojiScroll
|
466
|
|
- },
|
467
|
|
- _react2.default.createElement(_Emoji2.default, {
|
468
|
|
- onClick: this.handleClickEmoji,
|
469
|
|
- ref: function ref(node) {
|
470
|
|
- _this4.emoji = node;
|
|
455
|
+ { className: "comment-toolbar" },
|
|
456
|
+ _react2.default.createElement(
|
|
457
|
+ "div",
|
|
458
|
+ { className: "comment-toolbar-left" },
|
|
459
|
+ showEmoji && _react2.default.createElement(
|
|
460
|
+ _popover2.default,
|
|
461
|
+ {
|
|
462
|
+ trigger: "click",
|
|
463
|
+ placement: emojiPopoverPlacement,
|
|
464
|
+ autoAdjustOverflow: false,
|
|
465
|
+ overlayStyle: { zIndex: 9999 },
|
|
466
|
+ content: _react2.default.createElement(
|
|
467
|
+ "div",
|
|
468
|
+ {
|
|
469
|
+ style: { width: 240, height: 205 },
|
|
470
|
+ onWheel: this.handleEmojiScroll
|
471
|
471
|
},
|
472
|
|
- emojiList: this.props.app.emojiList
|
473
|
|
- })
|
474
|
|
- ),
|
475
|
|
- overlayClassName: "comment-emoji-popover"
|
476
|
|
- },
|
477
|
|
- emojiToolIcon || _react2.default.createElement(_icon2.default, { type: "smile-o", className: "comment-toolbar-icon" })
|
478
|
|
- ),
|
479
|
|
- showUpload ? _react2.default.createElement(
|
480
|
|
- _popover2.default,
|
481
|
|
- {
|
482
|
|
- trigger: "click"
|
483
|
|
- // TODO: 针对非 react.js,直接使用 click 事件来控制展开或关闭
|
484
|
|
- , visible: this.state.uploadVisible,
|
485
|
|
- placement: uploadPopoverPlacement,
|
486
|
|
- overlayClassName: uploadOverlayClassName,
|
487
|
|
- autoAdjustOverflow: false,
|
488
|
|
- overlayStyle: { zIndex: 9999 },
|
489
|
|
- onVisibleChange: function onVisibleChange(visible) {
|
490
|
|
- _this4.setState({
|
491
|
|
- uploadVisible: visible
|
492
|
|
- });
|
|
472
|
+ _react2.default.createElement(_Emoji2.default, {
|
|
473
|
+ onClick: this.handleClickEmoji,
|
|
474
|
+ ref: function ref(node) {
|
|
475
|
+ _this4.emoji = node;
|
|
476
|
+ },
|
|
477
|
+ emojiList: this.props.app.emojiList
|
|
478
|
+ })
|
|
479
|
+ ),
|
|
480
|
+ overlayClassName: "comment-emoji-popover"
|
493
|
481
|
},
|
494
|
|
- content: _react2.default.createElement(
|
495
|
|
- "div",
|
496
|
|
- {
|
497
|
|
- style: {
|
498
|
|
- width: 336, // 一行显示3张
|
499
|
|
- minHeight: 100,
|
500
|
|
- margin: "0 auto"
|
501
|
|
- }
|
|
482
|
+ emojiToolIcon || _react2.default.createElement(_icon2.default, { type: "smile-o", className: "comment-toolbar-icon" })
|
|
483
|
+ ),
|
|
484
|
+ showUpload ? _react2.default.createElement(
|
|
485
|
+ _popover2.default,
|
|
486
|
+ {
|
|
487
|
+ trigger: "click"
|
|
488
|
+ // TODO: 针对非 react.js,直接使用 click 事件来控制展开或关闭
|
|
489
|
+ , visible: this.state.uploadVisible,
|
|
490
|
+ placement: uploadPopoverPlacement,
|
|
491
|
+ overlayClassName: uploadOverlayClassName,
|
|
492
|
+ autoAdjustOverflow: false,
|
|
493
|
+ overlayStyle: { zIndex: 9999 },
|
|
494
|
+ onVisibleChange: function onVisibleChange(visible) {
|
|
495
|
+ _this4.setState({
|
|
496
|
+ uploadVisible: visible
|
|
497
|
+ });
|
502
|
498
|
},
|
503
|
|
- _react2.default.createElement(_Upload2.default, {
|
504
|
|
- onRef: function onRef(node) {
|
505
|
|
- return _this4.uploadRef = node;
|
|
499
|
+ content: _react2.default.createElement(
|
|
500
|
+ "div",
|
|
501
|
+ {
|
|
502
|
+ style: {
|
|
503
|
+ width: 336, // 一行显示3张
|
|
504
|
+ minHeight: 100,
|
|
505
|
+ margin: "0 auto"
|
|
506
|
+ }
|
506
|
507
|
},
|
507
|
|
- multiple: multiple,
|
508
|
|
- onChangeFileList: this.handleChangeFileList,
|
509
|
|
- onUpload: this.handleUpload,
|
510
|
|
- maxUpload: maxUpload,
|
511
|
|
- fileList: uploadFileList,
|
512
|
|
- showError: this.props.showError,
|
513
|
|
- onError: this.props.onError
|
514
|
|
- }),
|
515
|
|
- _react2.default.createElement("div", { className: "clearfix" })
|
516
|
|
- ),
|
517
|
|
- title: _react2.default.createElement(
|
518
|
|
- "div",
|
519
|
|
- { style: { margin: "5px auto" } },
|
520
|
|
- _react2.default.createElement(
|
521
|
|
- "span",
|
522
|
|
- null,
|
523
|
|
- _reactIntlUniversal2.default.get("editor.uploadTip"),
|
524
|
|
- maxUpload >= 2 ? _react2.default.createElement(
|
|
508
|
+ _react2.default.createElement(_Upload2.default, {
|
|
509
|
+ onRef: function onRef(node) {
|
|
510
|
+ return _this4.uploadRef = node;
|
|
511
|
+ },
|
|
512
|
+ multiple: multiple,
|
|
513
|
+ onChangeFileList: this.handleChangeFileList,
|
|
514
|
+ onUpload: this.handleUpload,
|
|
515
|
+ maxUpload: maxUpload,
|
|
516
|
+ fileList: uploadFileList,
|
|
517
|
+ showError: this.props.showError,
|
|
518
|
+ onError: this.props.onError
|
|
519
|
+ }),
|
|
520
|
+ _react2.default.createElement("div", { className: "clearfix" })
|
|
521
|
+ ),
|
|
522
|
+ title: _react2.default.createElement(
|
|
523
|
+ "div",
|
|
524
|
+ { style: { margin: "5px auto" } },
|
|
525
|
+ _react2.default.createElement(
|
525
|
526
|
"span",
|
526
|
|
- { style: { color: "#666", fontWeight: 400 } },
|
527
|
|
- _reactIntlUniversal2.default.get("editor.uploadCount", {
|
528
|
|
- count: maxUpload - uploadFileList.length
|
529
|
|
- })
|
530
|
|
- ) : null
|
|
527
|
+ null,
|
|
528
|
+ _reactIntlUniversal2.default.get("editor.uploadTip"),
|
|
529
|
+ maxUpload >= 2 ? _react2.default.createElement(
|
|
530
|
+ "span",
|
|
531
|
+ { style: { color: "#666", fontWeight: 400 } },
|
|
532
|
+ _reactIntlUniversal2.default.get("editor.uploadCount", {
|
|
533
|
+ count: maxUpload - uploadFileList.length
|
|
534
|
+ })
|
|
535
|
+ ) : null
|
|
536
|
+ )
|
531
|
537
|
)
|
532
|
|
- )
|
533
|
|
- },
|
534
|
|
- imageToolIcon ? _react2.default.cloneElement(imageToolIcon, {
|
535
|
|
- onClick: function onClick() {
|
536
|
|
- return _this4.handleShowUpload(true);
|
537
|
|
- }
|
538
|
|
- }) : _react2.default.createElement(_icon2.default, {
|
539
|
|
- type: "picture",
|
540
|
|
- className: "comment-toolbar-icon",
|
541
|
|
- style: { marginLeft: 20 },
|
542
|
|
- onClick: function onClick() {
|
543
|
|
- return _this4.handleShowUpload(true);
|
544
|
|
- }
|
545
|
|
- })
|
546
|
|
- ) : null
|
547
|
|
- ),
|
548
|
|
- _react2.default.createElement(
|
549
|
|
- "div",
|
550
|
|
- { className: "comment-toolbar-right" },
|
551
|
|
- button ? _react2.default.cloneElement(button, {
|
552
|
|
- onClick: button.props.onClick || handleSubmit
|
553
|
|
- }) : _react2.default.createElement(
|
554
|
|
- _button2.default,
|
555
|
|
- {
|
556
|
|
- onClick: function onClick() {
|
557
|
|
- return _this4.handleSubmit();
|
558
|
538
|
},
|
559
|
|
- type: "primary",
|
560
|
|
- loading: btnLoading,
|
561
|
|
- disabled: disabledSubmit
|
562
|
|
- },
|
563
|
|
- btnSubmitText
|
|
539
|
+ imageToolIcon ? _react2.default.cloneElement(imageToolIcon, {
|
|
540
|
+ onClick: function onClick() {
|
|
541
|
+ return _this4.handleShowUpload(true);
|
|
542
|
+ }
|
|
543
|
+ }) : _react2.default.createElement(_icon2.default, {
|
|
544
|
+ type: "picture",
|
|
545
|
+ className: "comment-toolbar-icon",
|
|
546
|
+ style: { marginLeft: 20 },
|
|
547
|
+ onClick: function onClick() {
|
|
548
|
+ return _this4.handleShowUpload(true);
|
|
549
|
+ }
|
|
550
|
+ })
|
|
551
|
+ ) : null
|
|
552
|
+ ),
|
|
553
|
+ _react2.default.createElement(
|
|
554
|
+ "div",
|
|
555
|
+ { className: "comment-toolbar-right" },
|
|
556
|
+ button ? _react2.default.cloneElement(button, {
|
|
557
|
+ onClick: button.props.onClick || handleSubmit
|
|
558
|
+ }) : _react2.default.createElement(
|
|
559
|
+ _button2.default,
|
|
560
|
+ {
|
|
561
|
+ onClick: function onClick() {
|
|
562
|
+ return _this4.handleSubmit();
|
|
563
|
+ },
|
|
564
|
+ type: "primary",
|
|
565
|
+ loading: btnLoading,
|
|
566
|
+ disabled: disabledSubmit
|
|
567
|
+ },
|
|
568
|
+ btnSubmitText
|
|
569
|
+ )
|
564
|
570
|
)
|
565
|
571
|
)
|
566
|
572
|
)
|
|
573
|
+ ) : _react2.default.createElement(
|
|
574
|
+ _react.Fragment,
|
|
575
|
+ null,
|
|
576
|
+ _react2.default.createElement(
|
|
577
|
+ "div",
|
|
578
|
+ { className: "comment-unlogin-tip" },
|
|
579
|
+ _reactIntlUniversal2.default.get("comment.unlogin")
|
|
580
|
+ ),
|
|
581
|
+ _react2.default.createElement(
|
|
582
|
+ "div",
|
|
583
|
+ { className: "comment-unlogin-button" },
|
|
584
|
+ _react2.default.createElement(
|
|
585
|
+ _button2.default,
|
|
586
|
+ {
|
|
587
|
+ type: "primary",
|
|
588
|
+ onClick: function onClick() {
|
|
589
|
+ window.location.href = app.LOGINLINK + "?f=" + window.location.href;
|
|
590
|
+ }
|
|
591
|
+ },
|
|
592
|
+ _reactIntlUniversal2.default.get("account.login")
|
|
593
|
+ )
|
|
594
|
+ )
|
567
|
595
|
)
|
568
|
596
|
);
|
569
|
597
|
}
|