Quellcode durchsuchen

emoji增加到每页30个, 增加鼠标滑动功能

narro vor 6 Jahren
Ursprung
Commit
34a212379b

+ 6
- 0
CHANGELOG.md Datei anzeigen

@@ -1,5 +1,11 @@
1 1
 # CHANGELOG
2 2
 
3
+## 0.5.13
4
+- [x] emoji增加到每页30个
5
+- [x] emoji增加鼠标滑动功能
6
+- [x] 增加图片预览器
7
+- [x] 上传图片每行显示3张
8
+
3 9
 ## 0.5.12
4 10
 - [x] 支持两种模式的分页器
5 11
 - [x] 分页器支持受控模式

+ 1
- 1
README.md Datei anzeigen

@@ -2,7 +2,7 @@
2 2
 
3 3
 通用评论系统及编辑器
4 4
 
5
-**`version 0.5.12`**
5
+**`version 0.5.13`**
6 6
 
7 7
 ```js
8 8
 import Comment, { Editor, RenderText } from 'comment';

+ 57
- 56
lib/components/ContentItem/index.css Datei anzeigen

@@ -1,105 +1,106 @@
1 1
 .comment-item-box {
2
-    margin: 10px 0 0 0;
3
-    padding: 15px 5px 0 5px;
4
-    border-top: 1px solid #eee;
2
+  margin: 10px 0 0 0;
3
+  padding: 15px 5px 0 5px;
4
+  border-top: 1px solid #eee;
5 5
 }
6 6
 
7 7
 .comment-item-left {
8
-    display: inline-block;
9
-    vertical-align: top;
10
-    width: 40px;
8
+  display: inline-block;
9
+  vertical-align: top;
10
+  width: 40px;
11 11
 }
12 12
 
13 13
 .comment-item-right {
14
-    display: inline-block;
15
-    width: 90%;
16
-    margin-left: 10px;
17
-    margin-bottom: 20px;
14
+  display: inline-block;
15
+  width: 90%;
16
+  margin-left: 10px;
17
+  margin-bottom: 20px;
18 18
 }
19 19
 
20 20
 .comment-item-content {
21
-    margin: 10px 0;
22
-    word-break: break-all;
21
+  margin: 10px 0;
22
+  word-break: break-all;
23 23
 }
24 24
 
25 25
 .comment-item-bottom {
26
-    margin: 20px auto;
26
+  margin: 20px auto;
27 27
 }
28 28
 
29 29
 .comment-item-bottom-left {
30
-    float: left;
31
-    user-select: none;
30
+  float: left;
31
+  user-select: none;
32 32
 }
33 33
 
34 34
 .comment-item-bottom-right {
35
-    float: right;
36
-    margin-left: 5px;
37
-    cursor: pointer;
35
+  float: right;
36
+  margin-left: 5px;
37
+  cursor: pointer;
38 38
 }
39 39
 
40 40
 .comment-favor {
41
-    font-size: 20px;
41
+  font-size: 20px;
42 42
 }
43 43
 
44 44
 .comment-favored {
45
-    color: #4a90e2;
45
+  color: #4a90e2;
46 46
 }
47 47
 
48 48
 .comment-item-image {
49
-    width: 400px;
50
-    max-width: 100%;
49
+  width: 400px;
50
+  max-width: 100%;
51 51
 }
52 52
 
53 53
 .comment-item-image .comment-item-image-wrapper {
54
-    float: left;
55
-    width: 25%;
56
-    box-sizing: border-box;
57
-    padding: 5px;
54
+  float: left;
55
+  width: 25%;
56
+  box-sizing: border-box;
57
+  padding: 5px;
58 58
 }
59 59
 
60 60
 .comment-item-image .comment-item-image-wrapper .comment-img-thumbnail {
61
-    background-position: center;
62
-    background-size: cover;
63
-    display: inline-block;
64
-    width: 100%;
65
-    height: 0;
66
-    padding-bottom: 100%;
67
-    border-radius: 5px;
68
-    cursor: url('//links-comment.oss-cn-beijing.aliyuncs.com/comment/20180928/QPI84fxmD.undefined'), auto;
61
+  background-position: center;
62
+  background-size: cover;
63
+  display: inline-block;
64
+  width: 100%;
65
+  height: 0;
66
+  padding-bottom: 100%;
67
+  border-radius: 5px;
68
+  cursor: url("//links-comment.oss-cn-beijing.aliyuncs.com/comment/20180928/QPI84fxmD.undefined"),
69
+    auto;
69 70
 }
70 71
 
71 72
 .comment-item-image .comment-item-image-wrapper .comment-img-divider {
72
-    display: inline-block;
73
-    width: 100%;
74
-    height: 0;
75
-    padding-bottom: 100%;
76
-    border-radius: 5px;
73
+  display: inline-block;
74
+  width: 100%;
75
+  height: 0;
76
+  padding-bottom: 100%;
77
+  border-radius: 5px;
77 78
 }
78 79
 
79 80
 .comment-item-image .comment-img {
80
-    margin-right: 10px;
81
+  margin-right: 10px;
81 82
 }
82 83
 
83 84
 @media screen and (max-width: 616px) and (min-width: 449px) {
84
-    .comment-item-right {
85
-        display: inline-block;
86
-        width: 85%;
87
-        margin-left: 10px;
88
-    }
85
+  .comment-item-right {
86
+    display: inline-block;
87
+    width: 85%;
88
+    margin-left: 10px;
89
+  }
89 90
 }
90 91
 
91 92
 @media screen and (max-width: 449px) and (min-width: 365px) {
92
-    .comment-item-right {
93
-        display: inline-block;
94
-        width: 80%;
95
-        margin-left: 10px;
96
-    }
93
+  .comment-item-right {
94
+    display: inline-block;
95
+    width: 80%;
96
+    margin-left: 10px;
97
+  }
97 98
 }
98 99
 
99 100
 @media screen and (max-width: 365px) {
100
-    .comment-item-right {
101
-        display: inline-block;
102
-        width: 75%;
103
-        margin-left: 10px;
104
-    }
105
-}
101
+  .comment-item-right {
102
+    display: inline-block;
103
+    width: 75%;
104
+    margin-left: 10px;
105
+  }
106
+}

+ 9
- 9
lib/components/ContentItem/index.js Datei anzeigen

@@ -177,10 +177,10 @@ var CommentItem = function (_Component) {
177 177
       var imgs = [].concat(_toConsumableArray(imageList));
178 178
       if (needClear) {
179 179
         if (imgs.length > 6) {
180
-          imgs.splice(3, 0, { type: 'divider' });
181
-          imgs.splice(7, 0, { type: 'divider' });
180
+          imgs.splice(3, 0, { type: "divider" });
181
+          imgs.splice(7, 0, { type: "divider" });
182 182
         } else {
183
-          imgs.splice(3, 0, { type: 'divider' });
183
+          imgs.splice(3, 0, { type: "divider" });
184 184
         }
185 185
       }
186 186
 
@@ -227,13 +227,10 @@ var CommentItem = function (_Component) {
227 227
             "div",
228 228
             { className: "comment-item-image" },
229 229
             !this.state.showPreviewer && imgs.map(function (item, index) {
230
-              if (item.type === 'divider') {
230
+              if (item.type === "divider") {
231 231
                 return _react2.default.createElement(
232 232
                   "div",
233
-                  {
234
-                    className: "comment-item-image-wrapper",
235
-                    key: index
236
-                  },
233
+                  { className: "comment-item-image-wrapper", key: index },
237 234
                   _react2.default.createElement("div", { className: "comment-img-divider" })
238 235
                 );
239 236
               }
@@ -255,7 +252,10 @@ var CommentItem = function (_Component) {
255 252
                     _this2.showPreviewer(i);
256 253
                   }
257 254
                 },
258
-                _react2.default.createElement("div", { style: { backgroundImage: "url(" + item + ")" }, className: "comment-img-thumbnail" })
255
+                _react2.default.createElement("div", {
256
+                  style: { backgroundImage: "url(" + item + ")" },
257
+                  className: "comment-img-thumbnail"
258
+                })
259 259
               );
260 260
             }),
261 261
             this.state.showPreviewer && _react2.default.createElement(_ImagePreviewer2.default, {

+ 1
- 1
lib/components/ContentItem/index.js.map
Datei-Diff unterdrückt, da er zu groß ist
Datei anzeigen


+ 75
- 34
lib/components/Editor/Emoji.js Datei anzeigen

@@ -8,6 +8,8 @@ var _carousel = require("antd/es/carousel");
8 8
 
9 9
 var _carousel2 = _interopRequireDefault(_carousel);
10 10
 
11
+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; }; }();
12
+
11 13
 require("antd/es/carousel/style/css");
12 14
 
13 15
 var _react = require("react");
@@ -22,53 +24,92 @@ require("./Emoji.css");
22 24
 
23 25
 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24 26
 
27
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
28
+
29
+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; }
30
+
31
+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; }
32
+
25 33
 // 每页 20  5*4
26 34
 // 共 20 * 3 = 60 (实际是 54)
27 35
 
28 36
 // class Emoji
29 37
 
30
-var Emoji = function Emoji(_ref) {
31
-  var _onClick = _ref.onClick;
32
-
33
-  var content = [];
34
-  var curPage = [];
35
-  for (var i = 0; i < 115; i++) {
36
-    if (curPage.length < 20) {
37
-      curPage.push(_emoji2.default[i]);
38
-    } else {
39
-      content.push(curPage);
40
-      curPage = [];
41
-    }
42
-  }
43
-  if (curPage.length > 0) {
44
-    content.push(curPage);
38
+var Emoji = function (_React$Component) {
39
+  _inherits(Emoji, _React$Component);
40
+
41
+  function Emoji() {
42
+    _classCallCheck(this, Emoji);
43
+
44
+    return _possibleConstructorReturn(this, (Emoji.__proto__ || Object.getPrototypeOf(Emoji)).apply(this, arguments));
45 45
   }
46
-  return _react2.default.createElement(
47
-    _carousel2.default,
48
-    null,
49
-    content.map(function (page, index) {
46
+
47
+  _createClass(Emoji, [{
48
+    key: "next",
49
+    value: function next() {
50
+      if (this.carousel) {
51
+        this.carousel.next();
52
+      }
53
+    }
54
+  }, {
55
+    key: "prev",
56
+    value: function prev() {
57
+      if (this.carousel) {
58
+        this.carousel.prev();
59
+      }
60
+    }
61
+  }, {
62
+    key: "render",
63
+    value: function render() {
64
+      var _this2 = this;
65
+
66
+      var _onClick = this.props.onClick;
67
+
68
+      var content = [];
69
+      var curPage = [];
70
+      for (var i = 0; i < 115; i++) {
71
+        if (curPage.length < 30) {
72
+          curPage.push(_emoji2.default[i]);
73
+        } else {
74
+          content.push(curPage);
75
+          curPage = [];
76
+        }
77
+      }
78
+      if (curPage.length > 0) {
79
+        content.push(curPage);
80
+      }
50 81
       return _react2.default.createElement(
51
-        "div",
52
-        { key: index, className: "emoji" },
53
-        page.map(function (item, index) {
82
+        _carousel2.default,
83
+        { ref: function ref(node) {
84
+            _this2.carousel = node;
85
+          } },
86
+        content.map(function (page, index) {
54 87
           return _react2.default.createElement(
55 88
             "div",
56
-            { className: "item", key: item.value },
57
-            _react2.default.createElement("span", { className: "helper" }),
58
-            _react2.default.createElement("img", {
59
-              src: "" + _emoji.prefixUrl + item.value + "." + item.ext,
60
-              alt: item.title,
61
-              style: { display: "inline-block" },
62
-              onClick: function onClick() {
63
-                return _onClick(item.title);
64
-              }
89
+            { key: index, className: "emoji" },
90
+            page.map(function (item, index) {
91
+              return _react2.default.createElement(
92
+                "div",
93
+                { className: "item", key: item.value },
94
+                _react2.default.createElement("span", { className: "helper" }),
95
+                _react2.default.createElement("img", {
96
+                  src: "" + _emoji.prefixUrl + item.value + "." + item.ext,
97
+                  alt: item.title,
98
+                  style: { display: "inline-block" },
99
+                  onClick: function onClick() {
100
+                    return _onClick(item.title);
101
+                  }
102
+                })
103
+              );
65 104
             })
66 105
           );
67 106
         })
68 107
       );
69
-    })
70
-  );
71
-};
108
+    }
109
+  }]);
110
+
111
+  return Emoji;
112
+}(_react2.default.Component);
72 113
 
73 114
 exports.default = Emoji;
74 115
 //# sourceMappingURL=Emoji.js.map

+ 1
- 1
lib/components/Editor/Emoji.js.map Datei anzeigen

@@ -1 +1 @@
1
-{"version":3,"sources":["../../../src/components/Editor/Emoji.js"],"names":["Emoji","onClick","content","curPage","i","length","push","emoji","map","page","index","item","value","prefixUrl","ext","title","display"],"mappings":";;;;;;;;;;;;AAAA;;;;AAEA;;;;AACA;;;;AACA;AACA;;AAEA;;AAEA,IAAMA,QAAQ,SAARA,KAAQ,OAAiB;AAAA,MAAdC,QAAc,QAAdA,OAAc;;AAC7B,MAAMC,UAAU,EAAhB;AACA,MAAIC,UAAU,EAAd;AACA,OAAK,IAAIC,IAAI,CAAb,EAAgBA,IAAI,GAApB,EAAyBA,GAAzB,EAA8B;AAC5B,QAAID,QAAQE,MAAR,GAAiB,EAArB,EAAyB;AACvBF,cAAQG,IAAR,CAAaC,gBAAMH,CAAN,CAAb;AACD,KAFD,MAEO;AACLF,cAAQI,IAAR,CAAaH,OAAb;AACAA,gBAAU,EAAV;AACD;AACF;AACD,MAAIA,QAAQE,MAAR,GAAiB,CAArB,EAAwB;AACtBH,YAAQI,IAAR,CAAaH,OAAb;AACD;AACD,SACE;AAAA;AAAA;AACGD,YAAQM,GAAR,CAAY,UAACC,IAAD,EAAOC,KAAP;AAAA,aACX;AAAA;AAAA,UAAK,KAAKA,KAAV,EAAiB,WAAU,OAA3B;AACGD,aAAKD,GAAL,CAAS,UAACG,IAAD,EAAOD,KAAP;AAAA,iBACR;AAAA;AAAA,cAAK,WAAU,MAAf,EAAsB,KAAKC,KAAKC,KAAhC;AACE,oDAAM,WAAU,QAAhB,GADF;AAEE;AACE,wBAAQC,gBAAR,GAAoBF,KAAKC,KAAzB,SAAkCD,KAAKG,GADzC;AAEE,mBAAKH,KAAKI,KAFZ;AAGE,qBAAO,EAAEC,SAAS,cAAX,EAHT;AAIE,uBAAS;AAAA,uBAAMf,SAAQU,KAAKI,KAAb,CAAN;AAAA;AAJX;AAFF,WADQ;AAAA,SAAT;AADH,OADW;AAAA,KAAZ;AADH,GADF;AAmBD,CAjCD;;kBAmCef,K","file":"Emoji.js","sourcesContent":["import React from \"react\";\r\nimport { Carousel } from \"antd\";\r\nimport emoji, { prefixUrl } from \"../../emoji\";\r\nimport \"./Emoji.css\";\r\n// 每页 20  5*4\r\n// 共 20 * 3 = 60 (实际是 54)\r\n\r\n// class Emoji\r\n\r\nconst Emoji = ({ onClick }) => {\r\n  const content = [];\r\n  let curPage = [];\r\n  for (let i = 0; i < 115; i++) {\r\n    if (curPage.length < 20) {\r\n      curPage.push(emoji[i]);\r\n    } else {\r\n      content.push(curPage);\r\n      curPage = [];\r\n    }\r\n  }\r\n  if (curPage.length > 0) {\r\n    content.push(curPage);\r\n  }\r\n  return (\r\n    <Carousel>\r\n      {content.map((page, index) => (\r\n        <div key={index} className=\"emoji\">\r\n          {page.map((item, index) => (\r\n            <div className=\"item\" key={item.value}>\r\n              <span className=\"helper\" />\r\n              <img\r\n                src={`${prefixUrl}${item.value}.${item.ext}`}\r\n                alt={item.title}\r\n                style={{ display: \"inline-block\" }}\r\n                onClick={() => onClick(item.title)}\r\n              />\r\n            </div>\r\n          ))}\r\n        </div>\r\n      ))}\r\n    </Carousel>\r\n  );\r\n};\r\n\r\nexport default Emoji;\r\n"]}
1
+{"version":3,"sources":["../../../src/components/Editor/Emoji.js"],"names":["Emoji","carousel","next","prev","onClick","props","content","curPage","i","length","push","emoji","node","map","page","index","item","value","prefixUrl","ext","title","display","React","Component"],"mappings":";;;;;;;;;;;;;;AAAA;;;;AAEA;;;;AACA;;;;;;;;;;AACA;AACA;;AAEA;;IAEMA,K;;;;;;;;;;;2BAEG;AACL,UAAI,KAAKC,QAAT,EAAmB;AACjB,aAAKA,QAAL,CAAcC,IAAd;AACD;AACF;;;2BAEM;AACL,UAAI,KAAKD,QAAT,EAAmB;AACjB,aAAKA,QAAL,CAAcE,IAAd;AACD;AACF;;;6BAEQ;AAAA;;AAAA,UACCC,QADD,GACa,KAAKC,KADlB,CACCD,OADD;;AAEP,UAAME,UAAU,EAAhB;AACA,UAAIC,UAAU,EAAd;AACA,WAAK,IAAIC,IAAI,CAAb,EAAgBA,IAAI,GAApB,EAAyBA,GAAzB,EAA8B;AAC5B,YAAID,QAAQE,MAAR,GAAiB,EAArB,EAAyB;AACvBF,kBAAQG,IAAR,CAAaC,gBAAMH,CAAN,CAAb;AACD,SAFD,MAEO;AACLF,kBAAQI,IAAR,CAAaH,OAAb;AACAA,oBAAU,EAAV;AACD;AACF;AACD,UAAIA,QAAQE,MAAR,GAAiB,CAArB,EAAwB;AACtBH,gBAAQI,IAAR,CAAaH,OAAb;AACD;AACD,aACE;AAAA;AAAA,UAAU,KAAK,aAACK,IAAD,EAAU;AAAE,mBAAKX,QAAL,GAAgBW,IAAhB;AAAuB,WAAlD;AACGN,gBAAQO,GAAR,CAAY,UAACC,IAAD,EAAOC,KAAP;AAAA,iBACX;AAAA;AAAA,cAAK,KAAKA,KAAV,EAAiB,WAAU,OAA3B;AACGD,iBAAKD,GAAL,CAAS,UAACG,IAAD,EAAOD,KAAP;AAAA,qBACR;AAAA;AAAA,kBAAK,WAAU,MAAf,EAAsB,KAAKC,KAAKC,KAAhC;AACE,wDAAM,WAAU,QAAhB,GADF;AAEE;AACE,4BAAQC,gBAAR,GAAoBF,KAAKC,KAAzB,SAAkCD,KAAKG,GADzC;AAEE,uBAAKH,KAAKI,KAFZ;AAGE,yBAAO,EAAEC,SAAS,cAAX,EAHT;AAIE,2BAAS;AAAA,2BAAMjB,SAAQY,KAAKI,KAAb,CAAN;AAAA;AAJX;AAFF,eADQ;AAAA,aAAT;AADH,WADW;AAAA,SAAZ;AADH,OADF;AAmBD;;;;EAhDiBE,gBAAMC,S;;kBAmDXvB,K","file":"Emoji.js","sourcesContent":["import React from \"react\";\r\nimport { Carousel } from \"antd\";\r\nimport emoji, { prefixUrl } from \"../../emoji\";\r\nimport \"./Emoji.css\";\r\n// 每页 20  5*4\r\n// 共 20 * 3 = 60 (实际是 54)\r\n\r\n// class Emoji\r\n\r\nclass Emoji extends React.Component {\r\n\r\n  next() {\r\n    if (this.carousel) {\r\n      this.carousel.next();\r\n    }\r\n  }\r\n\r\n  prev() {\r\n    if (this.carousel) {\r\n      this.carousel.prev();\r\n    }\r\n  }\r\n\r\n  render() {\r\n    const { onClick } = this.props;\r\n    const content = [];\r\n    let curPage = [];\r\n    for (let i = 0; i < 115; i++) {\r\n      if (curPage.length < 30) {\r\n        curPage.push(emoji[i]);\r\n      } else {\r\n        content.push(curPage);\r\n        curPage = [];\r\n      }\r\n    }\r\n    if (curPage.length > 0) {\r\n      content.push(curPage);\r\n    }\r\n    return (\r\n      <Carousel ref={(node) => { this.carousel = node; }}>\r\n        {content.map((page, index) => (\r\n          <div key={index} className=\"emoji\">\r\n            {page.map((item, index) => (\r\n              <div className=\"item\" key={item.value}>\r\n                <span className=\"helper\" />\r\n                <img\r\n                  src={`${prefixUrl}${item.value}.${item.ext}`}\r\n                  alt={item.title}\r\n                  style={{ display: \"inline-block\" }}\r\n                  onClick={() => onClick(item.title)}\r\n                />\r\n              </div>\r\n            ))}\r\n          </div>\r\n        ))}\r\n      </Carousel>\r\n    );\r\n  };\r\n}\r\n\r\nexport default Emoji;\r\n"]}

+ 18
- 2
lib/components/Editor/index.js Datei anzeigen

@@ -94,6 +94,7 @@ var Editor = function (_React$Component) {
94 94
     _this.handleUpload = _this.handleUpload.bind(_this);
95 95
     _this.handleSubmit = _this.handleSubmit.bind(_this);
96 96
     _this.resetState = _this.resetState.bind(_this);
97
+    _this.handleEmojiScroll = _this.handleEmojiScroll.bind(_this);
97 98
     return _this;
98 99
   }
99 100
 
@@ -104,6 +105,19 @@ var Editor = function (_React$Component) {
104 105
         this.props.onRef(this);
105 106
       }
106 107
     }
108
+  }, {
109
+    key: "handleEmojiScroll",
110
+    value: function handleEmojiScroll(e) {
111
+      if (!this.emoji) {
112
+        return;
113
+      }
114
+      e.preventDefault();
115
+      if (e.deltaY > 0) {
116
+        this.emoji.next();
117
+      } else if (e.deltaY < 0) {
118
+        this.emoji.prev();
119
+      }
120
+    }
107 121
 
108 122
     /**
109 123
      * 编辑器的值改变事件
@@ -314,8 +328,10 @@ var Editor = function (_React$Component) {
314 328
                   autoAdjustOverflow: false,
315 329
                   content: _react2.default.createElement(
316 330
                     "div",
317
-                    { style: { width: 200 } },
318
-                    _react2.default.createElement(_Emoji2.default, { onClick: this.handleClickEmoji })
331
+                    { style: { width: 240 }, onWheel: this.handleEmojiScroll },
332
+                    _react2.default.createElement(_Emoji2.default, { onClick: this.handleClickEmoji, ref: function ref(node) {
333
+                        _this3.emoji = node;
334
+                      } })
319 335
                   ),
320 336
                   overlayClassName: "comment-emoji-popover"
321 337
                 },

+ 1
- 1
lib/components/Editor/index.js.map
Datei-Diff unterdrückt, da er zu groß ist
Datei anzeigen


+ 6
- 3
lib/components/ImagePreviewer/ImagePreviewer.css Datei anzeigen

@@ -29,13 +29,16 @@
29 29
   height: 100%;
30 30
 }
31 31
 .container .pictureWrapper .tools .item.left {
32
-  cursor: url('//links-comment.oss-cn-beijing.aliyuncs.com/comment/20180928/73_yM_fx-.undefined'), auto;
32
+  cursor: url("//links-comment.oss-cn-beijing.aliyuncs.com/comment/20180928/73_yM_fx-.undefined"),
33
+    auto;
33 34
 }
34 35
 .container .pictureWrapper .tools .item.shrink {
35
-  cursor: url('//links-comment.oss-cn-beijing.aliyuncs.com/comment/20180928/oGPpbJ7Rk.undefined'), auto;
36
+  cursor: url("//links-comment.oss-cn-beijing.aliyuncs.com/comment/20180928/oGPpbJ7Rk.undefined"),
37
+    auto;
36 38
 }
37 39
 .container .pictureWrapper .tools .item.right {
38
-  cursor: url('//links-comment.oss-cn-beijing.aliyuncs.com/comment/20180928/S8obecP1d.undefined'), auto;
40
+  cursor: url("//links-comment.oss-cn-beijing.aliyuncs.com/comment/20180928/S8obecP1d.undefined"),
41
+    auto;
39 42
 }
40 43
 .container .pictureWrapper .picture {
41 44
   max-width: 100%;

+ 203
- 203
lib/components/ImagePreviewer/ImagePreviewer.js Datei anzeigen

@@ -1,34 +1,34 @@
1
-'use strict';
1
+"use strict";
2 2
 
3 3
 Object.defineProperty(exports, "__esModule", {
4
-    value: true
4
+  value: true
5 5
 });
6 6
 
7
-var _spin = require('antd/es/spin');
7
+var _spin = require("antd/es/spin");
8 8
 
9 9
 var _spin2 = _interopRequireDefault(_spin);
10 10
 
11
-var _icon = require('antd/es/icon');
11
+var _icon = require("antd/es/icon");
12 12
 
13 13
 var _icon2 = _interopRequireDefault(_icon);
14 14
 
15 15
 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; }; }();
16 16
 
17
-require('antd/es/spin/style/css');
17
+require("antd/es/spin/style/css");
18 18
 
19
-require('antd/es/icon/style/css');
19
+require("antd/es/icon/style/css");
20 20
 
21
-var _react = require('react');
21
+var _react = require("react");
22 22
 
23 23
 var _react2 = _interopRequireDefault(_react);
24 24
 
25
-var _classnames = require('classnames');
25
+var _classnames = require("classnames");
26 26
 
27 27
 var _classnames2 = _interopRequireDefault(_classnames);
28 28
 
29
-require('./ImagePreviewer.css');
29
+require("./ImagePreviewer.css");
30 30
 
31
-var _helper = require('../../helper');
31
+var _helper = require("../../helper");
32 32
 
33 33
 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
34 34
 
@@ -39,204 +39,204 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
39 39
 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; }
40 40
 
41 41
 var ImagePreviewer = function (_React$Component) {
42
-    _inherits(ImagePreviewer, _React$Component);
43
-
44
-    function ImagePreviewer(props) {
45
-        _classCallCheck(this, ImagePreviewer);
46
-
47
-        var _this = _possibleConstructorReturn(this, (ImagePreviewer.__proto__ || Object.getPrototypeOf(ImagePreviewer)).call(this, props));
48
-
49
-        _this.setIndex = _this.setIndex.bind(_this);
50
-        _this.onPrev = _this.onPrev.bind(_this);
51
-        _this.onNext = _this.onNext.bind(_this);
52
-        _this.onOrigin = _this.onOrigin.bind(_this);
53
-        _this.rotateLeft = _this.rotateLeft.bind(_this);
54
-        _this.rotateRight = _this.rotateRight.bind(_this);
55
-        _this.onImgLoad = _this.onImgLoad.bind(_this);
56
-        _this.onImageError = _this.onImageError.bind(_this);
57
-        _this.state = {
58
-            cIndex: props.index,
59
-            direction: 0, // 0- 0deg 1- 90deg 2- 180deg 3- 270deg
60
-            loading: false
61
-        };
62
-        return _this;
42
+  _inherits(ImagePreviewer, _React$Component);
43
+
44
+  function ImagePreviewer(props) {
45
+    _classCallCheck(this, ImagePreviewer);
46
+
47
+    var _this = _possibleConstructorReturn(this, (ImagePreviewer.__proto__ || Object.getPrototypeOf(ImagePreviewer)).call(this, props));
48
+
49
+    _this.setIndex = _this.setIndex.bind(_this);
50
+    _this.onPrev = _this.onPrev.bind(_this);
51
+    _this.onNext = _this.onNext.bind(_this);
52
+    _this.onOrigin = _this.onOrigin.bind(_this);
53
+    _this.rotateLeft = _this.rotateLeft.bind(_this);
54
+    _this.rotateRight = _this.rotateRight.bind(_this);
55
+    _this.onImgLoad = _this.onImgLoad.bind(_this);
56
+    _this.onImageError = _this.onImageError.bind(_this);
57
+    _this.state = {
58
+      cIndex: props.index,
59
+      direction: 0, // 0- 0deg 1- 90deg 2- 180deg 3- 270deg
60
+      loading: false
61
+    };
62
+    return _this;
63
+  }
64
+
65
+  _createClass(ImagePreviewer, [{
66
+    key: "componentWillReceiveProps",
67
+    value: function componentWillReceiveProps(nextProps) {
68
+      if (nextProps.index !== this.props.index) {
69
+        this.setIndex(nextProps.index);
70
+      }
71
+    }
72
+  }, {
73
+    key: "onPrev",
74
+    value: function onPrev() {
75
+      var prev = this.state.cIndex === 0 ? this.props.list.length - 1 : this.state.cIndex - 1;
76
+      this.setIndex(prev);
77
+    }
78
+  }, {
79
+    key: "onNext",
80
+    value: function onNext() {
81
+      var next = this.state.cIndex === this.props.list.length - 1 ? 0 : this.state.cIndex + 1;
82
+      this.setIndex(next);
83
+    }
84
+  }, {
85
+    key: "onOrigin",
86
+    value: function onOrigin() {
87
+      window.open(this.props.list[this.state.cIndex]);
88
+    }
89
+  }, {
90
+    key: "onImgLoad",
91
+    value: function onImgLoad() {
92
+      this.setState({
93
+        loading: false
94
+      });
95
+    }
96
+  }, {
97
+    key: "onImageError",
98
+    value: function onImageError() {
99
+      this.setState({
100
+        loading: false
101
+      });
102
+    }
103
+  }, {
104
+    key: "setIndex",
105
+    value: function setIndex(index) {
106
+      this.setState({
107
+        cIndex: index,
108
+        direction: 0,
109
+        loading: true
110
+      });
111
+    }
112
+  }, {
113
+    key: "rotateLeft",
114
+    value: function rotateLeft() {
115
+      var direction = this.state.direction - 1;
116
+      if (direction === -1) {
117
+        direction = 3;
118
+      }
119
+      this.setState({
120
+        direction: direction
121
+      });
122
+    }
123
+  }, {
124
+    key: "rotateRight",
125
+    value: function rotateRight() {
126
+      var direction = this.state.direction + 1;
127
+      if (direction === 4) {
128
+        direction = 0;
129
+      }
130
+      this.setState({
131
+        direction: direction
132
+      });
63 133
     }
64 134
 
65
-    _createClass(ImagePreviewer, [{
66
-        key: 'componentWillReceiveProps',
67
-        value: function componentWillReceiveProps(nextProps) {
68
-            if (nextProps.index !== this.props.index) {
69
-                this.setIndex(nextProps.index);
70
-            }
71
-        }
72
-    }, {
73
-        key: 'onPrev',
74
-        value: function onPrev() {
75
-            var prev = this.state.cIndex === 0 ? this.props.list.length - 1 : this.state.cIndex - 1;
76
-            this.setIndex(prev);
77
-        }
78
-    }, {
79
-        key: 'onNext',
80
-        value: function onNext() {
81
-            var next = this.state.cIndex === this.props.list.length - 1 ? 0 : this.state.cIndex + 1;
82
-            this.setIndex(next);
83
-        }
84
-    }, {
85
-        key: 'onOrigin',
86
-        value: function onOrigin() {
87
-            window.open(this.props.list[this.state.cIndex]);
88
-        }
89
-    }, {
90
-        key: 'onImgLoad',
91
-        value: function onImgLoad() {
92
-            this.setState({
93
-                loading: false
94
-            });
95
-        }
96
-    }, {
97
-        key: 'onImageError',
98
-        value: function onImageError() {
99
-            this.setState({
100
-                loading: false
101
-            });
102
-        }
103
-    }, {
104
-        key: 'setIndex',
105
-        value: function setIndex(index) {
106
-            this.setState({
107
-                cIndex: index,
108
-                direction: 0,
109
-                loading: true
110
-            });
111
-        }
112
-    }, {
113
-        key: 'rotateLeft',
114
-        value: function rotateLeft() {
115
-            var direction = this.state.direction - 1;
116
-            if (direction === -1) {
117
-                direction = 3;
118
-            }
119
-            this.setState({
120
-                direction: direction
121
-            });
122
-        }
123
-    }, {
124
-        key: 'rotateRight',
125
-        value: function rotateRight() {
126
-            var direction = this.state.direction + 1;
127
-            if (direction === 4) {
128
-                direction = 0;
129
-            }
130
-            this.setState({
131
-                direction: direction
132
-            });
133
-        }
134
-
135
-        // calcHeight(node) {
136
-        //     const { naturalHeight, naturalWidth } = node;
137
-        // }
138
-
139
-    }, {
140
-        key: 'render',
141
-        value: function render() {
142
-            var _this2 = this;
143
-
144
-            var _props = this.props,
145
-                list = _props.list,
146
-                onFold = _props.onFold;
147
-            var cIndex = this.state.cIndex;
148
-
135
+    // calcHeight(node) {
136
+    //     const { naturalHeight, naturalWidth } = node;
137
+    // }
138
+
139
+  }, {
140
+    key: "render",
141
+    value: function render() {
142
+      var _this2 = this;
143
+
144
+      var _props = this.props,
145
+          list = _props.list,
146
+          onFold = _props.onFold;
147
+      var cIndex = this.state.cIndex;
148
+
149
+      return _react2.default.createElement(
150
+        "div",
151
+        { className: "container" },
152
+        _react2.default.createElement(
153
+          "div",
154
+          { className: "toolbar" },
155
+          _react2.default.createElement(
156
+            "span",
157
+            { className: "button", onClick: onFold },
158
+            _react2.default.createElement(_icon2.default, { type: "to-top" }),
159
+            "\u6536\u8D77"
160
+          ),
161
+          _react2.default.createElement(
162
+            "span",
163
+            { className: "button", onClick: this.onOrigin },
164
+            _react2.default.createElement(_icon2.default, { type: "search" }),
165
+            " \u67E5\u770B\u539F\u56FE"
166
+          )
167
+        ),
168
+        _react2.default.createElement(
169
+          "div",
170
+          { className: "pictureWrapper" },
171
+          _react2.default.createElement(
172
+            _spin2.default,
173
+            { spinning: this.state.loading },
174
+            _react2.default.createElement("img", {
175
+              // ref={node => {
176
+              //     if (node) {
177
+              //         this.calcHeight(node);
178
+              //     }
179
+              // }}
180
+              className: "picture",
181
+              src: (0, _helper.addImageProcess)(list[cIndex], { large: true }),
182
+              alt: list[cIndex],
183
+              style: {
184
+                transform: "rotate(" + this.state.direction * 90 + "deg)",
185
+                opacity: this.state.loading ? 0 : 1,
186
+                transition: "0.3s opacity"
187
+              },
188
+              onLoad: this.onImgLoad,
189
+              onError: this.onImageError
190
+            })
191
+          ),
192
+          _react2.default.createElement(
193
+            "div",
194
+            { className: "tools" },
195
+            list.length > 1 && _react2.default.createElement("div", {
196
+              onClick: this.onPrev,
197
+              className: (0, _classnames2.default)("item", "left")
198
+            }),
199
+            _react2.default.createElement("div", { onClick: onFold, className: (0, _classnames2.default)("item", "shrink") }),
200
+            list.length > 1 && _react2.default.createElement("div", {
201
+              onClick: this.onNext,
202
+              className: (0, _classnames2.default)("item", "right")
203
+            })
204
+          )
205
+        ),
206
+        list.length > 1 && _react2.default.createElement(
207
+          "div",
208
+          { className: "list" },
209
+          list.map(function (item, index) {
149 210
             return _react2.default.createElement(
150
-                'div',
151
-                { className: 'container' },
152
-                _react2.default.createElement(
153
-                    'div',
154
-                    { className: 'toolbar' },
155
-                    _react2.default.createElement(
156
-                        'span',
157
-                        { className: 'button', onClick: onFold },
158
-                        _react2.default.createElement(_icon2.default, { type: 'to-top' }),
159
-                        '\u6536\u8D77'
160
-                    ),
161
-                    _react2.default.createElement(
162
-                        'span',
163
-                        { className: 'button', onClick: this.onOrigin },
164
-                        _react2.default.createElement(_icon2.default, { type: 'search' }),
165
-                        ' \u67E5\u770B\u539F\u56FE'
166
-                    )
167
-                ),
168
-                _react2.default.createElement(
169
-                    'div',
170
-                    { className: 'pictureWrapper' },
171
-                    _react2.default.createElement(
172
-                        _spin2.default,
173
-                        { spinning: this.state.loading },
174
-                        _react2.default.createElement('img', {
175
-                            // ref={node => {
176
-                            //     if (node) {
177
-                            //         this.calcHeight(node);
178
-                            //     }
179
-                            // }}
180
-                            className: 'picture',
181
-                            src: (0, _helper.addImageProcess)(list[cIndex], { large: true }),
182
-                            alt: list[cIndex],
183
-                            style: {
184
-                                transform: 'rotate(' + this.state.direction * 90 + 'deg)',
185
-                                opacity: this.state.loading ? 0 : 1,
186
-                                transition: '0.3s opacity'
187
-                            },
188
-                            onLoad: this.onImgLoad,
189
-                            onError: this.onImageError
190
-                        })
191
-                    ),
192
-                    _react2.default.createElement(
193
-                        'div',
194
-                        { className: 'tools' },
195
-                        list.length > 1 && _react2.default.createElement('div', {
196
-                            onClick: this.onPrev,
197
-                            className: (0, _classnames2.default)("item", "left")
198
-                        }),
199
-                        _react2.default.createElement('div', { onClick: onFold, className: (0, _classnames2.default)("item", "shrink") }),
200
-                        list.length > 1 && _react2.default.createElement('div', {
201
-                            onClick: this.onNext,
202
-                            className: (0, _classnames2.default)("item", "right")
203
-                        })
204
-                    )
205
-                ),
206
-                list.length > 1 && _react2.default.createElement(
207
-                    'div',
208
-                    { className: 'list' },
209
-                    list.map(function (item, index) {
210
-                        return _react2.default.createElement(
211
-                            'div',
212
-                            {
213
-                                className: (0, _classnames2.default)({
214
-                                    "wrapper": true,
215
-                                    "active": index === cIndex
216
-                                }),
217
-                                key: item
218
-                            },
219
-                            _react2.default.createElement('div', {
220
-                                className: (0, _classnames2.default)({
221
-                                    "thumbnail": true
222
-                                }),
223
-                                style: {
224
-                                    backgroundImage: 'url(' + (0, _helper.addImageProcess)(item, {
225
-                                        small: true
226
-                                    }) + ')'
227
-                                },
228
-                                onClick: function onClick() {
229
-                                    _this2.setIndex(index);
230
-                                }
231
-                            })
232
-                        );
233
-                    })
234
-                )
211
+              "div",
212
+              {
213
+                className: (0, _classnames2.default)({
214
+                  wrapper: true,
215
+                  active: index === cIndex
216
+                }),
217
+                key: item
218
+              },
219
+              _react2.default.createElement("div", {
220
+                className: (0, _classnames2.default)({
221
+                  thumbnail: true
222
+                }),
223
+                style: {
224
+                  backgroundImage: "url(" + (0, _helper.addImageProcess)(item, {
225
+                    small: true
226
+                  }) + ")"
227
+                },
228
+                onClick: function onClick() {
229
+                  _this2.setIndex(index);
230
+                }
231
+              })
235 232
             );
236
-        }
237
-    }]);
233
+          })
234
+        )
235
+      );
236
+    }
237
+  }]);
238 238
 
239
-    return ImagePreviewer;
239
+  return ImagePreviewer;
240 240
 }(_react2.default.Component);
241 241
 
242 242
 exports.default = ImagePreviewer;

+ 1
- 1
lib/components/ImagePreviewer/ImagePreviewer.js.map
Datei-Diff unterdrückt, da er zu groß ist
Datei anzeigen


+ 109
- 106
lib/components/ImagePreviewer/ImagePreviewer.less Datei anzeigen

@@ -1,114 +1,117 @@
1 1
 .container {
2
-    .toolbar {
3
-        border-bottom: 1px solid #f2f2f2;
4
-        margin: 0 5px;
5
-        padding-bottom: 10px;
6
-        .button {
7
-            padding: 5px 10px;
8
-            cursor: pointer;
9
-            &.reversal i {
10
-                transform: rotate3d(0, 1, 0, 180deg);
11
-            }
12
-        }
2
+  .toolbar {
3
+    border-bottom: 1px solid #f2f2f2;
4
+    margin: 0 5px;
5
+    padding-bottom: 10px;
6
+    .button {
7
+      padding: 5px 10px;
8
+      cursor: pointer;
9
+      &.reversal i {
10
+        transform: rotate3d(0, 1, 0, 180deg);
11
+      }
13 12
     }
14
-    .pictureWrapper {
15
-        position: relative; // width: 100%;
16
-        // padding-bottom: 68%;
17
-        // height: 0;
18
-        text-align: center;
19
-        margin-top: 15px;
20
-        padding: 0 5px;
21
-        .tools {
22
-            position: absolute;
23
-            left: 0;
24
-            top: 0;
25
-            bottom: 0;
26
-            right: 0;
27
-            .item {
28
-                width: 33%;
29
-                display: inline-block;
30
-                height: 100%;
31
-                &.left {
32
-                    cursor: url('//links-comment.oss-cn-beijing.aliyuncs.com/comment/20180928/73_yM_fx-.undefined'), auto;
33
-                }
34
-                &.shrink {
35
-                    cursor: url('//links-comment.oss-cn-beijing.aliyuncs.com/comment/20180928/oGPpbJ7Rk.undefined'), auto;
36
-                }
37
-                &.right {
38
-                    cursor: url('//links-comment.oss-cn-beijing.aliyuncs.com/comment/20180928/S8obecP1d.undefined'), auto;
39
-                }
40
-            }
41
-        }
42
-        .picture {
43
-            max-width: 100%;
44
-            max-height: 400px;
13
+  }
14
+  .pictureWrapper {
15
+    position: relative; // width: 100%;
16
+    // padding-bottom: 68%;
17
+    // height: 0;
18
+    text-align: center;
19
+    margin-top: 15px;
20
+    padding: 0 5px;
21
+    .tools {
22
+      position: absolute;
23
+      left: 0;
24
+      top: 0;
25
+      bottom: 0;
26
+      right: 0;
27
+      .item {
28
+        width: 33%;
29
+        display: inline-block;
30
+        height: 100%;
31
+        &.left {
32
+          cursor: url("//links-comment.oss-cn-beijing.aliyuncs.com/comment/20180928/73_yM_fx-.undefined"),
33
+            auto;
45 34
         }
46
-        .tool() {
47
-            position: absolute;
48
-            width: 50px;
49
-            background-color: transparent;
50
-            z-index: 100;
51
-            opacity: 0.5;
52
-            font-size: 50px;
53
-            text-align: left;
54
-            cursor: pointer;
55
-            &:hover {
56
-                background-color: #fff;
57
-            }
35
+        &.shrink {
36
+          cursor: url("//links-comment.oss-cn-beijing.aliyuncs.com/comment/20180928/oGPpbJ7Rk.undefined"),
37
+            auto;
58 38
         }
59
-        .prev {
60
-            .tool();
61
-            left: 5px;
62
-            top: 0;
63
-            bottom: 0;
39
+        &.right {
40
+          cursor: url("//links-comment.oss-cn-beijing.aliyuncs.com/comment/20180928/S8obecP1d.undefined"),
41
+            auto;
64 42
         }
65
-        .next {
66
-            .tool();
67
-            right: 5px;
68
-            top: 0;
69
-            bottom: 0;
70
-        }
71
-        .middle {
72
-            position: absolute;
73
-            top: 50%;
74
-            transform: translateY(-50%);
75
-        } // .picture {
76
-        //     position: absolute;
77
-        //     bottom: 0;
78
-        //     top: 0;
79
-        //     left: 5px;
80
-        //     right: 5px;
81
-        //     background-size: contain;
82
-        //     background-position: center;
83
-        // }
43
+      }
84 44
     }
85
-    .list {
86
-        font-size: 0;
87
-        margin-top: 25px;
88
-        .wrapper {
89
-            width: 11.1%;
90
-            height: 0;
91
-            padding-bottom: 11.1%;
92
-            position: relative;
93
-            display: inline-block;
94
-            border-radius: 5px;
95
-            border: 1px solid transparent;
96
-            opacity: 0.5;
97
-            &.active {
98
-                border: 1px solid #fc4747;
99
-                opacity: 1;
100
-            }
101
-            .thumbnail {
102
-                position: absolute;
103
-                top: 5px;
104
-                bottom: 5px;
105
-                left: 5px;
106
-                right: 5px;
107
-                background-size: cover;
108
-                background-position: center;
109
-                border-radius: 5px;
110
-                cursor: pointer;
111
-            }
112
-        }
45
+    .picture {
46
+      max-width: 100%;
47
+      max-height: 400px;
48
+    }
49
+    .tool() {
50
+      position: absolute;
51
+      width: 50px;
52
+      background-color: transparent;
53
+      z-index: 100;
54
+      opacity: 0.5;
55
+      font-size: 50px;
56
+      text-align: left;
57
+      cursor: pointer;
58
+      &:hover {
59
+        background-color: #fff;
60
+      }
61
+    }
62
+    .prev {
63
+      .tool();
64
+      left: 5px;
65
+      top: 0;
66
+      bottom: 0;
67
+    }
68
+    .next {
69
+      .tool();
70
+      right: 5px;
71
+      top: 0;
72
+      bottom: 0;
73
+    }
74
+    .middle {
75
+      position: absolute;
76
+      top: 50%;
77
+      transform: translateY(-50%);
78
+    } // .picture {
79
+    //     position: absolute;
80
+    //     bottom: 0;
81
+    //     top: 0;
82
+    //     left: 5px;
83
+    //     right: 5px;
84
+    //     background-size: contain;
85
+    //     background-position: center;
86
+    // }
87
+  }
88
+  .list {
89
+    font-size: 0;
90
+    margin-top: 25px;
91
+    .wrapper {
92
+      width: 11.1%;
93
+      height: 0;
94
+      padding-bottom: 11.1%;
95
+      position: relative;
96
+      display: inline-block;
97
+      border-radius: 5px;
98
+      border: 1px solid transparent;
99
+      opacity: 0.5;
100
+      &.active {
101
+        border: 1px solid #fc4747;
102
+        opacity: 1;
103
+      }
104
+      .thumbnail {
105
+        position: absolute;
106
+        top: 5px;
107
+        bottom: 5px;
108
+        left: 5px;
109
+        right: 5px;
110
+        background-size: cover;
111
+        background-position: center;
112
+        border-radius: 5px;
113
+        cursor: pointer;
114
+      }
113 115
     }
116
+  }
114 117
 }

+ 3
- 3
lib/constant.js Datei anzeigen

@@ -23,7 +23,7 @@ var AVATAR = exports.AVATAR = "";
23 23
 
24 24
 var IMAGE_SPLIT = exports.IMAGE_SPLIT = "IMAGE_SPLIT";
25 25
 
26
-var IMAGE_PROCESS = exports.IMAGE_PROCESS = '?x-oss-process=image/resize,h_350';
27
-var IMAGE_PROCESS_SMALL = exports.IMAGE_PROCESS_SMALL = '?x-oss-process=image/resize,h_100';
28
-var IMAGE_PROCESS_LARGE = exports.IMAGE_PROCESS_LARGE = '?x-oss-process=image/resize,h_500';
26
+var IMAGE_PROCESS = exports.IMAGE_PROCESS = "?x-oss-process=image/resize,h_350";
27
+var IMAGE_PROCESS_SMALL = exports.IMAGE_PROCESS_SMALL = "?x-oss-process=image/resize,h_100";
28
+var IMAGE_PROCESS_LARGE = exports.IMAGE_PROCESS_LARGE = "?x-oss-process=image/resize,h_500";
29 29
 //# sourceMappingURL=constant.js.map

+ 1
- 1
lib/constant.js.map Datei anzeigen

@@ -1 +1 @@
1
-{"version":3,"sources":["../src/constant.js"],"names":["ERROR_DEFAULT","LIMIT","OSS_ENDPOINT","OSS_BUCKET","DRIVER_LICENSE_PATH","OSS_LINK","MAX_UPLOAD_NUMBER","URL_REGEXP","REGEXP","AVATAR","IMAGE_SPLIT","IMAGE_PROCESS","IMAGE_PROCESS_SMALL","IMAGE_PROCESS_LARGE"],"mappings":";;;;;AAAO,IAAMA,wCAAgB,MAAtB;;AAEA,IAAMC,wBAAQ,EAAd,C,CAAkB;;AAElB,IAAMC,sCAAe,6BAArB;AACA,IAAMC,kCAAa,eAAnB;AACA,IAAMC,oDAAsB,UAA5B;;AAEA,IAAMC,8BAAW,6CAAjB;;AAEA,IAAMC,gDAAoB,CAA1B;;AAEA,IAAMC,kCAAa,oGAAnB;;AAEA,IAAMC,0BAAS,eAAf;;AAEA,IAAMC,0BAAS,EAAf;;AAEA,IAAMC,oCAAc,aAApB;;AAEA,IAAMC,wCAAgB,mCAAtB;AACA,IAAMC,oDAAsB,mCAA5B;AACA,IAAMC,oDAAsB,mCAA5B","file":"constant.js","sourcesContent":["export const ERROR_DEFAULT = \"出错了!\";\r\n\r\nexport const LIMIT = 10; // 默认 limit\r\n\r\nexport const OSS_ENDPOINT = \"oss-cn-beijing.aliyuncs.com\";\r\nexport const OSS_BUCKET = \"links-comment\";\r\nexport const DRIVER_LICENSE_PATH = \"/comment\";\r\n\r\nexport const OSS_LINK = \"//links-comment.oss-cn-beijing.aliyuncs.com\";\r\n\r\nexport const MAX_UPLOAD_NUMBER = 4;\r\n\r\nexport const URL_REGEXP = /((http(s)?:)?\\/\\/)?(www\\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\\.[a-z]{2,6}\\b([-a-zA-Z0-9@:%_+.~#?&//=]*)/g;\r\n\r\nexport const REGEXP = /\\[[^[\\]]+?\\]/g;\r\n\r\nexport const AVATAR = \"\";\r\n\r\nexport const IMAGE_SPLIT = \"IMAGE_SPLIT\";\r\n\r\nexport const IMAGE_PROCESS = '?x-oss-process=image/resize,h_350';\r\nexport const IMAGE_PROCESS_SMALL = '?x-oss-process=image/resize,h_100';\r\nexport const IMAGE_PROCESS_LARGE = '?x-oss-process=image/resize,h_500';\r\n"]}
1
+{"version":3,"sources":["../src/constant.js"],"names":["ERROR_DEFAULT","LIMIT","OSS_ENDPOINT","OSS_BUCKET","DRIVER_LICENSE_PATH","OSS_LINK","MAX_UPLOAD_NUMBER","URL_REGEXP","REGEXP","AVATAR","IMAGE_SPLIT","IMAGE_PROCESS","IMAGE_PROCESS_SMALL","IMAGE_PROCESS_LARGE"],"mappings":";;;;;AAAO,IAAMA,wCAAgB,MAAtB;;AAEA,IAAMC,wBAAQ,EAAd,C,CAAkB;;AAElB,IAAMC,sCAAe,6BAArB;AACA,IAAMC,kCAAa,eAAnB;AACA,IAAMC,oDAAsB,UAA5B;;AAEA,IAAMC,8BAAW,6CAAjB;;AAEA,IAAMC,gDAAoB,CAA1B;;AAEA,IAAMC,kCAAa,oGAAnB;;AAEA,IAAMC,0BAAS,eAAf;;AAEA,IAAMC,0BAAS,EAAf;;AAEA,IAAMC,oCAAc,aAApB;;AAEA,IAAMC,wCAAgB,mCAAtB;AACA,IAAMC,oDAAsB,mCAA5B;AACA,IAAMC,oDAAsB,mCAA5B","file":"constant.js","sourcesContent":["export const ERROR_DEFAULT = \"出错了!\";\r\n\r\nexport const LIMIT = 10; // 默认 limit\r\n\r\nexport const OSS_ENDPOINT = \"oss-cn-beijing.aliyuncs.com\";\r\nexport const OSS_BUCKET = \"links-comment\";\r\nexport const DRIVER_LICENSE_PATH = \"/comment\";\r\n\r\nexport const OSS_LINK = \"//links-comment.oss-cn-beijing.aliyuncs.com\";\r\n\r\nexport const MAX_UPLOAD_NUMBER = 4;\r\n\r\nexport const URL_REGEXP = /((http(s)?:)?\\/\\/)?(www\\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\\.[a-z]{2,6}\\b([-a-zA-Z0-9@:%_+.~#?&//=]*)/g;\r\n\r\nexport const REGEXP = /\\[[^[\\]]+?\\]/g;\r\n\r\nexport const AVATAR = \"\";\r\n\r\nexport const IMAGE_SPLIT = \"IMAGE_SPLIT\";\r\n\r\nexport const IMAGE_PROCESS = \"?x-oss-process=image/resize,h_350\";\r\nexport const IMAGE_PROCESS_SMALL = \"?x-oss-process=image/resize,h_100\";\r\nexport const IMAGE_PROCESS_LARGE = \"?x-oss-process=image/resize,h_500\";\r\n"]}

+ 1
- 1
lib/helper.js.map
Datei-Diff unterdrückt, da er zu groß ist
Datei anzeigen


+ 1
- 1
package.json Datei anzeigen

@@ -1,6 +1,6 @@
1 1
 {
2 2
   "name": "comment",
3
-  "version": "0.5.12",
3
+  "version": "0.5.13",
4 4
   "main": "lib/App.js",
5 5
   "description": "通用评论",
6 6
   "keywords": [

+ 50
- 31
src/components/Editor/Emoji.js Datei anzeigen

@@ -7,39 +7,58 @@ import "./Emoji.css";
7 7
 
8 8
 // class Emoji
9 9
 
10
-const Emoji = ({ onClick }) => {
11
-  const content = [];
12
-  let curPage = [];
13
-  for (let i = 0; i < 115; i++) {
14
-    if (curPage.length < 20) {
15
-      curPage.push(emoji[i]);
16
-    } else {
17
-      content.push(curPage);
18
-      curPage = [];
10
+class Emoji extends React.Component {
11
+  next() {
12
+    if (this.carousel) {
13
+      this.carousel.next();
14
+    }
15
+  }
16
+
17
+  prev() {
18
+    if (this.carousel) {
19
+      this.carousel.prev();
19 20
     }
20 21
   }
21
-  if (curPage.length > 0) {
22
-    content.push(curPage);
22
+
23
+  render() {
24
+    const { onClick } = this.props;
25
+    const content = [];
26
+    let curPage = [];
27
+    for (let i = 0; i < 115; i++) {
28
+      if (curPage.length < 30) {
29
+        curPage.push(emoji[i]);
30
+      } else {
31
+        content.push(curPage);
32
+        curPage = [];
33
+      }
34
+    }
35
+    if (curPage.length > 0) {
36
+      content.push(curPage);
37
+    }
38
+    return (
39
+      <Carousel
40
+        ref={node => {
41
+          this.carousel = node;
42
+        }}
43
+      >
44
+        {content.map((page, index) => (
45
+          <div key={index} className="emoji">
46
+            {page.map((item, index) => (
47
+              <div className="item" key={item.value}>
48
+                <span className="helper" />
49
+                <img
50
+                  src={`${prefixUrl}${item.value}.${item.ext}`}
51
+                  alt={item.title}
52
+                  style={{ display: "inline-block" }}
53
+                  onClick={() => onClick(item.title)}
54
+                />
55
+              </div>
56
+            ))}
57
+          </div>
58
+        ))}
59
+      </Carousel>
60
+    );
23 61
   }
24
-  return (
25
-    <Carousel>
26
-      {content.map((page, index) => (
27
-        <div key={index} className="emoji">
28
-          {page.map((item, index) => (
29
-            <div className="item" key={item.value}>
30
-              <span className="helper" />
31
-              <img
32
-                src={`${prefixUrl}${item.value}.${item.ext}`}
33
-                alt={item.title}
34
-                style={{ display: "inline-block" }}
35
-                onClick={() => onClick(item.title)}
36
-              />
37
-            </div>
38
-          ))}
39
-        </div>
40
-      ))}
41
-    </Carousel>
42
-  );
43
-};
62
+}
44 63
 
45 64
 export default Emoji;

+ 23
- 2
src/components/Editor/index.js Datei anzeigen

@@ -27,6 +27,7 @@ class Editor extends React.Component {
27 27
     this.handleUpload = this.handleUpload.bind(this);
28 28
     this.handleSubmit = this.handleSubmit.bind(this);
29 29
     this.resetState = this.resetState.bind(this);
30
+    this.handleEmojiScroll = this.handleEmojiScroll.bind(this);
30 31
   }
31 32
 
32 33
   componentDidMount() {
@@ -35,6 +36,18 @@ class Editor extends React.Component {
35 36
     }
36 37
   }
37 38
 
39
+  handleEmojiScroll(e) {
40
+    if (!this.emoji) {
41
+      return;
42
+    }
43
+    e.preventDefault();
44
+    if (e.deltaY > 0) {
45
+      this.emoji.next();
46
+    } else if (e.deltaY < 0) {
47
+      this.emoji.prev();
48
+    }
49
+  }
50
+
38 51
   /**
39 52
    * 编辑器的值改变事件
40 53
    * 将最新的值存储到 state 中
@@ -200,8 +213,16 @@ class Editor extends React.Component {
200 213
                   placement="bottomLeft"
201 214
                   autoAdjustOverflow={false}
202 215
                   content={
203
-                    <div style={{ width: 200 }}>
204
-                      <Emoji onClick={this.handleClickEmoji} />
216
+                    <div
217
+                      style={{ width: 240 }}
218
+                      onWheel={this.handleEmojiScroll}
219
+                    >
220
+                      <Emoji
221
+                        onClick={this.handleClickEmoji}
222
+                        ref={node => {
223
+                          this.emoji = node;
224
+                        }}
225
+                      />
205 226
                     </div>
206 227
                   }
207 228
                   overlayClassName="comment-emoji-popover"