@seafile/sdoc-editor 0.1.110 → 0.1.111

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.
@@ -10,6 +10,9 @@ var SocketManager = /*#__PURE__*/_createClass(function SocketManager(editor, doc
10
10
  _classCallCheck(this, SocketManager);
11
11
  this.addOperations = function (operations) {
12
12
  _this.pendingOperationList.push(operations);
13
+ if (_this.pendingOperationList.length > 5) {
14
+ _this.dispatchConnectState('pending_operations_exceed_limit');
15
+ }
13
16
  _this.sendOperations();
14
17
  };
15
18
  this.getDocumentVersion = function () {
@@ -36,7 +39,8 @@ var SocketManager = /*#__PURE__*/_createClass(function SocketManager(editor, doc
36
39
  if (result && result.success) {
37
40
  var serverVersion = result.version;
38
41
  _this.document['version'] = serverVersion;
39
- _this.dispatchConnectState('saved');
42
+ var lastSavedAt = new Date().getTime();
43
+ _this.dispatchConnectState('saved', lastSavedAt);
40
44
  _this.sendNextOperations();
41
45
  return;
42
46
  }
@@ -4,6 +4,7 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
4
4
  import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
5
  import React from 'react';
6
6
  import { withTranslation } from 'react-i18next';
7
+ import dayjs from 'dayjs';
7
8
  import { EventBus } from '../../basic-sdk';
8
9
  import toaster from '../toast';
9
10
  import './style.css';
@@ -22,6 +23,14 @@ var TipMessage = /*#__PURE__*/function (_React$Component) {
22
23
  duration: null
23
24
  });
24
25
  };
26
+ _this.onPendingOpExceedLimit = function () {
27
+ var t = _this.props.t;
28
+ toaster.closeAll();
29
+ var message = t('Pending_operations_exceed_limit');
30
+ toaster.warning(message, {
31
+ duration: 5
32
+ });
33
+ };
25
34
  _this.onDocumentLoadError = function () {
26
35
  var t = _this.props.t;
27
36
  var message = t('Document_content_load_failed');
@@ -66,11 +75,12 @@ var TipMessage = /*#__PURE__*/function (_React$Component) {
66
75
  isSaved: false
67
76
  });
68
77
  };
69
- _this.onDocumentSaved = function () {
78
+ _this.onDocumentSaved = function (lastSavedAt) {
70
79
  if (_this.saveTimer) clearTimeout(_this.saveTimer);
71
80
  if (_this.resetTimer) clearTimeout(_this.resetTimer);
72
81
  _this.saveTimer = setTimeout(function () {
73
82
  _this.setState({
83
+ lastSavedAt: lastSavedAt,
74
84
  isSaving: false,
75
85
  isSaved: true
76
86
  });
@@ -86,7 +96,8 @@ var TipMessage = /*#__PURE__*/function (_React$Component) {
86
96
  var t = _this.props.t;
87
97
  var _this$state = _this.state,
88
98
  isSaved = _this$state.isSaved,
89
- isSaving = _this$state.isSaving;
99
+ isSaving = _this$state.isSaving,
100
+ lastSavedAt = _this$state.lastSavedAt;
90
101
  if (isSaving && !isSaved) {
91
102
  return /*#__PURE__*/React.createElement("span", {
92
103
  className: "tip-message"
@@ -97,11 +108,17 @@ var TipMessage = /*#__PURE__*/function (_React$Component) {
97
108
  className: "tip-message"
98
109
  }, t('All_changes_saved'));
99
110
  }
111
+ if (lastSavedAt) {
112
+ return /*#__PURE__*/React.createElement("span", {
113
+ className: "tip-message"
114
+ }, /*#__PURE__*/React.createElement("span", null, t('Recently_saved'), ' '), /*#__PURE__*/React.createElement("span", null, dayjs(lastSavedAt).format('HH:mm')));
115
+ }
100
116
  return null;
101
117
  };
102
118
  _this.state = {
103
119
  isSaved: false,
104
- isSaving: false
120
+ isSaving: false,
121
+ lastSavedAt: ''
105
122
  };
106
123
  _this.saveTimer = null;
107
124
  return _this;
@@ -119,6 +136,7 @@ var TipMessage = /*#__PURE__*/function (_React$Component) {
119
136
 
120
137
  // op execute error
121
138
  this.unsubscribeOpExecError = eventBus.subscribe('operation_exec_error', this.onOperationExecuteError);
139
+ this.unsubscribePendingOpExceedLimit = eventBus.subscribe('pending_operations_exceed_limit', this.onPendingOpExceedLimit);
122
140
  this.unsubscribeDocumentLoadError = eventBus.subscribe('document_content_load_failed', this.onDocumentLoadError);
123
141
  }
124
142
  }, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.1.110",
3
+ "version": "0.1.111",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",
@@ -340,5 +340,7 @@
340
340
  "Font": "Font",
341
341
  "All_fonts": "All fonts",
342
342
  "Default_font": "Default font",
343
- "Document_content_load_failed": "Document content failed to load, please refresh the page to try again"
343
+ "Document_content_load_failed": "Document content failed to load, please refresh the page to try again",
344
+ "Pending_operations_exceed_limit": "There are multiple operations not synced to the server. Please check your network.",
345
+ "Recently_saved": "Recently saved"
344
346
  }
@@ -342,5 +342,7 @@
342
342
  "Font": "字体",
343
343
  "All_fonts": "所有字体",
344
344
  "Default_font": "默认字体",
345
- "Document_content_load_failed": "文档内容加载失败, 请刷新页面重新访问"
345
+ "Document_content_load_failed": "文档内容加载失败, 请刷新页面重新访问",
346
+ "Pending_operations_exceed_limit": "有多个操作未同步到服务器。请检查你的网络。",
347
+ "Recently_saved": "最近保存"
346
348
  }