@seafile/sdoc-editor 0.1.116 → 0.1.117
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.
|
@@ -29,13 +29,16 @@ var SocketManager = /*#__PURE__*/_createClass(function SocketManager(editor, doc
|
|
|
29
29
|
_this.isSending = false;
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
|
+
if (_this._sendingOperations || _this.disconnect) return;
|
|
32
33
|
_this.dispatchConnectState('is-saving');
|
|
33
34
|
var version = _this.document.version;
|
|
34
35
|
var operations = _this.pendingOperationList.shift();
|
|
35
36
|
var selection = _this.editor.selection;
|
|
37
|
+
_this._sendingOperations = operations;
|
|
36
38
|
_this.socketClient.sendOperations(operations, version, selection, _this.sendOperationsCallback);
|
|
37
39
|
};
|
|
38
40
|
this.sendOperationsCallback = function (result) {
|
|
41
|
+
_this._sendingOperations = null;
|
|
39
42
|
if (result && result.success) {
|
|
40
43
|
var serverVersion = result.version;
|
|
41
44
|
_this.document['version'] = serverVersion;
|
|
@@ -55,6 +58,8 @@ var SocketManager = /*#__PURE__*/_createClass(function SocketManager(editor, doc
|
|
|
55
58
|
} else if (error_type === 'document_content_load_failed') {
|
|
56
59
|
// After a short-term reconnection, the content of the document fails to load
|
|
57
60
|
_this.dispatchConnectState(error_type);
|
|
61
|
+
} else if (error_type === 'Internal_server_error') {
|
|
62
|
+
_this.dispatchConnectState(error_type);
|
|
58
63
|
} else if (error_type === 'operation_exec_error') {
|
|
59
64
|
_this.editor.isRemote = true;
|
|
60
65
|
revertOperationList(_this.editor, [operations]);
|
|
@@ -76,15 +81,11 @@ var SocketManager = /*#__PURE__*/_createClass(function SocketManager(editor, doc
|
|
|
76
81
|
});
|
|
77
82
|
}
|
|
78
83
|
if (_this.isExecRemoteOperations) return;
|
|
84
|
+
|
|
85
|
+
// update execute remote operations flag
|
|
79
86
|
_this.isExecRemoteOperations = true;
|
|
80
87
|
_this.editor.isRemote = true;
|
|
81
88
|
_this.execRemoteOperations();
|
|
82
|
-
|
|
83
|
-
// reset control flag
|
|
84
|
-
Promise.resolve().then(function (_) {
|
|
85
|
-
_this.isExecRemoteOperations = false;
|
|
86
|
-
_this.editor.isRemote = false;
|
|
87
|
-
});
|
|
88
89
|
};
|
|
89
90
|
this.execRemoteOperations = function () {
|
|
90
91
|
if (_this.remoteOperationsList.length > 0) {
|
|
@@ -123,11 +124,14 @@ var SocketManager = /*#__PURE__*/_createClass(function SocketManager(editor, doc
|
|
|
123
124
|
// Re-execute undone operations after isRemote is set to false
|
|
124
125
|
// Need resend this operations to server
|
|
125
126
|
Promise.resolve().then(function (_) {
|
|
126
|
-
|
|
127
|
-
|
|
127
|
+
// reset execute remote operations flag
|
|
128
|
+
_this.isExecRemoteOperations = false;
|
|
129
|
+
_this.editor.isRemote = false;
|
|
128
130
|
|
|
129
131
|
// 3. Execute pending operations
|
|
130
132
|
// 3.1 Re-execute operations
|
|
133
|
+
debug('Editor isRemote is false: %s', _this.editor.isRemote);
|
|
134
|
+
debug('Re-execute pending operations, %O', _this.revertOperationList);
|
|
131
135
|
reExecRevertOperationList(_this.editor, _this.revertOperationList);
|
|
132
136
|
|
|
133
137
|
// 3.2 Clear revert operationList
|
|
@@ -168,15 +172,11 @@ var SocketManager = /*#__PURE__*/_createClass(function SocketManager(editor, doc
|
|
|
168
172
|
// sync operations
|
|
169
173
|
// content is [{version, operations}, {version, operations}, ...]
|
|
170
174
|
_this.remoteOperationsList = content;
|
|
175
|
+
|
|
176
|
+
// update execute remote operations flag
|
|
171
177
|
_this.isExecRemoteOperations = true;
|
|
172
178
|
_this.editor.isRemote = true;
|
|
173
179
|
_this.execRemoteOperations();
|
|
174
|
-
|
|
175
|
-
// reset control flag
|
|
176
|
-
Promise.resolve().then(function (_) {
|
|
177
|
-
_this.isExecRemoteOperations = false;
|
|
178
|
-
_this.editor.isRemote = false;
|
|
179
|
-
});
|
|
180
180
|
};
|
|
181
181
|
this.sendCursorLocation = function (location) {
|
|
182
182
|
_this.socketClient.sendCursorLocation(location);
|
|
@@ -193,6 +193,21 @@ var SocketManager = /*#__PURE__*/_createClass(function SocketManager(editor, doc
|
|
|
193
193
|
deleteCursor(_this.editor, message);
|
|
194
194
|
_this.editor.onCursor && _this.editor.onCursor(_this.editor.cursors);
|
|
195
195
|
}
|
|
196
|
+
if (type === 'disconnect') {
|
|
197
|
+
if (_this._sendingOperations) {
|
|
198
|
+
_this.pendingOperationList.unshift(_this._sendingOperations.slice());
|
|
199
|
+
_this._sendingOperations = null;
|
|
200
|
+
}
|
|
201
|
+
_this.isSending = false;
|
|
202
|
+
_this.disconnect = true;
|
|
203
|
+
|
|
204
|
+
// Update saved state
|
|
205
|
+
var lastSavedAt = new Date().getTime();
|
|
206
|
+
_this.dispatchConnectState('saved', lastSavedAt);
|
|
207
|
+
}
|
|
208
|
+
if (type === 'reconnect') {
|
|
209
|
+
_this.disconnect = false;
|
|
210
|
+
}
|
|
196
211
|
_this.eventBus.dispatch(type, message);
|
|
197
212
|
};
|
|
198
213
|
this.closeSocketConnect = function () {
|
|
@@ -39,6 +39,14 @@ var TipMessage = /*#__PURE__*/function (_React$Component) {
|
|
|
39
39
|
duration: null
|
|
40
40
|
});
|
|
41
41
|
};
|
|
42
|
+
_this.onOperationsSaveError = function () {
|
|
43
|
+
var t = _this.props.t;
|
|
44
|
+
var message = t('Operations_save_error_tip');
|
|
45
|
+
toaster.danger(message, {
|
|
46
|
+
hasCloseButton: false,
|
|
47
|
+
duration: null
|
|
48
|
+
});
|
|
49
|
+
};
|
|
42
50
|
_this.onDisconnect = function () {
|
|
43
51
|
var _this$props = _this.props,
|
|
44
52
|
t = _this$props.t,
|
|
@@ -138,6 +146,7 @@ var TipMessage = /*#__PURE__*/function (_React$Component) {
|
|
|
138
146
|
this.unsubscribeOpExecError = eventBus.subscribe('operation_exec_error', this.onOperationExecuteError);
|
|
139
147
|
this.unsubscribePendingOpExceedLimit = eventBus.subscribe('pending_operations_exceed_limit', this.onPendingOpExceedLimit);
|
|
140
148
|
this.unsubscribeDocumentLoadError = eventBus.subscribe('document_content_load_failed', this.onDocumentLoadError);
|
|
149
|
+
this.unsubscribeOperationsSaveError = eventBus.subscribe('Internal_server_error', this.onOperationsSaveError);
|
|
141
150
|
}
|
|
142
151
|
}, {
|
|
143
152
|
key: "componentWillUnmount",
|
package/package.json
CHANGED
|
@@ -349,5 +349,6 @@
|
|
|
349
349
|
"Icon_and_text_Link": "Icon and text Link",
|
|
350
350
|
"Card": "Card",
|
|
351
351
|
"Select_sdoc_document": "Select sdoc document",
|
|
352
|
-
"Local_file": "Local file"
|
|
352
|
+
"Local_file": "Local file",
|
|
353
|
+
"Operations_save_error_tip": "Operation execution failed, internal server error, please refresh the page"
|
|
353
354
|
}
|