@seafile/sdoc-editor 0.1.143-beta2 → 0.1.143-beta3

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.
@@ -39,9 +39,13 @@ var SDocRebaseEditor = function SDocRebaseEditor(_ref) {
39
39
  return item.rebaseType;
40
40
  }).length === 0) {
41
41
  context.rebaseSdocRevision().then(function (res) {
42
+ var origin_file_version = res.data.origin_file_version;
43
+ context.updateSettings({
44
+ 'originFileVersion': origin_file_version
45
+ });
42
46
  editor.rebaseContent({
43
47
  children: slateValue
44
- });
48
+ }, origin_file_version);
45
49
  }).then(function (res) {
46
50
  rebaseEnd();
47
51
  }).catch(function (error) {
@@ -182,14 +186,14 @@ var SDocRebaseEditor = function SDocRebaseEditor(_ref) {
182
186
  }, /*#__PURE__*/React.createElement("div", {
183
187
  className: "sdoc-rebase-btn",
184
188
  onClick: function onClick() {
185
- return deleteMark(element);
189
+ return deleteElement(element);
186
190
  }
187
191
  }, t('Keep_other_modification')), /*#__PURE__*/React.createElement("div", {
188
192
  className: "mr-2 ml-2"
189
193
  }, '|'), /*#__PURE__*/React.createElement("div", {
190
194
  className: "sdoc-rebase-btn",
191
195
  onClick: function onClick() {
192
- return deleteElement(element);
196
+ return deleteMark(element);
193
197
  }
194
198
  }, t('Keep_my_modification')), /*#__PURE__*/React.createElement("div", {
195
199
  className: "mr-2 ml-2"
@@ -219,14 +223,14 @@ var SDocRebaseEditor = function SDocRebaseEditor(_ref) {
219
223
  }, /*#__PURE__*/React.createElement("div", {
220
224
  className: "sdoc-rebase-btn",
221
225
  onClick: function onClick() {
222
- return useCurrentChanges(element);
226
+ return useMasterChanges(element);
223
227
  }
224
228
  }, t('Keep_other_modification')), /*#__PURE__*/React.createElement("div", {
225
229
  className: "mr-2 ml-2"
226
230
  }, '|'), /*#__PURE__*/React.createElement("div", {
227
231
  className: "sdoc-rebase-btn",
228
232
  onClick: function onClick() {
229
- return useMasterChanges(element);
233
+ return useCurrentChanges(element);
230
234
  }
231
235
  }, t('Keep_my_modification')), /*#__PURE__*/React.createElement("div", {
232
236
  className: "mr-2 ml-2"
@@ -4,6 +4,7 @@ import { Editor, Operation } from '@seafile/slate';
4
4
  import { getNode } from '../extension/core';
5
5
  import * as OPERATION from '../node-id/constants';
6
6
  import { setCursor } from '../cursor/helper';
7
+ import { MODE } from '../../constants';
7
8
  export var getNodePathById = function getNodePathById(rootNode, nodeId) {
8
9
  var path = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
9
10
  if (rootNode.id === nodeId) return path;
@@ -252,7 +253,7 @@ export var reExecRevertOperationList = function reExecRevertOperationList(editor
252
253
  }
253
254
  };
254
255
  export var syncRemoteOperations = function syncRemoteOperations(editor, remoteOperations) {
255
- if (editor.isReadonly) return;
256
+ if (editor.mode !== MODE.EDITOR) return;
256
257
  if (remoteOperations.length === 0) return;
257
258
  Editor.withoutNormalizing(editor, function () {
258
259
  for (var i = 0; i < remoteOperations.length; i++) {
@@ -123,16 +123,17 @@ var SocketClient = /*#__PURE__*/_createClass(function SocketClient(config) {
123
123
  this.disconnectWithServer = function () {
124
124
  _this.socket.disconnect();
125
125
  };
126
- this.receiveRebaseDocument = function (document) {
126
+ this.receiveRebaseDocument = function (document, originFileVersion) {
127
127
  var socketManager = SocketManager.getInstance();
128
- socketManager.receiveRebaseContent(document);
128
+ socketManager.receiveRebaseContent(document, originFileVersion);
129
129
  };
130
- this.sendRebaseDocument = function (document, callback) {
130
+ this.sendRebaseDocument = function (document, originFileVersion, callback) {
131
131
  debug('=========== send operations ==========');
132
132
  debug('%O', document);
133
133
  debug('======================================');
134
134
  _this.socket.emit('rebase-document', _this.getParams({
135
- document: document
135
+ document: document,
136
+ originFileVersion: originFileVersion
136
137
  }), function (result) {
137
138
  callback && callback(result);
138
139
  });
@@ -7,7 +7,7 @@ import { syncRemoteOperations, reExecRevertOperationList, revertOperationList, s
7
7
  import SocketClient from './socket-client';
8
8
  import debug from '../utils/debug';
9
9
  import { deleteCursor } from '../cursor/helper';
10
- import { EXTERNAL_EVENT } from '../../constants';
10
+ import { EXTERNAL_EVENT, MODE } from '../../constants';
11
11
 
12
12
  // idle --> sending --> conflict --> idle
13
13
  // --> conflict --> idle
@@ -27,12 +27,15 @@ var SocketManager = /*#__PURE__*/_createClass(function SocketManager(editor, _do
27
27
  var version = _this.document.version;
28
28
  return version;
29
29
  };
30
- this.sendRebaseContent = function (document) {
31
- _this.socketClient.sendRebaseDocument(document);
30
+ this.sendRebaseContent = function (document, originFileVersion) {
31
+ _this.socketClient.sendRebaseDocument(document, originFileVersion, function (result) {
32
+ var serverVersion = result.version;
33
+ _this.document['version'] = serverVersion;
34
+ });
32
35
  };
33
- this.receiveRebaseContent = function (document) {
36
+ this.receiveRebaseContent = function (document, originFileVersion) {
34
37
  _this.document = document;
35
- _this.eventBus.dispatch(EXTERNAL_EVENT.REBASE_DOCUMENT, document);
38
+ _this.eventBus.dispatch(EXTERNAL_EVENT.REBASE_DOCUMENT, document, originFileVersion);
36
39
  };
37
40
  this.onReceiveLocalOperations = function (operations) {
38
41
  _this.pendingOperationList.push(operations);
@@ -42,7 +45,7 @@ var SocketManager = /*#__PURE__*/_createClass(function SocketManager(editor, _do
42
45
  _this.sendOperations();
43
46
  };
44
47
  this.sendOperations = function () {
45
- if (_this.editor.isReadonly) return;
48
+ if (_this.editor.mode !== MODE.EDITOR) return;
46
49
  if (_this.state !== STATE.IDLE) return;
47
50
  _this.state = STATE.SENDING;
48
51
  _this.sendNextOperations();
@@ -49,10 +49,10 @@ var withSocketIO = function withSocketIO(editor, options) {
49
49
  }
50
50
  onChange();
51
51
  };
52
- newEditor.rebaseContent = function (document) {
52
+ newEditor.rebaseContent = function (document, originFileVersion) {
53
53
  var config = options.config;
54
54
  var socketManager = SocketManager.getInstance(newEditor, document, config);
55
- socketManager.sendRebaseContent(document);
55
+ socketManager.sendRebaseContent(document, originFileVersion);
56
56
  };
57
57
  return newEditor;
58
58
  };
package/dist/context.js CHANGED
@@ -48,6 +48,13 @@ var Context = /*#__PURE__*/function () {
48
48
  if (this.settings[key] === false) return this.settings[key];
49
49
  return this.settings[key] || '';
50
50
  }
51
+ }, {
52
+ key: "updateSettings",
53
+ value: function updateSettings(update) {
54
+ for (var key in update) {
55
+ this.settings[key] = update[key];
56
+ }
57
+ }
51
58
  }, {
52
59
  key: "getViewConfig",
53
60
  value: function getViewConfig() {
@@ -53,8 +53,11 @@ var SimpleEditor = function SimpleEditor(_ref) {
53
53
 
54
54
  // eslint-disable-next-line react-hooks/exhaustive-deps
55
55
  }, []);
56
- var rebaseDocument = useCallback(function (document) {
57
- toaster.warning(t('Document_has_rebased'));
56
+ var rebaseDocument = useCallback(function (document, originFileVersion) {
57
+ toaster.warning(t('Document_rebased_tip'));
58
+ context.updateSettings({
59
+ originFileVersion: originFileVersion
60
+ });
58
61
  editorRef.current.setLoading(true);
59
62
  setShowChanges(false);
60
63
  setMode(MODE.EDITOR);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.1.143beta2",
3
+ "version": "0.1.143beta3",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",
@@ -369,5 +369,6 @@
369
369
  "Need_rebase": "Need rebase",
370
370
  "Abort": "Abort",
371
371
  "Tip": "Tip",
372
- "Rebase_delete_no_change_revision_tip": "No changes have been made in the revision, should the revision be deleted directly ?"
372
+ "Rebase_delete_no_change_revision_tip": "No changes have been made in the revision, should the revision be deleted directly ?",
373
+ "Document_rebased_tip": "Document has been rebased"
373
374
  }
@@ -368,5 +368,6 @@
368
368
  "Keep_both_modification": "保留两个更改",
369
369
  "Need_rebase": "需要变基",
370
370
  "Abort": "中止",
371
- "Rebase_delete_no_change_revision_tip": "修订稿未做任何改动,是否直接删除修订稿?"
371
+ "Rebase_delete_no_change_revision_tip": "修订稿未做任何改动,是否直接删除修订稿?",
372
+ "Document_rebased_tip": "文档已经变基了"
372
373
  }