@seafile/sdoc-editor 2.0.122-test-0.0.1 → 2.0.122-test-0.0.3

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.
@@ -80,11 +80,13 @@ var CommentArticle = function CommentArticle(_ref) {
80
80
  }
81
81
  eventProxy.onKeyDown(event);
82
82
  }, [eventProxy, editor]);
83
+ console.log(1, type);
83
84
  return /*#__PURE__*/_react["default"].createElement(_slateReact.Slate, {
84
85
  editor: editor,
85
86
  value: slateValue,
86
87
  onChange: updateSlateValue
87
88
  }, /*#__PURE__*/_react["default"].createElement(_slateReact.Editable, {
89
+ tabIndex: 0,
88
90
  id: "sdoc-editor",
89
91
  scrollSelectionIntoView: handleScrollIntoView,
90
92
  cursors: cursors,
@@ -44,7 +44,7 @@ var SdocCommentEditor = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref)
44
44
  slateValue = _useState2[0],
45
45
  _setSlateValue = _useState2[1];
46
46
  var commentEditorContainerRef = (0, _react.useRef)(null);
47
- var timeoutRef = (0, _react.useRef)(null);
47
+ var commentTimeoutRef = (0, _react.useRef)(null);
48
48
  var _useNotificationConte = (0, _notificationHooks.useNotificationContext)(),
49
49
  notificationsInfo = _useNotificationConte.notificationsInfo;
50
50
  var _useTranslation = (0, _reactI18next.useTranslation)('sdoc-editor'),
@@ -65,8 +65,10 @@ var SdocCommentEditor = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref)
65
65
  // eslint-disable-next-line react-hooks/exhaustive-deps
66
66
  }, []);
67
67
  (0, _react.useEffect)(function () {
68
+ console.log(1111, commentEditorContainerRef === null || commentEditorContainerRef === void 0 ? void 0 : commentEditorContainerRef.current, notificationsInfo);
69
+ console.log(22, commentEditorContainerRef.current.closest('.global-comment-input-wrapper'));
68
70
  if (!(commentEditorContainerRef !== null && commentEditorContainerRef !== void 0 && commentEditorContainerRef.current)) return;
69
- if (notificationsInfo.notifications_map.length === 0) return;
71
+ // if (Object.keys(notificationsInfo.notifications_map || {}).length === 0 ) return;
70
72
  if (!commentEditorContainerRef.current.closest('.global-comment-input-wrapper')) return;
71
73
  var clearAllNotification = /*#__PURE__*/function () {
72
74
  var _ref2 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee() {
@@ -107,22 +109,28 @@ var SdocCommentEditor = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref)
107
109
  var el = commentEditorContainerRef && commentEditorContainerRef.current;
108
110
 
109
111
  // Mark comment read if focusing commentEditorContainerRef over 3s
110
- var handleFocus = function handleFocus() {
111
- timeoutRef.current = setTimeout(function () {
112
+ var handleFocusIn = function handleFocusIn(e) {
113
+ console.log(5, e.target);
114
+ commentTimeoutRef.current = setTimeout(function () {
112
115
  clearAllNotification();
116
+ commentTimeoutRef.current = null;
113
117
  }, 3000);
114
118
  };
115
119
  var handleBlur = function handleBlur() {
116
- clearTimeout(timeoutRef.current);
120
+ clearTimeout(commentTimeoutRef.current);
121
+ commentTimeoutRef.current = null;
117
122
  };
118
- el.addEventListener('focus', handleFocus);
119
- el.addEventListener('blur', handleBlur);
123
+ el.addEventListener('focusin', handleFocusIn);
124
+ el.addEventListener('focusout', handleBlur);
120
125
  return function () {
121
- el.removeEventListener('focus', handleFocus);
122
- el.removeEventListener('blur', handleBlur);
123
- clearTimeout(timeoutRef.current);
126
+ el.removeEventListener('focusin', handleFocusIn);
127
+ el.removeEventListener('focusout', handleBlur);
128
+ if (commentTimeoutRef.current) {
129
+ clearTimeout(commentTimeoutRef.current);
130
+ commentTimeoutRef.current = null;
131
+ }
124
132
  };
125
- }, [notificationsInfo.notifications_map, t]);
133
+ }, [notificationsInfo]);
126
134
 
127
135
  // useMount: focus editor
128
136
  (0, _react.useEffect)(function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "2.0.122-test-0.0.1",
3
+ "version": "2.0.122-test-0.0.3",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "test": "jest",