@seafile/sdoc-editor 0.1.169-beta → 0.1.170

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,7 +1,7 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
2
  import classNames from 'classnames';
3
3
  import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
4
- import { withTranslation } from 'react-i18next';
4
+ import { useTranslation } from 'react-i18next';
5
5
  import { Button } from 'reactstrap';
6
6
  var getSubmitTip = function getSubmitTip(type, content) {
7
7
  if (content) return 'Save';
@@ -15,8 +15,10 @@ var CommentEditor = function CommentEditor(_ref) {
15
15
  insertContent = _ref.insertContent,
16
16
  updateContent = _ref.updateContent,
17
17
  setIsEditing = _ref.setIsEditing,
18
- t = _ref.t;
18
+ hiddenComment = _ref.hiddenComment;
19
19
  var commentRef = useRef();
20
+ var _useTranslation = useTranslation(),
21
+ t = _useTranslation.t;
20
22
  var _useState = useState(false),
21
23
  _useState2 = _slicedToArray(_useState, 2),
22
24
  isFocus = _useState2[0],
@@ -48,6 +50,9 @@ var CommentEditor = function CommentEditor(_ref) {
48
50
  setIsFocus(false);
49
51
  commentRef.current.textContent = '';
50
52
  setIsEditing && setIsEditing(false);
53
+ hiddenComment && hiddenComment(false);
54
+
55
+ // eslint-disable-next-line react-hooks/exhaustive-deps
51
56
  }, [setIsEditing]);
52
57
  var onKeyDown = useCallback(function (event) {
53
58
  // enter
@@ -88,4 +93,4 @@ var CommentEditor = function CommentEditor(_ref) {
88
93
  CommentEditor.defaultProps = {
89
94
  placeholder: 'Enter_a_comment'
90
95
  };
91
- export default withTranslation('sdoc-editor')(CommentEditor);
96
+ export default CommentEditor;
@@ -17,7 +17,8 @@ export default function CommentItemWrapper(_ref) {
17
17
  isActive = _ref.isActive,
18
18
  comment = _ref.comment,
19
19
  onCommentClick = _ref.onCommentClick,
20
- updateScrollPosition = _ref.updateScrollPosition;
20
+ updateScrollPosition = _ref.updateScrollPosition,
21
+ hiddenComment = _ref.hiddenComment;
21
22
  var listRef = useRef(null);
22
23
  var _useCommentContext = useCommentContext(),
23
24
  dispatch = _useCommentContext.dispatch;
@@ -360,7 +361,8 @@ export default function CommentItemWrapper(_ref) {
360
361
  className: "mt-4",
361
362
  type: "reply",
362
363
  placeholder: tip,
363
- insertContent: insertContent
364
+ insertContent: insertContent,
365
+ hiddenComment: hiddenComment
364
366
  }), isShowDeleteDialog && isActive && /*#__PURE__*/React.createElement(CommentDeleteShadow, {
365
367
  type: 'comment',
366
368
  deleteConfirm: _deleteComment,
@@ -12,7 +12,8 @@ import CommentItemWrapper from './comment-item-wrapper';
12
12
  import './comment-list.css';
13
13
  var CommentList = function CommentList(_ref) {
14
14
  var comments = _ref.comments,
15
- selectionElement = _ref.selectionElement;
15
+ selectionElement = _ref.selectionElement,
16
+ hiddenComment = _ref.hiddenComment;
16
17
  var commentRef = useRef(null);
17
18
  var position = useCommentListPosition();
18
19
  var _useState = useState(false),
@@ -102,7 +103,10 @@ var CommentList = function CommentList(_ref) {
102
103
  key: comment.id,
103
104
  comment: comment,
104
105
  isActive: isActive,
105
- onCommentClick: onCommentClick
106
+ onCommentClick: onCommentClick,
107
+ hiddenComment: function hiddenComment() {
108
+ return setActiveComment(null);
109
+ }
106
110
  };
107
111
  return /*#__PURE__*/React.createElement(CommentItemWrapper, props);
108
112
  })), comments.length === 0 && /*#__PURE__*/React.createElement("div", {
@@ -110,7 +114,8 @@ var CommentList = function CommentList(_ref) {
110
114
  }, /*#__PURE__*/React.createElement(CommentEditor, {
111
115
  type: "comment",
112
116
  insertContent: insertContent,
113
- selectionElement: selectionElement
117
+ selectionElement: selectionElement,
118
+ hiddenComment: hiddenComment
114
119
  })));
115
120
  };
116
121
  export default CommentList;
@@ -51,11 +51,16 @@ var EditorComment = function EditorComment() {
51
51
  setComments([]);
52
52
  setIsShowComments(false);
53
53
  }, [element_comments_map, selectionElement, editor.selection]);
54
+ var hiddenComment = useCallback(function () {
55
+ setComments([]);
56
+ setIsShowComments(false);
57
+ }, []);
54
58
  var onHiddenComment = useCallback(function (e) {
55
59
  if (e.target.className === 'article') {
56
- setComments([]);
57
- setIsShowComments(false);
60
+ hiddenComment();
58
61
  }
62
+
63
+ // eslint-disable-next-line react-hooks/exhaustive-deps
59
64
  }, []);
60
65
  useEffect(function () {
61
66
  window.addEventListener('click', onHiddenComment);
@@ -85,7 +90,8 @@ var EditorComment = function EditorComment() {
85
90
  } : null
86
91
  }, isShowComments && /*#__PURE__*/React.createElement(CommentList, {
87
92
  comments: comments,
88
- selectionElement: selectionElement
93
+ selectionElement: selectionElement,
94
+ hiddenComment: hiddenComment
89
95
  }))));
90
96
  };
91
97
  export default EditorComment;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.1.169beta",
3
+ "version": "0.1.170",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",