@seafile/sdoc-editor 0.1.149-beta1 → 0.1.149-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.
- package/dist/api/seafile-api.js +0 -14
- package/dist/basic-sdk/constants/index.js +5 -5
- package/dist/basic-sdk/editor/index.js +2 -2
- package/dist/basic-sdk/extension/constants/element-type.js +1 -4
- package/dist/basic-sdk/socket/socket-client.js +9 -2
- package/dist/basic-sdk/socket/socket-manager.js +5 -2
- package/dist/basic-sdk/socket/with-socket-io.js +2 -2
- package/dist/constants/index.js +1 -1
- package/dist/context.js +0 -13
- package/dist/pages/simple-editor.js +11 -11
- package/package.json +1 -1
package/dist/api/seafile-api.js
CHANGED
|
@@ -46,14 +46,6 @@ var SeafileAPI = /*#__PURE__*/function () {
|
|
|
46
46
|
var url = '/api/v2.1/seadoc/download-image/' + docUuid + '/' + encodeURIComponent(imageName);
|
|
47
47
|
return this.req.get(url);
|
|
48
48
|
}
|
|
49
|
-
}, {
|
|
50
|
-
key: "sdocPublishRevision",
|
|
51
|
-
value: function sdocPublishRevision(docUuid, replace) {
|
|
52
|
-
var url = '/api/v2.1/seadoc/publish-revision/' + docUuid + '/';
|
|
53
|
-
var form = new FormData();
|
|
54
|
-
form.append('replace', replace);
|
|
55
|
-
return this._sendPostRequest(url, form);
|
|
56
|
-
}
|
|
57
49
|
}, {
|
|
58
50
|
key: "startRevise",
|
|
59
51
|
value: function startRevise(repoID, fileUuid, path) {
|
|
@@ -83,12 +75,6 @@ var SeafileAPI = /*#__PURE__*/function () {
|
|
|
83
75
|
var url = 'api/v2.1/seadoc/revisions/' + docUuid + '/?page=' + page + '&per_page=' + perPage;
|
|
84
76
|
return this.req.get(url);
|
|
85
77
|
}
|
|
86
|
-
}, {
|
|
87
|
-
key: "deleteSdocRevision",
|
|
88
|
-
value: function deleteSdocRevision(docUuid) {
|
|
89
|
-
var url = 'api/v2.1/seadoc/revision/' + docUuid + '/';
|
|
90
|
-
return this.req.delete(url);
|
|
91
|
-
}
|
|
92
78
|
}, {
|
|
93
79
|
key: "updateSdocRevision",
|
|
94
80
|
value: function updateSdocRevision(docUuid) {
|
|
@@ -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];
|
|
@@ -94,8 +94,8 @@ var Editor = forwardRef(function (_ref, ref) {
|
|
|
94
94
|
}));
|
|
95
95
|
},
|
|
96
96
|
// send message
|
|
97
|
-
publishDocument: function publishDocument(originDocUuid, originDocName, isNeedUpdateOriginDoc) {
|
|
98
|
-
editor.publishDocument(originDocUuid, originDocName, isNeedUpdateOriginDoc);
|
|
97
|
+
publishDocument: function publishDocument(originDocUuid, originDocName, isNeedUpdateOriginDoc, callback) {
|
|
98
|
+
editor.publishDocument(originDocUuid, originDocName, isNeedUpdateOriginDoc, callback);
|
|
99
99
|
},
|
|
100
100
|
replaceDocument: function replaceDocument(value, originFileVersion) {
|
|
101
101
|
editor.replaceDocument(value, originFileVersion);
|
|
@@ -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';
|
|
@@ -124,8 +124,8 @@ var SocketClient = /*#__PURE__*/_createClass(function SocketClient(config) {
|
|
|
124
124
|
origin_doc_uuid: originDocUuid,
|
|
125
125
|
origin_doc_name: originDocName,
|
|
126
126
|
update_origin_doc: isNeedUpdateOriginDoc
|
|
127
|
-
}), function (
|
|
128
|
-
callback && callback(
|
|
127
|
+
}), function (success) {
|
|
128
|
+
callback && callback(success);
|
|
129
129
|
});
|
|
130
130
|
};
|
|
131
131
|
this.receivePublishDocument = function () {
|
|
@@ -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, {
|
|
@@ -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.sendPublishDocument = function (originDocUuid, originDocName, isNeedUpdateOriginDoc) {
|
|
31
|
-
_this.socketClient.sendPublishDocument(originDocUuid, originDocName, isNeedUpdateOriginDoc);
|
|
30
|
+
this.sendPublishDocument = function (originDocUuid, originDocName, isNeedUpdateOriginDoc, callback) {
|
|
31
|
+
_this.socketClient.sendPublishDocument(originDocUuid, originDocName, isNeedUpdateOriginDoc, callback);
|
|
32
32
|
};
|
|
33
33
|
this.receivePublishDocument = function () {
|
|
34
34
|
_this.eventBus.dispatch(EXTERNAL_EVENT.PUBLISH_DOCUMENT);
|
|
@@ -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) {
|
|
@@ -54,10 +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.publishDocument = function (originDocUuid, originDocName, isNeedUpdateOriginDoc) {
|
|
57
|
+
newEditor.publishDocument = function (originDocUuid, originDocName, isNeedUpdateOriginDoc, callback) {
|
|
58
58
|
var config = options.config;
|
|
59
59
|
var socketManager = SocketManager.getInstance(newEditor, document, config);
|
|
60
|
-
socketManager.sendPublishDocument(originDocUuid, originDocName, isNeedUpdateOriginDoc);
|
|
60
|
+
socketManager.sendPublishDocument(originDocUuid, originDocName, isNeedUpdateOriginDoc, callback);
|
|
61
61
|
};
|
|
62
62
|
newEditor.replaceDocument = function (document) {
|
|
63
63
|
var config = options.config;
|
package/dist/constants/index.js
CHANGED
package/dist/context.js
CHANGED
|
@@ -163,13 +163,6 @@ var Context = /*#__PURE__*/function () {
|
|
|
163
163
|
var fileUuid = this.getSetting('docUuid');
|
|
164
164
|
return this.api.startRevise(repoID, fileUuid, filePath);
|
|
165
165
|
}
|
|
166
|
-
}, {
|
|
167
|
-
key: "publishSdocRevision",
|
|
168
|
-
value: function publishSdocRevision() {
|
|
169
|
-
var replace = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
170
|
-
var docUuid = this.getSetting('docUuid');
|
|
171
|
-
return this.api.sdocPublishRevision(docUuid, replace);
|
|
172
|
-
}
|
|
173
166
|
}, {
|
|
174
167
|
key: "getSeadocOriginFileDownloadLink",
|
|
175
168
|
value: function getSeadocOriginFileDownloadLink() {
|
|
@@ -188,12 +181,6 @@ var Context = /*#__PURE__*/function () {
|
|
|
188
181
|
var docUuid = this.getSetting('docUuid');
|
|
189
182
|
return this.api.getSdocRevisions(docUuid, page, perPage);
|
|
190
183
|
}
|
|
191
|
-
}, {
|
|
192
|
-
key: "deleteSdocRevision",
|
|
193
|
-
value: function deleteSdocRevision() {
|
|
194
|
-
var docUuid = this.getSetting('docUuid');
|
|
195
|
-
return this.api.deleteSdocRevision(docUuid);
|
|
196
|
-
}
|
|
197
184
|
}, {
|
|
198
185
|
key: "updateSdocRevision",
|
|
199
186
|
value: function updateSdocRevision() {
|
|
@@ -227,12 +227,13 @@ 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.publishDocument(originDocUuid, originDocName, true, function (success) {
|
|
231
|
+
if (success) {
|
|
232
|
+
setTipType(TIP_TYPE.HAS_BEEN_PUBLISHED);
|
|
233
|
+
setShowTip(true);
|
|
234
|
+
} else {
|
|
235
|
+
toaster.danger(t('Error'));
|
|
236
|
+
}
|
|
236
237
|
});
|
|
237
238
|
return;
|
|
238
239
|
}
|
|
@@ -273,14 +274,13 @@ var SimpleEditor = function SimpleEditor(_ref) {
|
|
|
273
274
|
}, [tipType]);
|
|
274
275
|
var tipSubmit = useCallback(function () {
|
|
275
276
|
if (tipType === TIP_TYPE.DELETE_NO_CHANGES_REVISION) {
|
|
276
|
-
|
|
277
|
-
if (
|
|
278
|
-
editorRef.current.publishDocument(originDocUuid, originDocName, false);
|
|
277
|
+
editorRef.current.publishDocument(originDocUuid, originDocName, false, function (success) {
|
|
278
|
+
if (success) {
|
|
279
279
|
setShowTip(false);
|
|
280
280
|
jumpToURL(originFileURL);
|
|
281
|
+
} else {
|
|
282
|
+
toaster.danger(t('Error'));
|
|
281
283
|
}
|
|
282
|
-
}).catch(function (error) {
|
|
283
|
-
toaster.danger(t('Error'));
|
|
284
284
|
});
|
|
285
285
|
return;
|
|
286
286
|
}
|