@seafile/sdoc-editor 2.0.123 → 2.0.124
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 commentTimeoutRef = (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,70 @@ 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 (Object.keys(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 as read if focusing commentEditorContainerRef over 3s
|
|
110
|
+
var handleFocusIn = function handleFocusIn(e) {
|
|
111
|
+
commentTimeoutRef.current = setTimeout(function () {
|
|
112
|
+
clearAllNotification();
|
|
113
|
+
commentTimeoutRef.current = null;
|
|
114
|
+
}, 3000);
|
|
115
|
+
};
|
|
116
|
+
var handleBlur = function handleBlur() {
|
|
117
|
+
clearTimeout(commentTimeoutRef.current);
|
|
118
|
+
commentTimeoutRef.current = null;
|
|
119
|
+
};
|
|
120
|
+
el.addEventListener('focusin', handleFocusIn);
|
|
121
|
+
el.addEventListener('focusout', handleBlur);
|
|
122
|
+
return function () {
|
|
123
|
+
el.removeEventListener('focusin', handleFocusIn);
|
|
124
|
+
el.removeEventListener('focusout', handleBlur);
|
|
125
|
+
if (commentTimeoutRef.current) {
|
|
126
|
+
clearTimeout(commentTimeoutRef.current);
|
|
127
|
+
commentTimeoutRef.current = null;
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
}, [notificationsInfo]);
|
|
55
131
|
|
|
56
132
|
// useMount: focus editor
|
|
57
133
|
(0, _react.useEffect)(function () {
|
|
@@ -16,6 +16,7 @@ var _slugid = _interopRequireDefault(require("slugid"));
|
|
|
16
16
|
var _urlJoin = _interopRequireDefault(require("url-join"));
|
|
17
17
|
var _constants = require("../../../constants");
|
|
18
18
|
var _context2 = _interopRequireDefault(require("../../../context"));
|
|
19
|
+
var _socketManager = _interopRequireDefault(require("../../../socket/socket-manager"));
|
|
19
20
|
var _eventBus = _interopRequireDefault(require("../../../utils/event-bus"));
|
|
20
21
|
var _constants2 = require("../../constants");
|
|
21
22
|
var _core = require("../../core");
|
|
@@ -209,7 +210,7 @@ var queryCopyMoveProgressView = exports.queryCopyMoveProgressView = function que
|
|
|
209
210
|
};
|
|
210
211
|
var _start = /*#__PURE__*/function () {
|
|
211
212
|
var _ref3 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee() {
|
|
212
|
-
var res, successful, eventBus;
|
|
213
|
+
var res, successful, eventBus, socketManager;
|
|
213
214
|
return (0, _regeneratorRuntime2["default"])().wrap(function _callee$(_context) {
|
|
214
215
|
while (1) switch (_context.prev = _context.next) {
|
|
215
216
|
case 0:
|
|
@@ -223,6 +224,8 @@ var queryCopyMoveProgressView = exports.queryCopyMoveProgressView = function que
|
|
|
223
224
|
// Reload image
|
|
224
225
|
eventBus = _eventBus["default"].getInstance();
|
|
225
226
|
eventBus.dispatch(_constants.INTERNAL_EVENT.RELOAD_IMAGE);
|
|
227
|
+
socketManager = _socketManager["default"].getInstance();
|
|
228
|
+
socketManager.sendReloadImage();
|
|
226
229
|
} else {
|
|
227
230
|
timer = setTimeout(_start, interval);
|
|
228
231
|
}
|
|
@@ -93,6 +93,12 @@ var SocketClient = /*#__PURE__*/(0, _createClass2["default"])(function SocketCli
|
|
|
93
93
|
doc_uuid: docUuid
|
|
94
94
|
});
|
|
95
95
|
});
|
|
96
|
+
(0, _defineProperty2["default"])(this, "sendReloadImage", function () {
|
|
97
|
+
var docUuid = _this.config.docUuid;
|
|
98
|
+
_this.socket.emit('reload-image', {
|
|
99
|
+
doc_uuid: docUuid
|
|
100
|
+
});
|
|
101
|
+
});
|
|
96
102
|
(0, _defineProperty2["default"])(this, "onJoinRoom", function (userInfo) {
|
|
97
103
|
(0, _debug.serverDebug)('%s joined room success.', userInfo.username);
|
|
98
104
|
var socketManager = _socketManager["default"].getInstance();
|
|
@@ -108,6 +114,11 @@ var SocketClient = /*#__PURE__*/(0, _createClass2["default"])(function SocketCli
|
|
|
108
114
|
var socketManager = _socketManager["default"].getInstance();
|
|
109
115
|
socketManager.dispatchConnectState('user-updated', userInfo);
|
|
110
116
|
});
|
|
117
|
+
(0, _defineProperty2["default"])(this, "onReloadImage", function () {
|
|
118
|
+
(0, _debug.serverDebug)('Reload image by other people copy images from different repos');
|
|
119
|
+
var socketManager = _socketManager["default"].getInstance();
|
|
120
|
+
socketManager.dispatchConnectState('reload_image');
|
|
121
|
+
});
|
|
111
122
|
/**
|
|
112
123
|
* receive remote broadcast operations
|
|
113
124
|
* @param {*} params {operations, version}
|
|
@@ -197,6 +208,7 @@ var SocketClient = /*#__PURE__*/(0, _createClass2["default"])(function SocketCli
|
|
|
197
208
|
this.socket.on('join-room', this.onJoinRoom);
|
|
198
209
|
this.socket.on('leave-room', this.onLeaveRoom);
|
|
199
210
|
this.socket.on('user-updated', this.onUserUpdated);
|
|
211
|
+
this.socket.on('reload-image', this.onReloadImage);
|
|
200
212
|
this.socket.on('update-document', this.onReceiveRemoteOperations);
|
|
201
213
|
|
|
202
214
|
// doc replaced
|
|
@@ -61,6 +61,9 @@ var SocketManager = /*#__PURE__*/(0, _createClass2["default"])(function SocketMa
|
|
|
61
61
|
(0, _defineProperty2["default"])(this, "sendUserUpdated", function (name) {
|
|
62
62
|
_this.socketClient.sendUserUpdated(name);
|
|
63
63
|
});
|
|
64
|
+
(0, _defineProperty2["default"])(this, "sendReloadImage", function () {
|
|
65
|
+
_this.socketClient.sendReloadImage();
|
|
66
|
+
});
|
|
64
67
|
(0, _defineProperty2["default"])(this, "onReceiveLocalOperations", function (operations) {
|
|
65
68
|
if (_this.editor.readonly) return;
|
|
66
69
|
_this.pendingOperationList.push(operations);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seafile/sdoc-editor",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.124",
|
|
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": "9b30ab7dd281cd78875a7a366e98b517aa4b47b9"
|
|
74
74
|
}
|