@seafile/sdoc-editor 0.1.149-beta1 → 0.1.149-beta2

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.
@@ -11,12 +11,12 @@ export var MODIFY_TYPE = {
11
11
  ADD: 'add',
12
12
  DELETE: 'delete',
13
13
  MODIFY: 'modify',
14
- CHILDREN_MODIFY: 'children-modify'
14
+ CHILDREN_MODIFY: 'children_modify'
15
15
  };
16
16
  export var REBASE_TYPE = {
17
- MODIFY_MODIFY: 'modify-modify',
18
- DELETE_MODIFY: 'delete-modify',
19
- CHILDREN_MODIFY: 'children-modify'
17
+ MODIFY_MODIFY: 'modify_modify',
18
+ DELETE_MODIFY: 'delete_modify',
19
+ CHILDREN_MODIFY: 'children_modify'
20
20
  };
21
21
  export var REBASE_MARK_KEY = {
22
22
  ORIGIN: 'origin',
@@ -24,4 +24,4 @@ export var REBASE_MARK_KEY = {
24
24
  MODIFY_TYPE: 'modify_type',
25
25
  OLD_ELEMENT: 'old_element'
26
26
  };
27
- export var REBASE_MARKS = ['origin', 'rebase_type', 'old_element'];
27
+ export var REBASE_MARKS = [REBASE_MARK_KEY.ORIGIN, REBASE_MARK_KEY.REBASE_TYPE, REBASE_MARK_KEY.MODIFY_TYPE, REBASE_MARK_KEY.OLD_ELEMENT];
@@ -99,6 +99,9 @@ var Editor = forwardRef(function (_ref, ref) {
99
99
  },
100
100
  replaceDocument: function replaceDocument(value, originFileVersion) {
101
101
  editor.replaceDocument(value, originFileVersion);
102
+ },
103
+ saveDocument: function saveDocument(callback) {
104
+ editor.saveDocument(callback);
102
105
  }
103
106
 
104
107
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -46,7 +46,4 @@ export var SDOC_LINK = 'sdoc-link';
46
46
  // font
47
47
  export var FONT_SIZE = 'font-size';
48
48
  export var FONT_SIZE_INCREASE = 'font-size-increase';
49
- export var FONT_SIZE_REDUCE = 'font-size-reduce';
50
-
51
- // rebase
52
- export var REBASE_ELEMENT = 'rebase-element';
49
+ export var FONT_SIZE_REDUCE = 'font-size-reduce';
@@ -151,6 +151,13 @@ var SocketClient = /*#__PURE__*/_createClass(function SocketClient(config) {
151
151
  var socketManager = SocketManager.getInstance();
152
152
  socketManager.receiveDocumentReplacedError();
153
153
  };
154
+ this.sendSaveDocument = function (callback) {
155
+ _this.socket.emit('save-document', _this.getParams({
156
+ document: document
157
+ }), function (saveFlag) {
158
+ callback && callback(saveFlag);
159
+ });
160
+ };
154
161
  this.config = config;
155
162
  this.isReconnect = false;
156
163
  this.socket = io(config.sdocServer, {
@@ -48,6 +48,9 @@ var SocketManager = /*#__PURE__*/_createClass(function SocketManager(editor, _do
48
48
  this.receiveDocumentReplacedError = function () {
49
49
  _this.eventBus.dispatch(EXTERNAL_EVENT.DOCUMENT_REPLACED_ERROR);
50
50
  };
51
+ this.sendSaveDocument = function (callback) {
52
+ _this.socketClient.sendSaveDocument(callback);
53
+ };
51
54
  this.onReceiveLocalOperations = function (operations) {
52
55
  _this.pendingOperationList.push(operations);
53
56
  if (_this.pendingOperationList.length > 5) {
@@ -64,6 +64,11 @@ var withSocketIO = function withSocketIO(editor, options) {
64
64
  var socketManager = SocketManager.getInstance(newEditor, document, config);
65
65
  socketManager.sendReplaceDocument(document);
66
66
  };
67
+ newEditor.saveDocument = function (callback) {
68
+ var config = options.config;
69
+ var socketManager = SocketManager.getInstance(newEditor, document, config);
70
+ socketManager.sendSaveDocument(callback);
71
+ };
67
72
  return newEditor;
68
73
  };
69
74
  export default withSocketIO;
@@ -11,7 +11,7 @@ export var EXTERNAL_EVENT = {
11
11
  DOCUMENT_REPLACED_ERROR: 'document_replaced_error'
12
12
  };
13
13
  export var MODE = {
14
- DIFF_VIEWER: 'diff-viewer',
14
+ DIFF_VIEWER: 'diff_viewer',
15
15
  VIEWER: 'viewer',
16
16
  EDITOR: 'editor'
17
17
  };
@@ -227,12 +227,18 @@ var SimpleEditor = function SimpleEditor(_ref) {
227
227
  isNeedReplaceMaster = _getRebase.isNeedReplaceMaster,
228
228
  value = _getRebase.value;
229
229
  if (canMerge && isNeedReplaceMaster) {
230
- context.publishSdocRevision().then(function (res) {
231
- editorRef.current.publishDocument(originDocUuid, originDocName, true);
232
- setTipType(TIP_TYPE.HAS_BEEN_PUBLISHED);
233
- setShowTip(true);
234
- }).catch(function (error) {
235
- toaster.danger(t('Error'));
230
+ editorRef.current.saveDocument(function (saveFlag) {
231
+ if (saveFlag) {
232
+ context.publishSdocRevision().then(function (res) {
233
+ editorRef.current.publishDocument(originDocUuid, originDocName, true);
234
+ setTipType(TIP_TYPE.HAS_BEEN_PUBLISHED);
235
+ setShowTip(true);
236
+ }).catch(function (error) {
237
+ toaster.danger(t('Error'));
238
+ });
239
+ } else {
240
+ toaster.danger(t('Error'));
241
+ }
236
242
  });
237
243
  return;
238
244
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.1.149beta1",
3
+ "version": "0.1.149beta2",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",