@seafile/sdoc-editor 2.0.121 → 2.0.122-test-0.0.2
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.
|
@@ -8,13 +8,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports["default"] = void 0;
|
|
9
9
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
|
|
10
10
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/toConsumableArray"));
|
|
11
|
+
var _regeneratorRuntime2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/regeneratorRuntime"));
|
|
12
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/asyncToGenerator"));
|
|
11
13
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
|
|
12
14
|
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
+
var _reactI18next = require("react-i18next");
|
|
13
16
|
var _slate = require("@seafile/slate");
|
|
14
17
|
var _deepCopy = _interopRequireDefault(require("deep-copy"));
|
|
18
|
+
var _notificationHooks = require("../comment/hooks/notification-hooks");
|
|
15
19
|
var _fileLoading = _interopRequireDefault(require("../components/file-loading"));
|
|
20
|
+
var _toast = _interopRequireDefault(require("../components/toast"));
|
|
16
21
|
var _constants = require("../constants");
|
|
17
|
-
var
|
|
22
|
+
var _context2 = _interopRequireDefault(require("../context"));
|
|
18
23
|
var _extension = require("../extension");
|
|
19
24
|
var _core = require("../extension/core");
|
|
20
25
|
var _commentEditorToolbar = _interopRequireDefault(require("../extension/toolbar/comment-editor-toolbar"));
|
|
@@ -23,6 +28,8 @@ var _useScrollContext = require("../hooks/use-scroll-context");
|
|
|
23
28
|
var _layout = require("../layout");
|
|
24
29
|
var _nodeId = _interopRequireDefault(require("../node-id"));
|
|
25
30
|
var _socket = require("../socket");
|
|
31
|
+
var _commonUtils = require("../utils/common-utils");
|
|
32
|
+
var _eventBus = _interopRequireDefault(require("../utils/event-bus"));
|
|
26
33
|
var _commentArticle = _interopRequireDefault(require("./comment-article"));
|
|
27
34
|
var SdocCommentEditor = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
28
35
|
var propsEditor = _ref.editor,
|
|
@@ -37,10 +44,15 @@ var SdocCommentEditor = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref)
|
|
|
37
44
|
slateValue = _useState2[0],
|
|
38
45
|
_setSlateValue = _useState2[1];
|
|
39
46
|
var commentEditorContainerRef = (0, _react.useRef)(null);
|
|
47
|
+
var timeoutRef = (0, _react.useRef)(null);
|
|
48
|
+
var _useNotificationConte = (0, _notificationHooks.useNotificationContext)(),
|
|
49
|
+
notificationsInfo = _useNotificationConte.notificationsInfo;
|
|
50
|
+
var _useTranslation = (0, _reactI18next.useTranslation)('sdoc-editor'),
|
|
51
|
+
t = _useTranslation.t;
|
|
40
52
|
var validEditor = (0, _react.useMemo)(function () {
|
|
41
53
|
if (propsEditor) return propsEditor;
|
|
42
54
|
var defaultEditor = (0, _extension.createCommentEditor)();
|
|
43
|
-
var editorConfig =
|
|
55
|
+
var editorConfig = _context2["default"].getEditorConfig();
|
|
44
56
|
var newEditor = (0, _nodeId["default"])((0, _socket.withSocketIO)(defaultEditor, {
|
|
45
57
|
document: document,
|
|
46
58
|
config: editorConfig
|
|
@@ -52,6 +64,69 @@ var SdocCommentEditor = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref)
|
|
|
52
64
|
return newEditor;
|
|
53
65
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
54
66
|
}, []);
|
|
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'));
|
|
70
|
+
if (!(commentEditorContainerRef !== null && commentEditorContainerRef !== void 0 && commentEditorContainerRef.current)) return;
|
|
71
|
+
if (Object.keys(notificationsInfo.notifications_map || {}).length === 0) return;
|
|
72
|
+
if (!commentEditorContainerRef.current.closest('.global-comment-input-wrapper')) return;
|
|
73
|
+
console.log(333);
|
|
74
|
+
var clearAllNotification = /*#__PURE__*/function () {
|
|
75
|
+
var _ref2 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee() {
|
|
76
|
+
var res, notifications, eventBus, errorMessage;
|
|
77
|
+
return (0, _regeneratorRuntime2["default"])().wrap(function _callee$(_context) {
|
|
78
|
+
while (1) switch (_context.prev = _context.next) {
|
|
79
|
+
case 0:
|
|
80
|
+
_context.prev = 0;
|
|
81
|
+
_context.next = 3;
|
|
82
|
+
return _context2["default"].readAllNotifications();
|
|
83
|
+
case 3:
|
|
84
|
+
_context.next = 5;
|
|
85
|
+
return _context2["default"].listUnseenNotifications();
|
|
86
|
+
case 5:
|
|
87
|
+
res = _context.sent;
|
|
88
|
+
notifications = res.data.notifications;
|
|
89
|
+
eventBus = _eventBus["default"].getInstance();
|
|
90
|
+
eventBus.dispatch(_constants.INTERNAL_EVENT.UNSEEN_NOTIFICATIONS_COUNT, notifications === null || notifications === void 0 ? void 0 : notifications.length);
|
|
91
|
+
eventBus.dispatch(_constants.INTERNAL_EVENT.NEW_NOTIFICATION);
|
|
92
|
+
eventBus.dispatch(_constants.INTERNAL_EVENT.CLEAR_NOTIFICATION);
|
|
93
|
+
_context.next = 17;
|
|
94
|
+
break;
|
|
95
|
+
case 13:
|
|
96
|
+
_context.prev = 13;
|
|
97
|
+
_context.t0 = _context["catch"](0);
|
|
98
|
+
errorMessage = (0, _commonUtils.getErrorMsg)(_context.t0);
|
|
99
|
+
_toast["default"].danger(t(errorMessage));
|
|
100
|
+
case 17:
|
|
101
|
+
case "end":
|
|
102
|
+
return _context.stop();
|
|
103
|
+
}
|
|
104
|
+
}, _callee, null, [[0, 13]]);
|
|
105
|
+
}));
|
|
106
|
+
return function clearAllNotification() {
|
|
107
|
+
return _ref2.apply(this, arguments);
|
|
108
|
+
};
|
|
109
|
+
}();
|
|
110
|
+
var el = commentEditorContainerRef && commentEditorContainerRef.current;
|
|
111
|
+
|
|
112
|
+
// Mark comment read if focusing commentEditorContainerRef over 3s
|
|
113
|
+
var handleFocusIn = function handleFocusIn() {
|
|
114
|
+
timeoutRef.current = setTimeout(function () {
|
|
115
|
+
console.log(1, 'clear');
|
|
116
|
+
clearAllNotification();
|
|
117
|
+
}, 3000);
|
|
118
|
+
};
|
|
119
|
+
var handleBlur = function handleBlur() {
|
|
120
|
+
clearTimeout(timeoutRef.current);
|
|
121
|
+
};
|
|
122
|
+
el.addEventListener('focusin', handleFocusIn);
|
|
123
|
+
el.addEventListener('focusout', handleBlur);
|
|
124
|
+
return function () {
|
|
125
|
+
el.removeEventListener('focusin', handleFocusIn);
|
|
126
|
+
el.removeEventListener('focusout', handleBlur);
|
|
127
|
+
clearTimeout(timeoutRef.current);
|
|
128
|
+
};
|
|
129
|
+
}, [notificationsInfo, t]);
|
|
55
130
|
|
|
56
131
|
// useMount: focus editor
|
|
57
132
|
(0, _react.useEffect)(function () {
|
|
@@ -225,11 +225,8 @@ var Image = function Image(_ref) {
|
|
|
225
225
|
setIsShowImageHoverMenu(true);
|
|
226
226
|
}, [setPosition]);
|
|
227
227
|
var reloadImage = (0, _react.useCallback)(function () {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
setIsShowImagePlaceholder(false);
|
|
231
|
-
}
|
|
232
|
-
}, [data, editor]);
|
|
228
|
+
setIsShowImagePlaceholder(false);
|
|
229
|
+
}, []);
|
|
233
230
|
var onImageLoaded = (0, _react.useCallback)(function () {
|
|
234
231
|
if ((0, _helpers.isImageUrlIsFromCopy)(data.src) && !(0, _helpers.isCommentEditor)(editor)) {
|
|
235
232
|
setCopyImageLoading(true);
|
|
@@ -241,6 +238,7 @@ var Image = function Image(_ref) {
|
|
|
241
238
|
return (0, _helpers.handleBase64Image)(editor, path, data);
|
|
242
239
|
}
|
|
243
240
|
setIsShowImagePlaceholder(true);
|
|
241
|
+
console.log(data.src);
|
|
244
242
|
// External network images do not reload after failure to load
|
|
245
243
|
if (!data.src.startsWith('http')) {
|
|
246
244
|
var eventBus = _eventBus["default"].getInstance();
|
|
@@ -16,6 +16,7 @@ var RenderCommentEditorCustomRenderElement = function RenderCommentEditorCustomR
|
|
|
16
16
|
var readonly = (0, _slateReact.useReadOnly)();
|
|
17
17
|
var element = props.element,
|
|
18
18
|
commentType = props.commentType;
|
|
19
|
+
console.log(1, element);
|
|
19
20
|
switch (element.type) {
|
|
20
21
|
case _constants.PARAGRAPH:
|
|
21
22
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seafile/sdoc-editor",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.122-test-0.0.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "jest",
|
|
@@ -69,6 +69,5 @@
|
|
|
69
69
|
},
|
|
70
70
|
"publishConfig": {
|
|
71
71
|
"access": "public"
|
|
72
|
-
}
|
|
73
|
-
"gitHead": "8c9e96fe99d23442dfd23e849fc07fae8fed9048"
|
|
72
|
+
}
|
|
74
73
|
}
|
package/LICENSE.txt
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
Copyright (c) 2025 Seafile Ltd.
|
|
2
|
-
|
|
3
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
you may not use this file except in compliance with the License.
|
|
5
|
-
You may obtain a copy of the License at
|
|
6
|
-
|
|
7
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
|
|
9
|
-
Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
See the License for the specific language governing permissions and
|
|
13
|
-
limitations under the License.
|