@seafile/sdoc-editor 0.1.159-beta11 → 0.1.159-beta13
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/api/seafile-api.js +6 -2
- package/dist/basic-sdk/editor/index.js +3 -7
- package/dist/basic-sdk/socket/socket-client.js +0 -15
- package/dist/basic-sdk/socket/socket-manager.js +2 -8
- package/dist/basic-sdk/socket/with-socket-io.js +2 -7
- package/dist/context.js +3 -2
- package/dist/pages/simple-editor.js +14 -4
- package/package.json +1 -1
package/dist/api/seafile-api.js
CHANGED
|
@@ -88,9 +88,13 @@ var SeafileAPI = /*#__PURE__*/function () {
|
|
|
88
88
|
}
|
|
89
89
|
}, {
|
|
90
90
|
key: "updateSdocRevision",
|
|
91
|
-
value: function updateSdocRevision(docUuid) {
|
|
91
|
+
value: function updateSdocRevision(docUuid, docName) {
|
|
92
|
+
var docContent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
92
93
|
var url = 'api/v2.1/seadoc/revision/' + docUuid + '/';
|
|
93
|
-
|
|
94
|
+
var formData = new FormData();
|
|
95
|
+
var newFile = new File([JSON.stringify(docContent)], docName);
|
|
96
|
+
formData.append('file', newFile);
|
|
97
|
+
return this.req.put(url, formData);
|
|
94
98
|
}
|
|
95
99
|
}, {
|
|
96
100
|
key: "getRevisionBasicVersionContent",
|
|
@@ -87,18 +87,14 @@ var Editor = forwardRef(function (_ref, ref) {
|
|
|
87
87
|
setSlateValue: function setSlateValue(document) {
|
|
88
88
|
_setSlateValue(document.children);
|
|
89
89
|
},
|
|
90
|
+
updateDocumentVersion: function updateDocumentVersion(document) {
|
|
91
|
+
editor.updateDocumentVersion(document);
|
|
92
|
+
},
|
|
90
93
|
// get value
|
|
91
94
|
getSlateValue: function getSlateValue() {
|
|
92
95
|
return deepCopy(_objectSpread(_objectSpread({}, document), {}, {
|
|
93
96
|
children: slateValue
|
|
94
97
|
}));
|
|
95
|
-
},
|
|
96
|
-
// send message
|
|
97
|
-
publishDocument: function publishDocument(originDocUuid, originDocName, callback) {
|
|
98
|
-
editor.publishDocument(originDocUuid, originDocName, callback);
|
|
99
|
-
},
|
|
100
|
-
replaceDocument: function replaceDocument(value, originFileVersion) {
|
|
101
|
-
editor.replaceDocument(value, originFileVersion);
|
|
102
98
|
}
|
|
103
99
|
|
|
104
100
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -119,14 +119,6 @@ var SocketClient = /*#__PURE__*/_createClass(function SocketClient(config) {
|
|
|
119
119
|
this.disconnectWithServer = function () {
|
|
120
120
|
_this.socket.disconnect();
|
|
121
121
|
};
|
|
122
|
-
this.sendPublishDocument = function (originDocUuid, originDocName, callback) {
|
|
123
|
-
_this.socket.emit('publish-document', _this.getParams({
|
|
124
|
-
origin_doc_uuid: originDocUuid,
|
|
125
|
-
origin_doc_name: originDocName
|
|
126
|
-
}), function (success) {
|
|
127
|
-
callback && callback(success);
|
|
128
|
-
});
|
|
129
|
-
};
|
|
130
122
|
this.receivePublishDocument = function () {
|
|
131
123
|
var socketManager = SocketManager.getInstance();
|
|
132
124
|
socketManager.receivePublishDocument();
|
|
@@ -135,13 +127,6 @@ var SocketClient = /*#__PURE__*/_createClass(function SocketClient(config) {
|
|
|
135
127
|
var socketManager = SocketManager.getInstance();
|
|
136
128
|
socketManager.receivePublishDocumentError();
|
|
137
129
|
};
|
|
138
|
-
this.sendReplaceDocument = function (document, callback) {
|
|
139
|
-
_this.socket.emit('replace-document', _this.getParams({
|
|
140
|
-
document: document
|
|
141
|
-
}), function (result) {
|
|
142
|
-
callback && callback(result);
|
|
143
|
-
});
|
|
144
|
-
};
|
|
145
130
|
this.receiveDocumentReplaced = function () {
|
|
146
131
|
var socketManager = SocketManager.getInstance();
|
|
147
132
|
socketManager.receiveDocumentReplaced();
|
|
@@ -27,8 +27,8 @@ var SocketManager = /*#__PURE__*/_createClass(function SocketManager(editor, _do
|
|
|
27
27
|
var version = _this.document.version;
|
|
28
28
|
return version;
|
|
29
29
|
};
|
|
30
|
-
this.
|
|
31
|
-
_this.
|
|
30
|
+
this.updateDocumentVersion = function (document) {
|
|
31
|
+
_this.document['version'] = document.version;
|
|
32
32
|
};
|
|
33
33
|
this.receivePublishDocument = function () {
|
|
34
34
|
_this.eventBus.dispatch(EXTERNAL_EVENT.PUBLISH_DOCUMENT);
|
|
@@ -42,12 +42,6 @@ var SocketManager = /*#__PURE__*/_createClass(function SocketManager(editor, _do
|
|
|
42
42
|
this.receiveRemoveDocumentError = function () {
|
|
43
43
|
_this.eventBus.dispatch(EXTERNAL_EVENT.REMOVE_DOCUMENT_ERROR);
|
|
44
44
|
};
|
|
45
|
-
this.sendReplaceDocument = function (document) {
|
|
46
|
-
_this.socketClient.sendReplaceDocument(document, function (result) {
|
|
47
|
-
var serverVersion = result.version;
|
|
48
|
-
_this.document['version'] = serverVersion;
|
|
49
|
-
});
|
|
50
|
-
};
|
|
51
45
|
this.receiveDocumentReplaced = function () {
|
|
52
46
|
_this.eventBus.dispatch(EXTERNAL_EVENT.DOCUMENT_REPLACED);
|
|
53
47
|
};
|
|
@@ -54,15 +54,10 @@ var withSocketIO = function withSocketIO(editor, options) {
|
|
|
54
54
|
var socketManager = SocketManager.getInstance(newEditor, document, config);
|
|
55
55
|
socketManager.sendRebaseContent(document, originFileVersion);
|
|
56
56
|
};
|
|
57
|
-
newEditor.
|
|
57
|
+
newEditor.updateDocumentVersion = function (document) {
|
|
58
58
|
var config = options.config;
|
|
59
59
|
var socketManager = SocketManager.getInstance(newEditor, document, config);
|
|
60
|
-
socketManager.
|
|
61
|
-
};
|
|
62
|
-
newEditor.replaceDocument = function (document) {
|
|
63
|
-
var config = options.config;
|
|
64
|
-
var socketManager = SocketManager.getInstance(newEditor, document, config);
|
|
65
|
-
socketManager.sendReplaceDocument(document);
|
|
60
|
+
socketManager.updateDocumentVersion(document);
|
|
66
61
|
};
|
|
67
62
|
return newEditor;
|
|
68
63
|
};
|
package/dist/context.js
CHANGED
|
@@ -193,9 +193,10 @@ var Context = /*#__PURE__*/function () {
|
|
|
193
193
|
}
|
|
194
194
|
}, {
|
|
195
195
|
key: "updateSdocRevision",
|
|
196
|
-
value: function updateSdocRevision() {
|
|
196
|
+
value: function updateSdocRevision(sdocContent) {
|
|
197
197
|
var docUuid = this.getSetting('docUuid');
|
|
198
|
-
|
|
198
|
+
var docName = this.getSetting('docName');
|
|
199
|
+
return this.api.updateSdocRevision(docUuid, docName, sdocContent);
|
|
199
200
|
}
|
|
200
201
|
}, {
|
|
201
202
|
key: "deleteSdocRevision",
|
|
@@ -84,11 +84,12 @@ var SimpleEditor = function SimpleEditor(_ref) {
|
|
|
84
84
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
85
85
|
}, []);
|
|
86
86
|
var onDocumentReplaced = useCallback(function () {
|
|
87
|
+
if (showTip) return;
|
|
87
88
|
setTipType(TIP_TYPE.HAS_BEEN_REPLACED);
|
|
88
89
|
setShowTip(true);
|
|
89
90
|
|
|
90
91
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
91
|
-
}, [editorRef]);
|
|
92
|
+
}, [editorRef, showTip]);
|
|
92
93
|
var hasPublishRevision = useCallback(function () {
|
|
93
94
|
if (showTip) return;
|
|
94
95
|
setTipType(TIP_TYPE.HAS_BEEN_PUBLISHED);
|
|
@@ -270,14 +271,23 @@ var SimpleEditor = function SimpleEditor(_ref) {
|
|
|
270
271
|
return;
|
|
271
272
|
}
|
|
272
273
|
if (tipType === TIP_TYPE.MERGE) {
|
|
273
|
-
context.
|
|
274
|
+
var _context$getUserInfo = context.getUserInfo(),
|
|
275
|
+
username = _context$getUserInfo.username;
|
|
276
|
+
var doc = {
|
|
277
|
+
children: mergeValue.children,
|
|
278
|
+
version: mergeValue.version,
|
|
279
|
+
format_version: document.format_version,
|
|
280
|
+
docName: document.docName,
|
|
281
|
+
last_modify_user: username
|
|
282
|
+
};
|
|
283
|
+
context.updateSdocRevision(doc).then(function (res) {
|
|
274
284
|
var origin_file_version = res.data.origin_file_version;
|
|
275
285
|
context.updateSettings({
|
|
276
286
|
'originFileVersion': origin_file_version
|
|
277
287
|
});
|
|
278
|
-
editorRef.current.replaceDocument(mergeValue);
|
|
279
288
|
editorRef.current.setLoading(true);
|
|
280
289
|
editorRef.current.setSlateValue(mergeValue);
|
|
290
|
+
editorRef.current.updateDocumentVersion(mergeValue);
|
|
281
291
|
setMode(MODE.EDITOR);
|
|
282
292
|
editorRef.current.setEditorMode(MODE.EDITOR);
|
|
283
293
|
editorRef.current.setLoading(false);
|
|
@@ -290,7 +300,7 @@ var SimpleEditor = function SimpleEditor(_ref) {
|
|
|
290
300
|
setShowTip(false);
|
|
291
301
|
|
|
292
302
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
293
|
-
}, [tipType, mergeValue, editorRef.current]);
|
|
303
|
+
}, [tipType, mergeValue, editorRef.current, document]);
|
|
294
304
|
if (isLoadingSdoc) {
|
|
295
305
|
return /*#__PURE__*/React.createElement(Loading, null);
|
|
296
306
|
}
|