@seafile/sdoc-editor 0.1.119 → 0.1.120

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.
@@ -65,30 +65,29 @@ var SocketManager = /*#__PURE__*/_createClass(function SocketManager(editor, doc
65
65
 
66
66
  // Operations are execute failure
67
67
  var error_type = result.error_type;
68
- if (error_type === 'version_behind_server') {
69
- // Put the failed operation into the pending list and re-execute it
70
- _this.pendingOperationList.unshift(_toConsumableArray(_this._sendingOperations));
71
- _this.state = STATE.CONFLICT;
72
- var lose_operations = result.lose_operations;
73
- _this.resolveConflicting(lose_operations);
74
- } else if (error_type === 'document_content_load_failed') {
75
- // After a short-term reconnection, the content of the document fails to load
76
- _this.dispatchConnectState(error_type);
77
-
78
- // reset sending control
79
- _this.state = STATE.NEED_RELOAD;
80
- _this._sendingOperations = null;
81
- } else if (error_type === 'Internal_server_error') {
68
+ if (error_type === 'load_document_content_error' || error_type === 'save_operations_to_database_error') {
69
+ // load_document_content_error: After a short-term reconnection, the content of the document fails to load
70
+ // save_operation_to_database_error: Save operation to database error
82
71
  _this.dispatchConnectState(error_type);
83
72
 
84
73
  // reset sending control
85
74
  _this.state = STATE.NEED_RELOAD;
86
75
  _this._sendingOperations = null;
87
- } else if (error_type === 'operation_exec_error') {
76
+ } else if (error_type === 'version_behind_server') {
77
+ // Put the failed operation into the pending list and re-execute it
78
+ _this.pendingOperationList.unshift(_toConsumableArray(_this._sendingOperations));
79
+ _this.state = STATE.CONFLICT;
80
+ var lose_operations = result.lose_operations;
81
+ _this.resolveConflicting(lose_operations);
82
+ } else if (error_type === 'execute_client_operations_error') {
88
83
  _this.editor.isRemote = true;
89
84
  var dupSendingOperations = _toConsumableArray(_this._sendingOperations);
90
85
  revertOperationList(_this.editor, [dupSendingOperations]);
91
86
 
87
+ // Update the save time after revert
88
+ var _lastSavedAt = new Date().getTime();
89
+ _this.dispatchConnectState('saved', _lastSavedAt);
90
+
92
91
  // Set isRemote to false must be in Promise.resolve function, make sure the modification of isRemote is later than the onChange event
93
92
  Promise.resolve().then(function (_) {
94
93
  _this.editor.isRemote = false;
@@ -112,7 +111,13 @@ var SocketManager = /*#__PURE__*/_createClass(function SocketManager(editor, doc
112
111
  var operations = params.operations;
113
112
  // Update content & version
114
113
  debug('execute remote operations: %O', operations);
115
- syncRemoteOperations(_this.editor, operations);
114
+ try {
115
+ syncRemoteOperations(_this.editor, operations);
116
+ } catch (error) {
117
+ _this.state = STATE.CONFLICT;
118
+ _this.dispatchConnectState('sync_server_operations_error');
119
+ return;
120
+ }
116
121
 
117
122
  // Update document
118
123
  _this.document.version = serverVersion;
@@ -197,7 +202,13 @@ var SocketManager = /*#__PURE__*/_createClass(function SocketManager(editor, doc
197
202
  serverVersion = operationParams.version;
198
203
  // 2.1 Update content & version
199
204
  debug('execute lose operations: %O', operations);
200
- syncRemoteOperations(_this.editor, operations);
205
+ try {
206
+ syncRemoteOperations(_this.editor, operations);
207
+ } catch (error) {
208
+ _this.state = STATE.CONFLICT;
209
+ _this.dispatchConnectState('sync_server_operations_error');
210
+ return;
211
+ }
201
212
 
202
213
  // 2.2 Update document
203
214
  _this.document.version = serverVersion;
@@ -18,35 +18,34 @@ var TipMessage = /*#__PURE__*/function (_React$Component) {
18
18
  _this.onOperationExecuteError = function () {
19
19
  var t = _this.props.t;
20
20
  var message = t('Failed_to_execute_operation_on_server');
21
- toaster.danger(message, {
22
- hasCloseButton: true,
23
- duration: null
24
- });
25
- };
26
- _this.onPendingOpExceedLimit = function () {
27
- var t = _this.props.t;
28
- toaster.closeAll();
29
- var message = t('Pending_operations_exceed_limit');
30
21
  toaster.warning(message, {
31
- duration: 5
22
+ hasCloseButton: true
32
23
  });
33
24
  };
34
- _this.onDocumentLoadError = function () {
25
+ _this.onSyncServerOperationError = function () {
35
26
  var t = _this.props.t;
36
- var message = t('Document_content_load_failed');
27
+ var message = t('Failed_to_sync_with_server_operations');
37
28
  toaster.danger(message, {
38
- hasCloseButton: true,
29
+ hasCloseButton: false,
39
30
  duration: null
40
31
  });
41
32
  };
42
- _this.onOperationsSaveError = function () {
33
+ _this.onInternalServerExecError = function () {
43
34
  var t = _this.props.t;
44
- var message = t('Operations_save_error_tip');
35
+ var message = t('Internal_server_exec_operations_error');
45
36
  toaster.danger(message, {
46
37
  hasCloseButton: false,
47
38
  duration: null
48
39
  });
49
40
  };
41
+ _this.onPendingOpExceedLimit = function () {
42
+ var t = _this.props.t;
43
+ toaster.closeAll();
44
+ var message = t('Pending_operations_exceed_limit');
45
+ toaster.warning(message, {
46
+ duration: 5
47
+ });
48
+ };
50
49
  _this.onDisconnect = function () {
51
50
  var _this$props = _this.props,
52
51
  t = _this$props.t,
@@ -142,18 +141,28 @@ var TipMessage = /*#__PURE__*/function (_React$Component) {
142
141
  this.unsubscribeReconnectErrorEvent = eventBus.subscribe('reconnect_error', this.onReconnectError);
143
142
  this.unsubscribeReconnectEvent = eventBus.subscribe('reconnect', this.onReconnect);
144
143
 
145
- // op execute error
146
- this.unsubscribeOpExecError = eventBus.subscribe('operation_exec_error', this.onOperationExecuteError);
144
+ // server return error
145
+ this.unsubscribeOpExecError = eventBus.subscribe('execute_client_operations_error', this.onOperationExecuteError);
146
+ this.unsubscribeSyncServerOpError = eventBus.subscribe('sync_server_operations_error', this.onSyncServerOperationError);
147
+ this.unsubscribeDocumentLoadError = eventBus.subscribe('load_document_content_error', this.onInternalServerExecError);
148
+ this.unsubscribeOperationsSaveError = eventBus.subscribe('save_operations_to_database_error', this.onInternalServerExecError);
149
+
150
+ // local error
147
151
  this.unsubscribePendingOpExceedLimit = eventBus.subscribe('pending_operations_exceed_limit', this.onPendingOpExceedLimit);
148
- this.unsubscribeDocumentLoadError = eventBus.subscribe('document_content_load_failed', this.onDocumentLoadError);
149
- this.unsubscribeOperationsSaveError = eventBus.subscribe('Internal_server_error', this.onOperationsSaveError);
150
152
  }
151
153
  }, {
152
154
  key: "componentWillUnmount",
153
155
  value: function componentWillUnmount() {
154
156
  this.unsubscribeSavingEvent();
155
157
  this.unsubscribeSavedEvent();
158
+ this.unsubscribeDisconnectEvent();
159
+ this.unsubscribeReconnectErrorEvent();
160
+ this.unsubscribeReconnectEvent();
161
+ this.unsubscribeOpExecError();
162
+ this.unsubscribeSyncServerOpError();
163
+ this.unsubscribePendingOpExceedLimit();
156
164
  this.unsubscribeDocumentLoadError();
165
+ this.unsubscribeOperationsSaveError();
157
166
  clearTimeout(this.saveTimer);
158
167
  }
159
168
  }]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.1.119",
3
+ "version": "0.1.120",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",
@@ -273,7 +273,7 @@
273
273
  "Revision": "Revision",
274
274
  "Error": "Error",
275
275
  "Start_revise": "Start revise",
276
- "Failed_to_execute_operation_on_server": "Failed to execute operation on server",
276
+ "Failed_to_execute_operation_on_server": "Failed to execute operation on server, the current operation has been withdrawn",
277
277
  "Start_revise_tip": "Create a temporary document and modify on it, merge it back after reviewing changes",
278
278
  "Load_doc_content_error": "Load doc content error",
279
279
  "Sdoc_format_invalid": "The content of the document does not conform to the sdoc specification",
@@ -341,7 +341,6 @@
341
341
  "Font": "Font",
342
342
  "All_fonts": "All fonts",
343
343
  "Default_font": "Default font",
344
- "Document_content_load_failed": "Document content failed to load, please refresh the page to try again",
345
344
  "Pending_operations_exceed_limit": "There are multiple operations not synced to the server. Please check your network.",
346
345
  "Recently_saved": "Recently saved",
347
346
  "Sdoc_document" : "Sdoc document",
@@ -350,5 +349,6 @@
350
349
  "Card": "Card",
351
350
  "Select_sdoc_document": "Select sdoc document",
352
351
  "Local_file": "Local file",
353
- "Operations_save_error_tip": "Operation execution failed, internal server error, please refresh the page"
352
+ "Internal_server_exec_operations_error": "An exception occurred on the server, please refresh the page and try again",
353
+ "Failed_to_sync_with_server_operations": "Synchronization with the server failed, please refresh the page"
354
354
  }
@@ -273,7 +273,7 @@
273
273
  "Revision": "修订稿",
274
274
  "Error": "错误",
275
275
  "Start_revise": "开始修订",
276
- "Failed_to_execute_operation_on_server": "无法在服务器上执行操作",
276
+ "Failed_to_execute_operation_on_server": "无法在服务器上执行操作,当前操作已经撤回",
277
277
  "Start_revise_tip": "创建一个临时文档并对其进行修订,检查更改后将其合并回来",
278
278
  "Load_doc_content_error": "加载文档内容错误",
279
279
  "Sdoc_format_invalid": "文档内容不符合 sdoc 规范",
@@ -343,7 +343,6 @@
343
343
  "Font": "字体",
344
344
  "All_fonts": "所有字体",
345
345
  "Default_font": "默认字体",
346
- "Document_content_load_failed": "文档内容加载失败, 请刷新页面重新访问",
347
346
  "Pending_operations_exceed_limit": "有多个操作未同步到服务器。请检查你的网络。",
348
347
  "Recently_saved": "最近保存",
349
348
  "Sdoc_document" : "sdoc 文档",
@@ -352,5 +351,6 @@
352
351
  "Card": "卡片",
353
352
  "Select_sdoc_document": "选择sdoc文档",
354
353
  "Local_file": "本地文件",
355
- "Operations_save_error_tip": "操作执行失败,服务器内部错误,请刷新页面"
354
+ "Internal_server_exec_operations_error": "在服务器执行操作异常,请刷新页面后重试",
355
+ "Failed_to_sync_with_server_operations": "与服务器同步操作失败,请刷新页面"
356
356
  }