@seafile/sdoc-editor 2.0.120 → 2.0.122-test-0.0.1
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,65 @@ 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
|
+
if (!(commentEditorContainerRef !== null && commentEditorContainerRef !== void 0 && commentEditorContainerRef.current)) return;
|
|
69
|
+
if (notificationsInfo.notifications_map.length === 0) return;
|
|
70
|
+
if (!commentEditorContainerRef.current.closest('.global-comment-input-wrapper')) return;
|
|
71
|
+
var clearAllNotification = /*#__PURE__*/function () {
|
|
72
|
+
var _ref2 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee() {
|
|
73
|
+
var res, notifications, eventBus, errorMessage;
|
|
74
|
+
return (0, _regeneratorRuntime2["default"])().wrap(function _callee$(_context) {
|
|
75
|
+
while (1) switch (_context.prev = _context.next) {
|
|
76
|
+
case 0:
|
|
77
|
+
_context.prev = 0;
|
|
78
|
+
_context.next = 3;
|
|
79
|
+
return _context2["default"].readAllNotifications();
|
|
80
|
+
case 3:
|
|
81
|
+
_context.next = 5;
|
|
82
|
+
return _context2["default"].listUnseenNotifications();
|
|
83
|
+
case 5:
|
|
84
|
+
res = _context.sent;
|
|
85
|
+
notifications = res.data.notifications;
|
|
86
|
+
eventBus = _eventBus["default"].getInstance();
|
|
87
|
+
eventBus.dispatch(_constants.INTERNAL_EVENT.UNSEEN_NOTIFICATIONS_COUNT, notifications === null || notifications === void 0 ? void 0 : notifications.length);
|
|
88
|
+
eventBus.dispatch(_constants.INTERNAL_EVENT.NEW_NOTIFICATION);
|
|
89
|
+
eventBus.dispatch(_constants.INTERNAL_EVENT.CLEAR_NOTIFICATION);
|
|
90
|
+
_context.next = 17;
|
|
91
|
+
break;
|
|
92
|
+
case 13:
|
|
93
|
+
_context.prev = 13;
|
|
94
|
+
_context.t0 = _context["catch"](0);
|
|
95
|
+
errorMessage = (0, _commonUtils.getErrorMsg)(_context.t0);
|
|
96
|
+
_toast["default"].danger(t(errorMessage));
|
|
97
|
+
case 17:
|
|
98
|
+
case "end":
|
|
99
|
+
return _context.stop();
|
|
100
|
+
}
|
|
101
|
+
}, _callee, null, [[0, 13]]);
|
|
102
|
+
}));
|
|
103
|
+
return function clearAllNotification() {
|
|
104
|
+
return _ref2.apply(this, arguments);
|
|
105
|
+
};
|
|
106
|
+
}();
|
|
107
|
+
var el = commentEditorContainerRef && commentEditorContainerRef.current;
|
|
108
|
+
|
|
109
|
+
// Mark comment read if focusing commentEditorContainerRef over 3s
|
|
110
|
+
var handleFocus = function handleFocus() {
|
|
111
|
+
timeoutRef.current = setTimeout(function () {
|
|
112
|
+
clearAllNotification();
|
|
113
|
+
}, 3000);
|
|
114
|
+
};
|
|
115
|
+
var handleBlur = function handleBlur() {
|
|
116
|
+
clearTimeout(timeoutRef.current);
|
|
117
|
+
};
|
|
118
|
+
el.addEventListener('focus', handleFocus);
|
|
119
|
+
el.addEventListener('blur', handleBlur);
|
|
120
|
+
return function () {
|
|
121
|
+
el.removeEventListener('focus', handleFocus);
|
|
122
|
+
el.removeEventListener('blur', handleBlur);
|
|
123
|
+
clearTimeout(timeoutRef.current);
|
|
124
|
+
};
|
|
125
|
+
}, [notificationsInfo.notifications_map, t]);
|
|
55
126
|
|
|
56
127
|
// useMount: focus editor
|
|
57
128
|
(0, _react.useEffect)(function () {
|
|
@@ -223,7 +223,6 @@ var queryCopyMoveProgressView = exports.queryCopyMoveProgressView = function que
|
|
|
223
223
|
// Reload image
|
|
224
224
|
eventBus = _eventBus["default"].getInstance();
|
|
225
225
|
eventBus.dispatch(_constants.INTERNAL_EVENT.RELOAD_IMAGE);
|
|
226
|
-
console.log('xiexieni');
|
|
227
226
|
} else {
|
|
228
227
|
timer = setTimeout(_start, interval);
|
|
229
228
|
}
|
|
@@ -225,13 +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
|
-
imageRef.current['src'] = (0, _helpers.getImageURL)(data, editor);
|
|
231
|
-
console.log('adddd');
|
|
232
|
-
setIsShowImagePlaceholder(false);
|
|
233
|
-
}
|
|
234
|
-
}, [data, editor]);
|
|
228
|
+
setIsShowImagePlaceholder(false);
|
|
229
|
+
}, []);
|
|
235
230
|
var onImageLoaded = (0, _react.useCallback)(function () {
|
|
236
231
|
if ((0, _helpers.isImageUrlIsFromCopy)(data.src) && !(0, _helpers.isCommentEditor)(editor)) {
|
|
237
232
|
setCopyImageLoading(true);
|
|
@@ -243,6 +238,7 @@ var Image = function Image(_ref) {
|
|
|
243
238
|
return (0, _helpers.handleBase64Image)(editor, path, data);
|
|
244
239
|
}
|
|
245
240
|
setIsShowImagePlaceholder(true);
|
|
241
|
+
console.log(data.src);
|
|
246
242
|
// External network images do not reload after failure to load
|
|
247
243
|
if (!data.src.startsWith('http')) {
|
|
248
244
|
var eventBus = _eventBus["default"].getInstance();
|
|
@@ -269,7 +265,6 @@ var Image = function Image(_ref) {
|
|
|
269
265
|
});
|
|
270
266
|
}
|
|
271
267
|
}, [data, editor, element]);
|
|
272
|
-
console.log(isShowImagePlaceholder);
|
|
273
268
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, isShowImagePlaceholder && /*#__PURE__*/_react["default"].createElement("span", Object.assign({
|
|
274
269
|
className: (0, _classnames["default"])('sdoc-image-wrapper', className)
|
|
275
270
|
}, attributes, {
|
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.1",
|
|
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": "ed7790e36b4da8046dee63ee46eb52d602d4fbdd"
|
|
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.
|