123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- "use strict";
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
-
- var _button = require("antd/es/button");
-
- var _button2 = _interopRequireDefault(_button);
-
- var _popover = require("antd/es/popover");
-
- var _popover2 = _interopRequireDefault(_popover);
-
- var _icon = require("antd/es/icon");
-
- var _icon2 = _interopRequireDefault(_icon);
-
- var _input = require("antd/es/input");
-
- var _input2 = _interopRequireDefault(_input);
-
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
-
- require("antd/es/button/style/css");
-
- require("antd/es/popover/style/css");
-
- require("antd/es/icon/style/css");
-
- require("antd/es/input/style/css");
-
- var _react = require("react");
-
- var _react2 = _interopRequireDefault(_react);
-
- var _constant = require("../../constant");
-
- var _Upload = require("./Upload");
-
- var _Upload2 = _interopRequireDefault(_Upload);
-
- var _Emoji = require("./Emoji");
-
- var _Emoji2 = _interopRequireDefault(_Emoji);
-
- require("./index.css");
-
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
-
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
-
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // https://github.com/lovasoa/react-contenteditable/blob/master/src/react-contenteditable.js
-
- // import styles from "./index.less";
-
-
- var TextArea = _input2.default.TextArea;
-
- var Editor = function (_React$Component) {
- _inherits(Editor, _React$Component);
-
- function Editor(props) {
- _classCallCheck(this, Editor);
-
- var _this = _possibleConstructorReturn(this, (Editor.__proto__ || Object.getPrototypeOf(Editor)).call(this, props));
-
- _this.state = {
- showUpload: false
- };
- _this.handleClickEmoji = _this.handleClickEmoji.bind(_this);
- _this.handleShowUpload = _this.handleShowUpload.bind(_this);
- return _this;
- }
-
- _createClass(Editor, [{
- key: "componentDidMount",
- value: function componentDidMount() {}
- }, {
- key: "handleClickEmoji",
- value: function handleClickEmoji(emojiId) {
- this.props.onChangeEmoji(emojiId);
- }
- }, {
- key: "handleShowUpload",
- value: function handleShowUpload(showUpload) {
- if (typeof showUpload === "boolean") {
- this.setState({ showUpload: showUpload });
- } else {
- this.setState({ showUpload: !this.state.showUpload });
- }
- }
- }, {
- key: "render",
- value: function render() {
- var _this2 = this;
-
- var _props = this.props,
- value = _props.value,
- onChange = _props.onChange,
- placeholder = _props.placeholder,
- fileList = _props.fileList,
- onChangeFileList = _props.onChangeFileList,
- onUpload = _props.onUpload;
-
- return _react2.default.createElement(
- "div",
- { className: "editor" },
- _react2.default.createElement(TextArea, {
- value: value,
- onChange: onChange,
- rows: 5,
- placeholder: placeholder
- }),
- _react2.default.createElement(
- "div",
- { className: "toolbar" },
- _react2.default.createElement(
- "div",
- { style: { float: "left", margin: "8px 11px" } },
- _react2.default.createElement(
- _popover2.default,
- {
- trigger: "click",
- placement: "bottomLeft",
- autoAdjustOverflow: false,
- content: _react2.default.createElement(
- "div",
- { style: { width: 200 } },
- _react2.default.createElement(_Emoji2.default, { onClick: this.handleClickEmoji })
- ),
- overlayClassName: "feed"
- },
- _react2.default.createElement(_icon2.default, { type: "smile-o", className: "icon" })
- ),
- _react2.default.createElement(
- _popover2.default,
- {
- visible: this.state.showUpload,
- overlayStyle: { zIndex: 999 },
- content: _react2.default.createElement(
- "div",
- { style: { width: 112 * _constant.MAX_UPLOAD_NUMBER, minHeight: 100 } },
- _react2.default.createElement(_Upload2.default, {
- onChangeFileList: onChangeFileList,
- onUpload: onUpload,
- fileList: fileList
- })
- ),
- placement: "bottomLeft",
- title: _react2.default.createElement(
- "div",
- { style: { margin: "5px auto" } },
- _react2.default.createElement(
- "span",
- null,
- "\u4E0A\u4F20\u56FE\u7247",
- _react2.default.createElement(
- "span",
- { style: { color: "#666", fontWeight: 400 } },
- "(\u60A8\u8FD8\u80FD\u4E0A\u4F20",
- _constant.MAX_UPLOAD_NUMBER - fileList.length,
- "\u5F20\u56FE\u7247)"
- )
- ),
- _react2.default.createElement(_icon2.default, {
- type: "close",
- onClick: function onClick() {
- return _this2.handleShowUpload(false);
- },
- style: {
- float: "right",
- cursor: "pointer",
- marginTop: 4
- }
- })
- )
- },
- _react2.default.createElement(_icon2.default, {
- type: "picture",
- className: "icon",
- style: { marginLeft: 10 },
- onClick: function onClick() {
- return _this2.handleShowUpload(true);
- }
- })
- )
- ),
- _react2.default.createElement(
- "div",
- { style: { float: "right", margin: "5px 11px" } },
- _react2.default.createElement(
- _button2.default,
- {
- onClick: this.props.onSubmit,
- type: "primary",
- loading: this.props.loading
- },
- "\u53D1\u8868"
- )
- )
- )
- );
- }
- }]);
-
- return Editor;
- }(_react2.default.Component);
-
- exports.default = Editor;
- //# sourceMappingURL=index.js.map
|