@seafile/sdoc-editor 0.1.98 → 0.1.100

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,4 @@
1
+ /* editor-comment css */
1
2
  .sdoc-comment-container {
2
3
  position: absolute;
3
4
  left: 0;
@@ -36,172 +37,112 @@
36
37
  width: 280px;
37
38
  }
38
39
 
39
- .sdoc-comment-container .comment-list-container {
40
+ /* global comment css */
41
+ .global-comments-popover {
40
42
  position: absolute;
41
- /* background: rgba(255,255,255,.92);
42
- border-radius: 8px;
43
- box-shadow: 0 0 2px rgba(0,0,0,.04);
44
- padding: 16px 0; */
45
- }
46
-
47
- .sdoc-comment-container .comment-ui-container {
48
- background-color: #edf2fa;
49
- border-radius: 8px;
50
- box-shadow: 0 0 2px rgba(0,0,0,.04);
51
- padding: 16px 0;
52
- margin-bottom: 20px;
53
- cursor: pointer;
54
- }
55
-
56
- .sdoc-comment-container .comment-ui-container.active {
57
- position: relative;
58
- left: -24px;
59
- background: rgba(255, 255, 255, .92);
60
- box-shadow: 0 1px 3px rgba(0,0,0,.3), 0 4px 8px 3px rgba(0,0,0,.15);
43
+ right: 10px;
44
+ top: 50px;
45
+ z-index: 103;
46
+ width: 340px;
47
+ height: 600px;
61
48
  }
62
49
 
63
- .sdoc-comment-container .comment-list-container .comment-item-list {
64
- max-height: 350px;
65
- min-width: 280px;
66
- overflow-x: hidden;
67
- overflow-y: auto;
68
- margin: 0;
69
- }
70
-
71
- .sdoc-comment-container .comment-list-container .comment-item {
72
- position: relative;
73
- padding: 16px 16px 0;
74
- cursor: default;
75
- }
76
-
77
- .sdoc-comment-container .comment-ui-container.active .comment-item:hover {
78
- background: #fafafa;
79
- }
80
-
81
- .sdoc-comment-container .comment-item .comment-header,
82
- .sdoc-comment-container .comment-item .comment-author {
50
+ .global-comments-popover .comments-panel-wrapper {
51
+ height: 100%;
83
52
  display: flex;
84
- justify-content: space-between;
85
- align-items: center;
86
- }
87
-
88
- .sdoc-comment-container .comment-item .comment-content {
89
- padding-bottom: 10px;
90
- margin-top: 10px;
91
- margin-left: 30px;
53
+ flex-direction: column;
54
+ background: #fff;
55
+ border: 1px solid #EAECEF;
56
+ box-shadow: 0 2px 10px rgba(0, 0, 0, .12);
92
57
  }
93
58
 
94
- .sdoc-comment-container .comment-header .comment-author__avatar {
59
+ .global-comments-popover .comments-panel-header {
60
+ padding: 0 16px;
61
+ height: 46px;
95
62
  display: flex;
96
63
  align-items: center;
64
+ justify-content: space-between;
65
+ border-bottom: 1px solid #EAECEF;
97
66
  }
98
67
 
99
- .sdoc-comment-container .comment-header .comment-author__avatar img {
100
- width: 32px;
101
- height: 32px;
102
- border-radius: 50%;
68
+ .global-comments-popover .comments-panel-header .title {
69
+ color: #212529;
70
+ font-size: 16px;
71
+ font-weight: 500;
103
72
  }
104
73
 
105
- .sdoc-comment-container .comment-header .comment-author__info {
74
+ .global-comments-popover .comments-panel-header .sdoc-close {
106
75
  display: flex;
107
- flex-direction: column;
108
- align-items: start;
76
+ align-items: center;
109
77
  justify-content: center;
110
- padding-left: 10px;
111
- overflow: hidden;
112
- white-space: nowrap;
113
- text-overflow: ellipsis;
114
- cursor: pointer;
115
- }
116
-
117
- .sdoc-comment-container .comment-header .comment-author__info .name {
118
- color: #1f1f1f;
119
78
  font-size: 14px;
120
- line-height: 20px;
121
- font-weight: 500;
79
+ font-weight: 700;
80
+ color: #999;
81
+ cursor: pointer;
122
82
  }
123
83
 
124
- .sdoc-comment-container .comment-header .comment-author__info .time {
125
- color: #444746;
126
- font-size: 12px;
127
- line-height: 16px;
84
+ .global-comments-popover .comments-panel-header .sdoc-close:hover {
85
+ color: #5a5a5a;
128
86
  }
129
87
 
130
- .sdoc-comment-container .comment-header .comment-operation {
131
- line-height: 20px;
132
- font-size: 20px;
133
- color: rgb(70, 77, 90);
134
- width: 20px;
135
- height: 20px;
136
- cursor: pointer;
88
+ .global-comments-popover .comments-panel-body {
89
+ flex: 1;
90
+ display: flex;
91
+ flex-direction: column;
92
+ min-height: 0;
137
93
  }
138
94
 
139
- .sdoc-comment-container .comment-ui-container .comment-operation {
140
- width: 32px;
141
- height: 32px;
95
+ .global-comments-popover .comments-panel-body__header {
96
+ height: 38px;
142
97
  display: flex;
98
+ justify-content: space-between;
143
99
  align-items: center;
144
- justify-content: center;
100
+ padding: 16px;
145
101
  }
146
102
 
147
- .sdoc-comment-container .comment-ui-container.active .comment-operation:hover {
148
- border-radius: 100%;
149
- background-color: #f0f0f0;
103
+ .global-comments-popover .comments-panel-body__header .comment-type {
104
+ color: #212529;
105
+ font-size: 12px;
150
106
  }
151
107
 
152
- .sdoc-comment-container .comment-ui-container .comment-operation .sdoc-confirm {
153
- color: #20a0ff;
154
- font-weight: 800;
108
+ .global-comments-popover .comments-panel-body__header .comment-type{
109
+ color: #212529;
110
+ font-size: 12px;
155
111
  }
156
112
 
157
- .sdoc-comment-menu {
158
- padding: 0;
159
- border-radius: 2px;
113
+ .global-comments-popover .comments-panel-body__header .comment-count-tip {
114
+ color: #999;
115
+ font-size: 12px;
160
116
  }
161
117
 
162
- .sdoc-popover-menu {
163
- background: rgb(255, 255, 255);
164
- width: 130px;
165
- padding: 8px 0;
166
- height: auto;
118
+ .global-comments-popover .comments-panel-body__content {
119
+ flex: 1;
120
+ display: flex;
121
+ flex-direction: column;
122
+ padding: 16px;
123
+ overflow: auto;
167
124
  }
168
125
 
169
- .sdoc-popover-menu__item {
170
- padding: 4px 24px;
171
- height: 28px;
172
- vertical-align: middle;
173
- font-size: 14px;
174
- background-color: transparent;
175
- cursor: default;
176
- color: #202428;
177
- background-color: #fff;
126
+ .global-comments-popover .comments-panel-body__content .sdoc-comment-list-container {
127
+ position: relative;
178
128
  }
179
129
 
180
- .sdoc-popover-menu__item:hover {
181
- background-color: #20a0ff;
182
- color: #fff;
130
+ .global-comments-popover .comments-panel-body__content .comment-item-list {
131
+ max-width: 308px;
183
132
  }
184
133
 
185
- .sdoc-comment-container .comment-list-container .comment-editor-wrapper {
186
- display: flex;
187
- align-items: center;
188
- justify-content: center;
189
- padding: 0 16px;
134
+ .global-comments-popover .comments-panel-body__content .comment-ui-container.active {
135
+ left: 0;
190
136
  }
191
137
 
192
- .sdoc-comment-container .comment-list-container .comment-editor {
193
- height: 40px;
194
- width: 248px;
195
- background: #fff;
196
- border: 1px solid rgba(0, 0, 0, .12);
197
- border-radius: 4px;
198
- padding: 8px;
138
+ .global-comments-popover .comments-panel-body__content .comment-ui-container.sdoc-resolved {
139
+ background: #f5f5f5;
199
140
  }
200
141
 
201
- .sdoc-comment-container .comment-list-container .comment-editor:focus-visible {
202
- outline: none;
142
+ .global-comments-popover .comments-panel-body__content .comment-ui-container.active.sdoc-resolved {
143
+ background: #f5f5f5;
203
144
  }
204
145
 
205
- .sdoc-comment-container .comment-list-container .comment-editor:focus {
206
- border: 1px solid rgba(0, 0, 0, .12);
146
+ .sdoc-comment-list-menu .dropdown-item {
147
+ font-size: 12px;
207
148
  }
@@ -8,7 +8,10 @@ export var commentDecorate = function commentDecorate(editor) {
8
8
  path = _ref2[1];
9
9
  var decorations = [];
10
10
  var comments = ((_editor$element_comme = editor.element_comments_map) === null || _editor$element_comme === void 0 ? void 0 : _editor$element_comme[node.id]) || [];
11
- if (comments && comments.length > 0) {
11
+ var unresolvedComments = comments && comments.filter(function (item) {
12
+ return !item.resolved;
13
+ });
14
+ if (unresolvedComments && unresolvedComments.length > 0) {
12
15
  var decoration = {
13
16
  anchor: {
14
17
  path: path,
@@ -21,7 +24,7 @@ export var commentDecorate = function commentDecorate(editor) {
21
24
  };
22
25
  // rgba prevents occlusion of the cursor
23
26
  decoration['computed_bg_color'] = 'rgba(129, 237, 247, 0.5)';
24
- decoration['comment_count'] = editor.element_comments_map[node.id].length;
27
+ decoration['comment_count'] = unresolvedComments === null || unresolvedComments === void 0 ? void 0 : unresolvedComments.length;
25
28
  decorations.push(decoration);
26
29
  }
27
30
  return decorations;
@@ -0,0 +1,39 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import { useEffect, useState } from 'react';
3
+ import { useCommentContext } from './use-comment-context';
4
+ import { COMMENT_TYPES } from '../comment/global-comment-header';
5
+ var useCommentList = function useCommentList() {
6
+ var _useCommentContext = useCommentContext(),
7
+ commentsInfo = _useCommentContext.commentsInfo;
8
+ var _ref = commentsInfo || [],
9
+ comment_list = _ref.comment_list;
10
+ var _useState = useState(COMMENT_TYPES.all),
11
+ _useState2 = _slicedToArray(_useState, 2),
12
+ commentType = _useState2[0],
13
+ setCommentType = _useState2[1];
14
+ var _useState3 = useState([comment_list]),
15
+ _useState4 = _slicedToArray(_useState3, 2),
16
+ commentList = _useState4[0],
17
+ setCommentList = _useState4[1];
18
+ useEffect(function () {
19
+ if (commentType === COMMENT_TYPES.all) {
20
+ setCommentList(comment_list);
21
+ } else if (commentType === COMMENT_TYPES.resolved) {
22
+ var _commentList = comment_list.filter(function (item) {
23
+ return item.resolved;
24
+ });
25
+ setCommentList(_commentList);
26
+ } else if (commentType === COMMENT_TYPES.unresolved) {
27
+ var _commentList2 = comment_list.filter(function (item) {
28
+ return !item.resolved;
29
+ });
30
+ setCommentList(_commentList2);
31
+ }
32
+ }, [commentType, comment_list]);
33
+ return {
34
+ commentList: commentList,
35
+ commentType: commentType,
36
+ setCommentType: setCommentType
37
+ };
38
+ };
39
+ export default useCommentList;
@@ -1,12 +1,12 @@
1
1
  import React from 'react';
2
2
  import { useCommentContext } from './hooks/use-comment-context';
3
- import Comment from './comment';
3
+ import { EditorComment, GlobalComment } from './comment';
4
4
  var CommentWrapper = function CommentWrapper() {
5
5
  var _useCommentContext = useCommentContext(),
6
6
  commentsInfo = _useCommentContext.commentsInfo;
7
7
  if (commentsInfo.isFetching) {
8
8
  return null;
9
9
  }
10
- return /*#__PURE__*/React.createElement(Comment, null);
10
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(EditorComment, null), /*#__PURE__*/React.createElement(GlobalComment, null));
11
11
  };
12
12
  export default CommentWrapper;
@@ -1,17 +1,28 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
+ import deepCopy from 'deep-copy';
3
4
  export var formatCommentsData = function formatCommentsData(comments) {
4
- var elementCommentsMap = {};
5
- for (var i = 0; i < comments.length; i++) {
6
- var item = comments[i];
5
+ var formatComments = [];
6
+ var dupComments = deepCopy(comments);
7
+ for (var i = 0; i < dupComments.length; i++) {
8
+ var item = dupComments[i];
7
9
 
8
10
  // the comment is not in sdoc document
9
- if (!item.detail || item.resolved) continue;
11
+ if (!item.detail) continue;
10
12
  try {
11
13
  item.detail = JSON.parse(item.detail);
14
+ formatComments.push(item);
12
15
  } catch (err) {
13
16
  continue;
14
17
  }
18
+ }
19
+ return formatComments;
20
+ };
21
+ export var initElementCommentsMap = function initElementCommentsMap(comments) {
22
+ var elementCommentsMap = {};
23
+ var formatComments = formatCommentsData(comments);
24
+ for (var i = 0; i < formatComments.length; i++) {
25
+ var item = formatComments[i];
15
26
  var element_id = item.detail.element_id;
16
27
  if (!elementCommentsMap[element_id]) {
17
28
  elementCommentsMap[element_id] = [];
@@ -20,6 +31,45 @@ export var formatCommentsData = function formatCommentsData(comments) {
20
31
  }
21
32
  return elementCommentsMap;
22
33
  };
34
+ export var initCommentList = function initCommentList(comments) {
35
+ // format comments
36
+ var formatComments = formatCommentsData(comments);
37
+
38
+ // sort comments by update time
39
+ return sortCommentList(formatComments);
40
+ };
41
+ export var sortCommentList = function sortCommentList(commentList) {
42
+ var newComments = commentList.map(function (item) {
43
+ var updated_at = item.updated_at,
44
+ replies = item.replies;
45
+ var replayUpdatedTimes = replies.map(function (item) {
46
+ return item.updated_at;
47
+ });
48
+ var updatedTimes = [updated_at].concat(_toConsumableArray(replayUpdatedTimes));
49
+ updatedTimes.sort(function (a, b) {
50
+ return new Date(a).getTime() <= new Date(b).getTime() ? 1 : -1;
51
+ });
52
+ item.updated_time = updatedTimes[0];
53
+ return item;
54
+ });
55
+ var unresolvedComments = [];
56
+ var resolvedComments = [];
57
+ // Differentiate between resolved and unresolved comments
58
+ newComments.forEach(function (item) {
59
+ if (item.resolved) {
60
+ resolvedComments.push(item);
61
+ } else {
62
+ unresolvedComments.push(item);
63
+ }
64
+ });
65
+ unresolvedComments.sort(function (a, b) {
66
+ return new Date(a.updated_time).getTime() <= new Date(b.updated_time).getTime() ? 1 : -1;
67
+ });
68
+ resolvedComments.sort(function (a, b) {
69
+ return new Date(a.updated_time).getTime() <= new Date(b.updated_time).getTime() ? 1 : -1;
70
+ });
71
+ return [].concat(unresolvedComments, resolvedComments);
72
+ };
23
73
  export var initCommentsInfo = {
24
74
  isFetching: true,
25
75
  comment_list: [],
@@ -34,11 +84,11 @@ export var commentReducer = function commentReducer(state, action) {
34
84
  }
35
85
  case 'RECEIVE_STATE':
36
86
  {
37
- var element_comments_map = formatCommentsData(action.payload);
87
+ var commentList = initCommentList(action.payload);
38
88
  return {
39
89
  isFetching: false,
40
- comment_list: action.payload,
41
- element_comments_map: element_comments_map,
90
+ comment_list: commentList,
91
+ element_comments_map: initElementCommentsMap(action.payload),
42
92
  error: false
43
93
  };
44
94
  }
@@ -52,41 +102,59 @@ export var commentReducer = function commentReducer(state, action) {
52
102
  }
53
103
  case 'INSERT_COMMENT':
54
104
  {
55
- var _element_comments_map = state.element_comments_map;
105
+ var element_comments_map = state.element_comments_map,
106
+ comment_list = state.comment_list;
56
107
  var _action$payload = action.payload,
57
108
  element_id = _action$payload.element_id,
58
109
  comment = _action$payload.comment;
59
- if (!_element_comments_map[element_id]) {
60
- _element_comments_map[element_id] = [];
110
+ if (!element_comments_map[element_id]) {
111
+ element_comments_map[element_id] = [];
61
112
  }
62
- _element_comments_map[element_id] = [].concat(_toConsumableArray(_element_comments_map[element_id]), [comment]);
113
+ element_comments_map[element_id] = [].concat(_toConsumableArray(element_comments_map[element_id]), [comment]);
114
+ var _commentList = [comment].concat(_toConsumableArray(comment_list));
63
115
  return _objectSpread(_objectSpread({}, state), {}, {
64
- element_comments_map: _objectSpread({}, _element_comments_map)
116
+ element_comments_map: _objectSpread({}, element_comments_map),
117
+ comment_list: _commentList
65
118
  });
66
119
  }
67
120
  case 'DELETE_COMMENT':
68
121
  {
69
- var _element_comments_map2 = state.element_comments_map;
122
+ var _element_comments_map = state.element_comments_map,
123
+ _comment_list = state.comment_list;
70
124
  var _action$payload2 = action.payload,
71
125
  _element_id = _action$payload2.element_id,
72
126
  comment_id = _action$payload2.comment_id;
73
- if (_element_comments_map2[_element_id]) {
74
- _element_comments_map2[_element_id] = _element_comments_map2[_element_id].filter(function (item) {
127
+ if (_element_comments_map[_element_id]) {
128
+ _element_comments_map[_element_id] = _element_comments_map[_element_id].filter(function (item) {
75
129
  return item.id !== comment_id;
76
130
  });
77
131
  }
132
+ var _commentList2 = _comment_list.filter(function (item) {
133
+ return item.id === comment_id;
134
+ });
78
135
  return _objectSpread(_objectSpread({}, state), {}, {
79
- element_comments_map: _objectSpread({}, _element_comments_map2)
136
+ element_comments_map: _objectSpread({}, _element_comments_map),
137
+ comment_list: _commentList2
80
138
  });
81
139
  }
82
140
  case 'UPDATE_COMMENT':
83
141
  {
84
- var _element_comments_map3 = state.element_comments_map;
142
+ var _element_comments_map2 = state.element_comments_map,
143
+ _comment_list2 = state.comment_list;
85
144
  var _action$payload3 = action.payload,
86
145
  _element_id2 = _action$payload3.element_id,
87
146
  _comment_id = _action$payload3.comment_id,
88
147
  _comment = _action$payload3.comment;
89
- _element_comments_map3[_element_id2] = _element_comments_map3[_element_id2].map(function (item) {
148
+ _element_comments_map2[_element_id2] = _element_comments_map2[_element_id2].map(function (item) {
149
+ if (item.id === _comment_id) {
150
+ item.comment = _comment.comment;
151
+ item.detail = _comment.detail;
152
+ item.updated_at = _comment.updated_at;
153
+ return item;
154
+ }
155
+ return item;
156
+ });
157
+ var _commentList3 = _comment_list2.map(function (item) {
90
158
  if (item.id === _comment_id) {
91
159
  item.comment = _comment.comment;
92
160
  item.detail = _comment.detail;
@@ -96,42 +164,55 @@ export var commentReducer = function commentReducer(state, action) {
96
164
  return item;
97
165
  });
98
166
  return _objectSpread(_objectSpread({}, state), {}, {
99
- element_comments_map: _objectSpread({}, _element_comments_map3)
167
+ element_comments_map: _objectSpread({}, _element_comments_map2),
168
+ comment_list: _commentList3
100
169
  });
101
170
  }
102
171
  case 'UPDATE_COMMENT_STATE':
103
172
  {
104
- var _element_comments_map4 = state.element_comments_map;
173
+ var _element_comments_map3 = state.element_comments_map,
174
+ _comment_list3 = state.comment_list;
105
175
  var _action$payload4 = action.payload,
106
176
  _element_id3 = _action$payload4.element_id,
107
177
  _comment_id2 = _action$payload4.comment_id,
108
178
  _comment2 = _action$payload4.comment;
109
179
 
110
180
  // modify comment state
111
- _element_comments_map4[_element_id3] = _element_comments_map4[_element_id3].map(function (item) {
181
+ _element_comments_map3[_element_id3] = _element_comments_map3[_element_id3].map(function (item) {
112
182
  if (item.id === _comment_id2) {
113
183
  item.resolved = _comment2.resolved;
114
184
  return item;
115
185
  }
116
186
  return item;
117
187
  });
118
-
119
- // remove it form current list
120
- _element_comments_map4[_element_id3] = _element_comments_map4[_element_id3].filter(function (item) {
121
- return item.id !== _comment_id2;
188
+ var _commentList4 = _comment_list3.map(function (item) {
189
+ if (item.id === _comment_id2) {
190
+ item.resolved = _comment2.resolved;
191
+ return item;
192
+ }
193
+ return item;
122
194
  });
123
195
  return _objectSpread(_objectSpread({}, state), {}, {
124
- element_comments_map: _objectSpread({}, _element_comments_map4)
196
+ element_comments_map: _objectSpread({}, _element_comments_map3),
197
+ comment_list: sortCommentList(_commentList4)
125
198
  });
126
199
  }
127
200
  case 'INSERT_REPLY':
128
201
  {
129
- var _element_comments_map5 = state.element_comments_map;
202
+ var _element_comments_map4 = state.element_comments_map,
203
+ _comment_list4 = state.comment_list;
130
204
  var _action$payload5 = action.payload,
131
205
  _element_id4 = _action$payload5.element_id,
132
206
  _comment_id3 = _action$payload5.comment_id,
133
207
  reply = _action$payload5.reply;
134
- _element_comments_map5[_element_id4] = _element_comments_map5[_element_id4].map(function (item) {
208
+ _element_comments_map4[_element_id4] = _element_comments_map4[_element_id4].map(function (item) {
209
+ if (item.id === _comment_id3) {
210
+ item.replies = [].concat(_toConsumableArray(item.replies), [reply]);
211
+ return item;
212
+ }
213
+ return item;
214
+ });
215
+ var _commentList5 = _comment_list4.map(function (item) {
135
216
  if (item.id === _comment_id3) {
136
217
  item.replies = [].concat(_toConsumableArray(item.replies), [reply]);
137
218
  return item;
@@ -139,17 +220,28 @@ export var commentReducer = function commentReducer(state, action) {
139
220
  return item;
140
221
  });
141
222
  return _objectSpread(_objectSpread({}, state), {}, {
142
- element_comments_map: _objectSpread({}, _element_comments_map5)
223
+ element_comments_map: _objectSpread({}, _element_comments_map4),
224
+ comment_list: _commentList5
143
225
  });
144
226
  }
145
227
  case 'DELETE_REPLY':
146
228
  {
147
- var _element_comments_map6 = state.element_comments_map;
229
+ var _element_comments_map5 = state.element_comments_map,
230
+ _comment_list5 = state.comment_list;
148
231
  var _action$payload6 = action.payload,
149
232
  _element_id5 = _action$payload6.element_id,
150
233
  _comment_id4 = _action$payload6.comment_id,
151
234
  reply_id = _action$payload6.reply_id;
152
- _element_comments_map6[_element_id5] = _element_comments_map6[_element_id5].map(function (item) {
235
+ _element_comments_map5[_element_id5] = _element_comments_map5[_element_id5].map(function (item) {
236
+ if (item.id === _comment_id4) {
237
+ item.replies = item.replies.filter(function (reply) {
238
+ return reply.id !== reply_id;
239
+ });
240
+ return item;
241
+ }
242
+ return item;
243
+ });
244
+ var _commentList6 = _comment_list5.map(function (item) {
153
245
  if (item.id === _comment_id4) {
154
246
  item.replies = item.replies.filter(function (reply) {
155
247
  return reply.id !== reply_id;
@@ -159,18 +251,33 @@ export var commentReducer = function commentReducer(state, action) {
159
251
  return item;
160
252
  });
161
253
  return _objectSpread(_objectSpread({}, state), {}, {
162
- element_comments_map: _objectSpread({}, _element_comments_map6)
254
+ element_comments_map: _objectSpread({}, _element_comments_map5),
255
+ comment_list: _commentList6
163
256
  });
164
257
  }
165
258
  case 'UPDATE_REPLY':
166
259
  {
167
- var _element_comments_map7 = state.element_comments_map;
260
+ var _element_comments_map6 = state.element_comments_map,
261
+ _comment_list6 = state.comment_list;
168
262
  var _action$payload7 = action.payload,
169
263
  _element_id6 = _action$payload7.element_id,
170
264
  _comment_id5 = _action$payload7.comment_id,
171
265
  _reply_id = _action$payload7.reply_id,
172
266
  _reply = _action$payload7.reply;
173
- _element_comments_map7[_element_id6] = _element_comments_map7[_element_id6].map(function (item) {
267
+ _element_comments_map6[_element_id6] = _element_comments_map6[_element_id6].map(function (item) {
268
+ if (item.id === _comment_id5) {
269
+ item.replies = item.replies.map(function (replyItem) {
270
+ if (replyItem.id === _reply_id) {
271
+ // need update replay updated_at
272
+ return _objectSpread(_objectSpread({}, replyItem), _reply);
273
+ }
274
+ return replyItem;
275
+ });
276
+ return item;
277
+ }
278
+ return item;
279
+ });
280
+ var _commentList7 = _comment_list6.map(function (item) {
174
281
  if (item.id === _comment_id5) {
175
282
  item.replies = item.replies.map(function (replyItem) {
176
283
  if (replyItem.id === _reply_id) {
@@ -184,7 +291,8 @@ export var commentReducer = function commentReducer(state, action) {
184
291
  return item;
185
292
  });
186
293
  return _objectSpread(_objectSpread({}, state), {}, {
187
- element_comments_map: _objectSpread({}, _element_comments_map7)
294
+ element_comments_map: _objectSpread({}, _element_comments_map6),
295
+ comment_list: _commentList7
188
296
  });
189
297
  }
190
298
  default:
@@ -0,0 +1,14 @@
1
+ import React, { useCallback } from 'react';
2
+ import { EventBus } from '../../../basic-sdk';
3
+ export default function CommentsOperation() {
4
+ var onCommentsToggle = useCallback(function () {
5
+ var eventBus = EventBus.getInstance();
6
+ eventBus.dispatch('COMMENT_LIST_CLICK');
7
+ }, []);
8
+ return /*#__PURE__*/React.createElement("span", {
9
+ className: "op-item",
10
+ onClick: onCommentsToggle
11
+ }, /*#__PURE__*/React.createElement("i", {
12
+ className: "sdocfont sdoc-comments mr-1"
13
+ }));
14
+ }
@@ -1,10 +1,11 @@
1
1
  import React from 'react';
2
2
  import { withTranslation } from 'react-i18next';
3
+ import context from '../../context';
3
4
  import RevisionOperations from './revision-operations';
4
5
  import HistoryOperation from './history-operation';
5
6
  import CollaboratorsOperation from './collaborators-operation';
6
7
  import MoreOperations from './more-operations';
7
- import context from '../../context';
8
+ import CommentsOperation from './comments-operation';
8
9
  import './style.css';
9
10
  var DocOperations = function DocOperations(_ref) {
10
11
  var isShowChanges = _ref.isShowChanges,
@@ -15,7 +16,7 @@ var DocOperations = function DocOperations(_ref) {
15
16
  }, /*#__PURE__*/React.createElement(RevisionOperations, {
16
17
  isShowChanges: isShowChanges,
17
18
  toggleViewChanges: toggleViewChanges
18
- }), !isSdocRevision && /*#__PURE__*/React.createElement("span", {
19
+ }), /*#__PURE__*/React.createElement(CommentsOperation, null), !isSdocRevision && /*#__PURE__*/React.createElement("span", {
19
20
  className: "op-item"
20
21
  }, /*#__PURE__*/React.createElement("i", {
21
22
  className: "sdocfont sdoc-share"