@seafile/sdoc-editor 2.0.102 → 2.0.103
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.
|
@@ -27,7 +27,8 @@ var CommentItemCollapseWrapper = function CommentItemCollapseWrapper(_ref) {
|
|
|
27
27
|
editor = _ref.editor,
|
|
28
28
|
replyCount = _ref.replyCount,
|
|
29
29
|
setCurrentCommentGroup = _ref.setCurrentCommentGroup,
|
|
30
|
-
t = _ref.t
|
|
30
|
+
t = _ref.t,
|
|
31
|
+
deleteUnseenNotifications = _ref.deleteUnseenNotifications;
|
|
31
32
|
var scrollRef = (0, _react.useRef)(document.querySelector('.sdoc-scroll-container'));
|
|
32
33
|
var _useNotificationConte = (0, _notificationHooks.useNotificationContext)(),
|
|
33
34
|
notificationsInfo = _useNotificationConte.notificationsInfo;
|
|
@@ -39,15 +40,49 @@ var CommentItemCollapseWrapper = function CommentItemCollapseWrapper(_ref) {
|
|
|
39
40
|
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
40
41
|
replyContent = _useState4[0],
|
|
41
42
|
setReplyContent = _useState4[1];
|
|
43
|
+
var CommentItemListRef = (0, _react.useRef)();
|
|
44
|
+
var timeoutRef = (0, _react.useRef)(null);
|
|
42
45
|
var isUnseen = notificationsInfo.notifications_map["sdoc_notification_".concat(topLevelComment.id)] ? true : false;
|
|
43
46
|
var isReplayUnseen = (0, _react.useMemo)(function () {
|
|
44
47
|
if (!latestReply) return false;
|
|
45
48
|
var isUnseen = notificationsInfo.notifications_map["sdoc_notification_".concat(topLevelComment.id, "_").concat(latestReply.id)] ? true : false;
|
|
46
49
|
return isUnseen;
|
|
47
50
|
}, [latestReply, notificationsInfo.notifications_map, topLevelComment.id]);
|
|
51
|
+
(0, _react.useEffect)(function () {
|
|
52
|
+
if (!CommentItemListRef.current) return;
|
|
53
|
+
if (!(isUnseen || isReplayUnseen)) return;
|
|
54
|
+
var observer = new IntersectionObserver(function (_ref2) {
|
|
55
|
+
var _ref3 = (0, _slicedToArray2["default"])(_ref2, 1),
|
|
56
|
+
entry = _ref3[0];
|
|
57
|
+
var isVisible = entry.isIntersecting && entry.intersectionRatio === 1;
|
|
58
|
+
if (isVisible) {
|
|
59
|
+
if (!timeoutRef.current) {
|
|
60
|
+
timeoutRef.current = setTimeout(function () {
|
|
61
|
+
deleteUnseenNotifications && deleteUnseenNotifications(topLevelComment);
|
|
62
|
+
timeoutRef.current = null;
|
|
63
|
+
}, 3000);
|
|
64
|
+
} else {
|
|
65
|
+
if (timeoutRef.current) {
|
|
66
|
+
clearTimeout(timeoutRef.current);
|
|
67
|
+
timeoutRef.current = null;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}, {
|
|
72
|
+
threshold: [1.0]
|
|
73
|
+
});
|
|
74
|
+
if (CommentItemListRef.current) observer.observe(CommentItemListRef.current);
|
|
75
|
+
return function () {
|
|
76
|
+
observer.disconnect();
|
|
77
|
+
if (timeoutRef.current) {
|
|
78
|
+
clearTimeout(timeoutRef.current);
|
|
79
|
+
timeoutRef.current = null;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}, [deleteUnseenNotifications, isReplayUnseen, isUnseen, topLevelComment]);
|
|
48
83
|
(0, _react.useEffect)(function () {
|
|
49
84
|
var initCommentContent = /*#__PURE__*/function () {
|
|
50
|
-
var
|
|
85
|
+
var _ref4 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee() {
|
|
51
86
|
var htmlString;
|
|
52
87
|
return (0, _regeneratorRuntime2["default"])().wrap(function _callee$(_context) {
|
|
53
88
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -64,14 +99,14 @@ var CommentItemCollapseWrapper = function CommentItemCollapseWrapper(_ref) {
|
|
|
64
99
|
}, _callee);
|
|
65
100
|
}));
|
|
66
101
|
return function initCommentContent() {
|
|
67
|
-
return
|
|
102
|
+
return _ref4.apply(this, arguments);
|
|
68
103
|
};
|
|
69
104
|
}();
|
|
70
105
|
initCommentContent();
|
|
71
106
|
}, [topLevelComment.comment]);
|
|
72
107
|
(0, _react.useEffect)(function () {
|
|
73
108
|
var initReplyContent = /*#__PURE__*/function () {
|
|
74
|
-
var
|
|
109
|
+
var _ref5 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee2() {
|
|
75
110
|
var mdString, htmlString;
|
|
76
111
|
return (0, _regeneratorRuntime2["default"])().wrap(function _callee2$(_context2) {
|
|
77
112
|
while (1) switch (_context2.prev = _context2.next) {
|
|
@@ -101,7 +136,7 @@ var CommentItemCollapseWrapper = function CommentItemCollapseWrapper(_ref) {
|
|
|
101
136
|
}, _callee2);
|
|
102
137
|
}));
|
|
103
138
|
return function initReplyContent() {
|
|
104
|
-
return
|
|
139
|
+
return _ref5.apply(this, arguments);
|
|
105
140
|
};
|
|
106
141
|
}();
|
|
107
142
|
initReplyContent();
|
|
@@ -149,7 +184,8 @@ var CommentItemCollapseWrapper = function CommentItemCollapseWrapper(_ref) {
|
|
|
149
184
|
}), /*#__PURE__*/_react["default"].createElement("div", {
|
|
150
185
|
className: "comment-item-selected-text"
|
|
151
186
|
}, _slate.Node.string(element))), /*#__PURE__*/_react["default"].createElement("div", {
|
|
152
|
-
className: "comment-item-list"
|
|
187
|
+
className: "comment-item-list",
|
|
188
|
+
ref: CommentItemListRef
|
|
153
189
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
154
190
|
className: "comment-item"
|
|
155
191
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
@@ -207,7 +207,8 @@ var GlobalComment = function GlobalComment(_ref) {
|
|
|
207
207
|
topLevelComment: comment,
|
|
208
208
|
replyCount: replyCount,
|
|
209
209
|
latestReply: latestReply,
|
|
210
|
-
setCurrentCommentGroup: setCurrentCommentGroup
|
|
210
|
+
setCurrentCommentGroup: setCurrentCommentGroup,
|
|
211
|
+
deleteUnseenNotifications: deleteUnseenNotifications
|
|
211
212
|
});
|
|
212
213
|
}), activeCommentGroup && /*#__PURE__*/_react["default"].createElement(_commentItemWrapper["default"], {
|
|
213
214
|
key: activeCommentGroup.id,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seafile/sdoc-editor",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.103",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "jest",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"publishConfig": {
|
|
71
71
|
"access": "public"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "f39fbe4fc1914c923390805564ebf725ccaf6b72"
|
|
74
74
|
}
|