@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.
- package/dist/basic-sdk/constants/index.js +5 -5
- package/dist/basic-sdk/editor/index.js +3 -0
- package/dist/basic-sdk/extension/constants/element-type.js +1 -4
- package/dist/basic-sdk/socket/socket-client.js +7 -0
- package/dist/basic-sdk/socket/socket-manager.js +3 -0
- package/dist/basic-sdk/socket/with-socket-io.js +5 -0
- package/dist/constants/index.js +1 -1
- package/dist/pages/simple-editor.js +12 -6
- package/package.json +1 -1
|
@@ -11,12 +11,12 @@ export var MODIFY_TYPE = {
|
|
|
11
11
|
ADD: 'add',
|
|
12
12
|
DELETE: 'delete',
|
|
13
13
|
MODIFY: 'modify',
|
|
14
|
-
CHILDREN_MODIFY: '
|
|
14
|
+
CHILDREN_MODIFY: 'children_modify'
|
|
15
15
|
};
|
|
16
16
|
export var REBASE_TYPE = {
|
|
17
|
-
MODIFY_MODIFY: '
|
|
18
|
-
DELETE_MODIFY: '
|
|
19
|
-
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 = [
|
|
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;
|
package/dist/constants/index.js
CHANGED
|
@@ -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
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
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
|
}
|