@seafile/sdoc-editor 2.0.170 → 2.0.172

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.
@@ -141,6 +141,7 @@ var CommentItemCollapseWrapper = function CommentItemCollapseWrapper(_ref) {
141
141
  }, [latestReply, t]);
142
142
  var handleScrollToArticle = (0, _react.useCallback)(function (e) {
143
143
  e.stopPropagation();
144
+ if (!element) return;
144
145
  var dom = _slateReact.ReactEditor.toDOMNode(editor, element);
145
146
  var headerHeight = 56 + 37;
146
147
  scrollRef.current.scrollTo({
@@ -29,8 +29,8 @@ var CommentItemContent = function CommentItemContent(_ref) {
29
29
  updateComment = _ref.updateComment,
30
30
  updateCommentState = _ref.updateCommentState,
31
31
  onDeleteComment = _ref.onDeleteComment,
32
- t = _ref.t,
33
- targetId = _ref.targetId;
32
+ targetId = _ref.targetId,
33
+ t = _ref.t;
34
34
  var _useParticipantsConte = (0, _useParticipants.useParticipantsContext)(),
35
35
  addParticipants = _useParticipantsConte.addParticipants,
36
36
  participants = _useParticipantsConte.participants;
@@ -116,7 +116,7 @@ var CommentItemWrapper = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref
116
116
  }(), [comment.detail, dispatch]);
117
117
  var updateCommentState = (0, _react.useCallback)(/*#__PURE__*/function () {
118
118
  var _ref4 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/(0, _regenerator2["default"])().m(function _callee3(commentId, newComment) {
119
- var time, user, reply, res, returnReply, newReply, elementId, resolvedComment, _resolvedComment$deta, unresolvedComment, _unresolvedComment$de;
119
+ var time, user, reply, elementId, resolvedComment, _resolvedComment$deta, unresolvedComment, _unresolvedComment$de, res, returnReply, newReply;
120
120
  return (0, _regenerator2["default"])().w(function (_context3) {
121
121
  while (1) switch (_context3.n) {
122
122
  case 0:
@@ -127,18 +127,7 @@ var CommentItemWrapper = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref
127
127
  reply: newComment.resolved,
128
128
  updated_at: time,
129
129
  author: user.username
130
- }; // When updating comment status, add a new reply
131
- _context3.n = 1;
132
- return _context7["default"].insertReply(commentId, reply);
133
- case 1:
134
- res = _context3.v;
135
- returnReply = res.data.reply;
136
- newReply = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reply), {}, {
137
- id: returnReply.id,
138
- reply: returnReply.reply,
139
- user_name: returnReply.user_name,
140
- avatar_url: returnReply.avatar_url
141
- });
130
+ };
142
131
  elementId = (0, _helper.getPrimaryElementId)(comment.detail);
143
132
  if (newComment.resolved === true) {
144
133
  resolvedComment = commentsDetail ? Object.values(commentsDetail).find(function (comments) {
@@ -161,25 +150,38 @@ var CommentItemWrapper = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref
161
150
  (0, _helper.updateCommentedElementsAttrs)(unresolvedComment.detail.element_id_list, editor, (_unresolvedComment$de = unresolvedComment.detail) === null || _unresolvedComment$de === void 0 ? void 0 : _unresolvedComment$de.text_comment_id, !newComment.resolved);
162
151
  }
163
152
  }
153
+
154
+ // Modify comment status
155
+ _context3.n = 1;
156
+ return _context7["default"].updateComment(commentId, newComment);
157
+ case 1:
164
158
  dispatch({
165
- type: 'INSERT_REPLY',
159
+ type: 'UPDATE_COMMENT_STATE',
166
160
  payload: {
167
161
  element_id: elementId,
168
162
  comment_id: commentId,
169
- reply: newReply
163
+ comment: newComment
170
164
  }
171
165
  });
172
166
 
173
- // Modify comment status
167
+ // When updating comment status, add a new reply
174
168
  _context3.n = 2;
175
- return _context7["default"].updateComment(commentId, newComment);
169
+ return _context7["default"].insertReply(commentId, reply);
176
170
  case 2:
171
+ res = _context3.v;
172
+ returnReply = res.data.reply;
173
+ newReply = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reply), {}, {
174
+ id: returnReply.id,
175
+ reply: returnReply.reply,
176
+ user_name: returnReply.user_name,
177
+ avatar_url: returnReply.avatar_url
178
+ });
177
179
  dispatch({
178
- type: 'UPDATE_COMMENT_STATE',
180
+ type: 'INSERT_REPLY',
179
181
  payload: {
180
182
  element_id: elementId,
181
183
  comment_id: commentId,
182
- comment: newComment
184
+ reply: newReply
183
185
  }
184
186
  });
185
187
 
@@ -401,6 +403,7 @@ var CommentItemWrapper = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref
401
403
  });
402
404
  var handleScrollToArticle = (0, _react.useCallback)(function (e) {
403
405
  e.stopPropagation();
406
+ if (!element) return;
404
407
  var dom = _slateReact.ReactEditor.toDOMNode(editor, element);
405
408
  var headerHeight = 56 + 37;
406
409
  scrollRef.current.scrollTo({
@@ -23,10 +23,11 @@ var ImagePreviewer = /*#__PURE__*/function (_React$Component) {
23
23
  (0, _defineProperty2["default"])(_this, "getImageNodes", function (nodes) {
24
24
  var nodeIndex = 0;
25
25
  var list = [];
26
+ var editor = _this.props.editor;
26
27
  while (nodes && nodeIndex <= nodes.length - 1) {
27
28
  var currentNode = nodes[nodeIndex];
28
29
  if (currentNode.type === 'image') {
29
- var url = (0, _helpers.getImageURL)(currentNode.data);
30
+ var url = (0, _helpers.getImageURL)(currentNode.data, editor);
30
31
  url && list.push(url);
31
32
  } else {
32
33
  list.push.apply(list, (0, _toConsumableArray2["default"])(_this.getImageNodes(currentNode.children)));
@@ -49,9 +50,9 @@ var ImagePreviewer = /*#__PURE__*/function (_React$Component) {
49
50
  };
50
51
  });
51
52
  });
52
- var editor = props.editor,
53
+ var _editor = props.editor,
53
54
  imageUrl = props.imageUrl;
54
- _this.images = _this.getImageNodes(editor.children);
55
+ _this.images = _this.getImageNodes(_editor.children);
55
56
  _this.state = {
56
57
  imageIndex: _this.images.findIndex(function (item) {
57
58
  return item === imageUrl;
@@ -304,7 +304,7 @@ var ImageHoverMenu = function ImageHoverMenu(_ref) {
304
304
  className: "sdocfont sdoc-check-mark sdoc-dropdown-item-right-icon"
305
305
  })));
306
306
  })), isShowImagePreview && /*#__PURE__*/_react["default"].createElement(_imagePreviewer["default"], {
307
- imageUrl: (0, _helpers.getImageURL)(data),
307
+ imageUrl: (0, _helpers.getImageURL)(data, editor),
308
308
  editor: editor,
309
309
  toggleImagePreviewer: function toggleImagePreviewer() {
310
310
  setIsShowImagePreview(!isShowImagePreview);
@@ -3,7 +3,7 @@
3
3
  padding: .5rem 1rem .5rem 0;
4
4
  }
5
5
 
6
- .sdoc-wiki-viewer-outline .outline-h2,
6
+ .sdoc-wiki-viewer-outline .outline-h2,
7
7
  .sdoc-wiki-viewer-outline .outline-h3 {
8
8
  white-space: nowrap;
9
9
  overflow: hidden;
@@ -13,7 +13,7 @@
13
13
  .sdoc-wiki-viewer-outline .outline-h2 {
14
14
  margin-left: 20px;
15
15
  line-height: 2.5;
16
- color:#364149;
16
+ color: #364149;
17
17
  white-space: nowrap;
18
18
  cursor: pointer;
19
19
  }
@@ -25,9 +25,9 @@
25
25
  .sdoc-wiki-viewer-outline .outline-h3 {
26
26
  margin-left: 40px;
27
27
  line-height: 2.5;
28
- color:#364149;
28
+ color: #364149;
29
29
  white-space: nowrap;
30
- cursor:pointer;
30
+ cursor: pointer;
31
31
  }
32
32
 
33
33
  .sdoc-wiki-viewer-outline .outline-h3:hover {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "2.0.170",
3
+ "version": "2.0.172",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "test": "jest",
@@ -71,5 +71,5 @@
71
71
  "publishConfig": {
72
72
  "access": "public"
73
73
  },
74
- "gitHead": "f67a3cb8453cb2244cddc1f3ec798ccc5bdd7fbe"
74
+ "gitHead": "9aecbf97e5f1620e494c33fac11450514acb0dfa"
75
75
  }