@seafile/sdoc-editor 0.1.141 → 0.1.142-beta
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/sdoc-server-api.js +15 -0
- package/dist/api/seafile-api.js +27 -5
- package/dist/basic-sdk/assets/css/dropdown-menu.css +5 -1
- package/dist/basic-sdk/constants/index.js +14 -1
- package/dist/basic-sdk/editor/common-editor.js +45 -0
- package/dist/basic-sdk/editor/index.js +135 -0
- package/dist/basic-sdk/editor/rebase-editor/index.css +29 -0
- package/dist/basic-sdk/editor/rebase-editor/index.js +276 -0
- package/dist/basic-sdk/{slate-editor.js → editor/slate-editor.js} +21 -16
- package/dist/basic-sdk/extension/core/transforms/replace-node-children.js +26 -0
- package/dist/basic-sdk/extension/toolbar/header-toolbar/index.js +5 -1
- package/dist/basic-sdk/extension/toolbar/header-toolbar/insert-toolbar/index.css +5 -0
- package/dist/basic-sdk/socket/helpers.js +1 -0
- package/dist/basic-sdk/socket/socket-client.js +5 -0
- package/dist/basic-sdk/socket/socket-manager.js +8 -2
- package/dist/basic-sdk/socket/with-socket-io.js +20 -12
- package/dist/basic-sdk/utils/diff.js +2 -2
- package/dist/basic-sdk/utils/rebase.js +193 -0
- package/dist/basic-sdk/views/diff-viewer.js +3 -1
- package/dist/basic-sdk/views/viewer.js +8 -11
- package/dist/components/doc-operations/index.js +8 -2
- package/dist/components/doc-operations/revision-operations/index.js +11 -3
- package/dist/components/doc-operations/revision-operations/publish-button.js +16 -13
- package/dist/components/tip-dialog/index.css +0 -0
- package/dist/components/tip-dialog/index.js +45 -0
- package/dist/constants/index.js +8 -1
- package/dist/context.js +30 -4
- package/dist/pages/simple-editor.js +221 -71
- package/package.json +1 -1
- package/public/locales/en/sdoc-editor.json +7 -1
- package/public/locales/zh_CN/sdoc-editor.json +7 -1
- package/dist/basic-sdk/editor.js +0 -105
package/dist/context.js
CHANGED
|
@@ -89,6 +89,11 @@ var Context = /*#__PURE__*/function () {
|
|
|
89
89
|
value: function saveContent(content) {
|
|
90
90
|
return this.sdocServerApi.saveDocContent(content);
|
|
91
91
|
}
|
|
92
|
+
}, {
|
|
93
|
+
key: "saveDocContentByRebase",
|
|
94
|
+
value: function saveDocContentByRebase(content) {
|
|
95
|
+
return this.sdocServerApi.saveDocContentByRebase(content);
|
|
96
|
+
}
|
|
92
97
|
}, {
|
|
93
98
|
key: "getCollaborators",
|
|
94
99
|
value: function getCollaborators() {
|
|
@@ -156,14 +161,15 @@ var Context = /*#__PURE__*/function () {
|
|
|
156
161
|
}, {
|
|
157
162
|
key: "publishSdocRevision",
|
|
158
163
|
value: function publishSdocRevision() {
|
|
164
|
+
var replace = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
159
165
|
var docUuid = this.getSetting('docUuid');
|
|
160
|
-
return this.api.sdocPublishRevision(docUuid);
|
|
166
|
+
return this.api.sdocPublishRevision(docUuid, replace);
|
|
161
167
|
}
|
|
162
168
|
}, {
|
|
163
|
-
key: "
|
|
164
|
-
value: function
|
|
169
|
+
key: "getSeadocOriginFileDownloadLink",
|
|
170
|
+
value: function getSeadocOriginFileDownloadLink() {
|
|
165
171
|
var docUuid = this.getSetting('docUuid');
|
|
166
|
-
return this.api.
|
|
172
|
+
return this.api.getSeadocOriginFileDownloadLink(docUuid);
|
|
167
173
|
}
|
|
168
174
|
}, {
|
|
169
175
|
key: "getSdocRevisionsCount",
|
|
@@ -177,6 +183,26 @@ var Context = /*#__PURE__*/function () {
|
|
|
177
183
|
var docUuid = this.getSetting('docUuid');
|
|
178
184
|
return this.api.getSdocRevisions(docUuid, page, perPage);
|
|
179
185
|
}
|
|
186
|
+
}, {
|
|
187
|
+
key: "deleteSdocRevision",
|
|
188
|
+
value: function deleteSdocRevision() {
|
|
189
|
+
var docUuid = this.getSetting('docUuid');
|
|
190
|
+
return this.api.deleteSdocRevision(docUuid);
|
|
191
|
+
}
|
|
192
|
+
}, {
|
|
193
|
+
key: "rebaseSdocRevision",
|
|
194
|
+
value: function rebaseSdocRevision() {
|
|
195
|
+
var docUuid = this.getSetting('docUuid');
|
|
196
|
+
return this.api.rebaseSdocRevision(docUuid);
|
|
197
|
+
}
|
|
198
|
+
}, {
|
|
199
|
+
key: "getFileHistoryVersion",
|
|
200
|
+
value: function getFileHistoryVersion(fileVersion, filePath) {
|
|
201
|
+
var docUuid = this.getSetting('docUuid');
|
|
202
|
+
return this.api.getFileHistoryVersion(docUuid, fileVersion, filePath);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// local files
|
|
180
206
|
}, {
|
|
181
207
|
key: "getSdocLocalFiles",
|
|
182
208
|
value: function getSdocLocalFiles(p) {
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
2
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
4
3
|
import { withTranslation } from 'react-i18next';
|
|
5
|
-
import deepCopy from 'deep-copy';
|
|
6
|
-
import { SDocEditor, DiffViewer } from '../basic-sdk';
|
|
7
4
|
import Loading from '../components/loading';
|
|
8
5
|
import DocInfo from '../components/doc-info';
|
|
9
6
|
import DocOperations from '../components/doc-operations';
|
|
@@ -11,6 +8,11 @@ import Layout, { Header, Content } from '../layout';
|
|
|
11
8
|
import { generateDefaultDocContent } from '../utils';
|
|
12
9
|
import context from '../context';
|
|
13
10
|
import ErrorBoundary from './error-boundary';
|
|
11
|
+
import TipDialog from '../components/tip-dialog';
|
|
12
|
+
import { EXTERNAL_EVENT, MODE } from '../constants';
|
|
13
|
+
import { getRebase } from '../basic-sdk/utils/rebase';
|
|
14
|
+
import toaster from '../components/toast';
|
|
15
|
+
import { EventBus, SDocEditor } from '../basic-sdk';
|
|
14
16
|
import '../assets/css/simple-editor.css';
|
|
15
17
|
var SimpleEditor = function SimpleEditor(_ref) {
|
|
16
18
|
var isStarred = _ref.isStarred,
|
|
@@ -19,39 +21,74 @@ var SimpleEditor = function SimpleEditor(_ref) {
|
|
|
19
21
|
var editorRef = useRef(null);
|
|
20
22
|
var _useState = useState(true),
|
|
21
23
|
_useState2 = _slicedToArray(_useState, 2),
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
var _useState3 = useState(
|
|
24
|
+
isLoadingSdoc = _useState2[0],
|
|
25
|
+
setLoadingSdoc = _useState2[1];
|
|
26
|
+
var _useState3 = useState(''),
|
|
25
27
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var _useState5 = useState(
|
|
28
|
+
errorMessage = _useState4[0],
|
|
29
|
+
setErrorMessage = _useState4[1];
|
|
30
|
+
var _useState5 = useState(false),
|
|
29
31
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
var _useState7 = useState(
|
|
32
|
+
isShowChanges = _useState6[0],
|
|
33
|
+
setShowChanges = _useState6[1];
|
|
34
|
+
var _useState7 = useState(null),
|
|
33
35
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
var _useState9 = useState(
|
|
36
|
+
document = _useState8[0],
|
|
37
|
+
setDocument = _useState8[1];
|
|
38
|
+
var _useState9 = useState(MODE.EDITOR),
|
|
37
39
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
var _useState11 = useState(
|
|
40
|
+
mode = _useState10[0],
|
|
41
|
+
setMode = _useState10[1];
|
|
42
|
+
var _useState11 = useState([]),
|
|
41
43
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
var _useState13 = useState(
|
|
44
|
+
changes = _useState12[0],
|
|
45
|
+
setChanges = _useState12[1];
|
|
46
|
+
var _useState13 = useState(false),
|
|
45
47
|
_useState14 = _slicedToArray(_useState13, 2),
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
showTip = _useState14[0],
|
|
49
|
+
setShowTip = _useState14[1];
|
|
48
50
|
useEffect(function () {
|
|
49
51
|
context.initApi();
|
|
50
|
-
initDocumentData(
|
|
52
|
+
initDocumentData();
|
|
51
53
|
|
|
52
54
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
53
55
|
}, []);
|
|
54
|
-
var
|
|
56
|
+
var rebaseDocument = useCallback(function (document) {
|
|
57
|
+
toaster.warning(t('Document_has_rebased'));
|
|
58
|
+
editorRef.current.setLoading(true);
|
|
59
|
+
setShowChanges(false);
|
|
60
|
+
setMode(MODE.EDITOR);
|
|
61
|
+
editorRef.current.setEditorMode(MODE.EDITOR);
|
|
62
|
+
|
|
63
|
+
//
|
|
64
|
+
console.log('document: ', document);
|
|
65
|
+
setDocument(document);
|
|
66
|
+
editorRef.current.setSlateValue(document);
|
|
67
|
+
editorRef.current.setLoading(false);
|
|
68
|
+
|
|
69
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
70
|
+
}, [editorRef]);
|
|
71
|
+
useEffect(function () {
|
|
72
|
+
var eventBus = EventBus.getInstance();
|
|
73
|
+
var rebaseDocumentSubscribe = eventBus.subscribe(EXTERNAL_EVENT.REBASE_DOCUMENT, rebaseDocument);
|
|
74
|
+
return function () {
|
|
75
|
+
rebaseDocumentSubscribe();
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
79
|
+
}, []);
|
|
80
|
+
|
|
81
|
+
// useMount: reset title
|
|
82
|
+
useEffect(function () {
|
|
83
|
+
var isSdocRevision = context.getSetting('isSdocRevision');
|
|
84
|
+
var originFilename = context.getSetting('originFilename');
|
|
85
|
+
if (isSdocRevision) {
|
|
86
|
+
window.document.getElementsByTagName('title')[0].innerText = "".concat(t('Revision'), " - ").concat(originFilename);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
90
|
+
}, []);
|
|
91
|
+
var initDocumentData = useCallback(function () {
|
|
55
92
|
setShowChanges(false);
|
|
56
93
|
setLoadingSdoc(true);
|
|
57
94
|
context.getFileContent().then(function (res) {
|
|
@@ -65,7 +102,6 @@ var SimpleEditor = function SimpleEditor(_ref) {
|
|
|
65
102
|
}
|
|
66
103
|
setDocument(result);
|
|
67
104
|
setLoadingSdoc(false);
|
|
68
|
-
isFirstLoad && setFirstLoad(false);
|
|
69
105
|
}).catch(function (error) {
|
|
70
106
|
// eslint-disable-next-line
|
|
71
107
|
console.log(error);
|
|
@@ -83,54 +119,172 @@ var SimpleEditor = function SimpleEditor(_ref) {
|
|
|
83
119
|
|
|
84
120
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
85
121
|
}, []);
|
|
86
|
-
var
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
122
|
+
var setFileContent = useCallback(function () {
|
|
123
|
+
context.getFileContent().then(function (res) {
|
|
124
|
+
var result = res.data || generateDefaultDocContent();
|
|
125
|
+
if (result && !result.children) {
|
|
126
|
+
result = {
|
|
127
|
+
version: 0,
|
|
128
|
+
children: result.content,
|
|
129
|
+
cursors: result.cursors || {}
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
setDocument(result);
|
|
133
|
+
editorRef.current.setSlateValue(result);
|
|
134
|
+
editorRef.current.setLoading(false);
|
|
135
|
+
}).catch(function (error) {
|
|
136
|
+
// eslint-disable-next-line
|
|
137
|
+
console.log(error);
|
|
138
|
+
setErrorMessage('Load_doc_content_error');
|
|
139
|
+
editorRef.current.setLoading(false);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
// eslint-disable-next-line no-trailing-spaces
|
|
143
|
+
}, []);
|
|
144
|
+
var setDiffContent = useCallback(function () {
|
|
145
|
+
context.getSeadocOriginFileDownloadLink().then(function (res) {
|
|
90
146
|
var originFileDownloadLink = res.data.origin_file_download_link;
|
|
91
147
|
return fetch(originFileDownloadLink);
|
|
92
148
|
}).then(function (res) {
|
|
93
149
|
return res.json();
|
|
94
150
|
}).then(function (originContent) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
setLoadingSdoc(false);
|
|
151
|
+
editorRef.current.setDiffContent(originContent);
|
|
152
|
+
editorRef.current.setLoading(false);
|
|
98
153
|
}).catch(function (error) {
|
|
99
|
-
|
|
100
|
-
setLoadingSdoc(false);
|
|
154
|
+
console.log('error');
|
|
101
155
|
});
|
|
102
|
-
|
|
103
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
104
|
-
}, [document]);
|
|
156
|
+
}, []);
|
|
105
157
|
var toggleViewChanges = useCallback(function (isShowChanges) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
158
|
+
var needFetchNewContent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
159
|
+
editorRef.current.setLoading(true);
|
|
160
|
+
setShowChanges(isShowChanges);
|
|
161
|
+
var mode = isShowChanges ? MODE.DIFF_VIEWER : MODE.EDITOR;
|
|
162
|
+
setMode(mode);
|
|
163
|
+
editorRef.current.setEditorMode(mode);
|
|
164
|
+
if (!isShowChanges) {
|
|
165
|
+
setFileContent();
|
|
166
|
+
return;
|
|
111
167
|
}
|
|
112
|
-
if (
|
|
113
|
-
|
|
168
|
+
if (!needFetchNewContent) {
|
|
169
|
+
setDiffContent();
|
|
114
170
|
return;
|
|
115
171
|
}
|
|
116
|
-
|
|
117
|
-
|
|
172
|
+
context.getFileContent().then(function (res) {
|
|
173
|
+
var result = res.data || generateDefaultDocContent();
|
|
174
|
+
if (result && !result.children) {
|
|
175
|
+
result = {
|
|
176
|
+
version: 0,
|
|
177
|
+
children: result.content,
|
|
178
|
+
cursors: result.cursors || {}
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
setDocument(result);
|
|
182
|
+
editorRef.current.setSlateValue(result);
|
|
183
|
+
}).then(function () {
|
|
184
|
+
setDiffContent();
|
|
185
|
+
}).catch(function (error) {
|
|
186
|
+
// eslint-disable-next-line
|
|
187
|
+
console.log(error);
|
|
188
|
+
setErrorMessage('Load_doc_content_error');
|
|
189
|
+
editorRef.current.setLoading(false);
|
|
190
|
+
});
|
|
118
191
|
|
|
119
192
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
120
193
|
}, [document]);
|
|
121
|
-
var
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
194
|
+
var publishRevision = useCallback(function () {
|
|
195
|
+
var repoID = context.getSetting('repoID');
|
|
196
|
+
var siteRoot = context.getSetting('siteRoot');
|
|
197
|
+
var originFileVersion = context.getSetting('originFileVersion');
|
|
198
|
+
var originFilePath = context.getSetting('originFilePath');
|
|
199
|
+
var revisionCurrentContent;
|
|
200
|
+
var revisionMasterContent;
|
|
201
|
+
var masterContent;
|
|
202
|
+
context.getFileHistoryVersion(originFileVersion, originFilePath).then(function (res) {
|
|
203
|
+
var fileHistoryRevisionContent = res.data.content; // commit content
|
|
204
|
+
revisionMasterContent = JSON.parse(fileHistoryRevisionContent);
|
|
205
|
+
return context.getSeadocOriginFileDownloadLink();
|
|
206
|
+
}).then(function (res) {
|
|
207
|
+
var originFileDownloadLink = res.data.origin_file_download_link;
|
|
208
|
+
return fetch(originFileDownloadLink);
|
|
209
|
+
}).then(function (res) {
|
|
210
|
+
return res.json();
|
|
211
|
+
}).then(function (content) {
|
|
212
|
+
masterContent = content;
|
|
213
|
+
return context.getFileContent();
|
|
214
|
+
}).then(function (res) {
|
|
215
|
+
var result = res.data || generateDefaultDocContent();
|
|
216
|
+
if (result && !result.children) {
|
|
217
|
+
result = {
|
|
218
|
+
version: 0,
|
|
219
|
+
children: result.content,
|
|
220
|
+
cursors: result.cursors || {}
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
revisionCurrentContent = result;
|
|
224
|
+
var _getRebase = getRebase(masterContent, revisionMasterContent, revisionCurrentContent),
|
|
225
|
+
canMerge = _getRebase.canMerge,
|
|
226
|
+
isNeedReplaceMaster = _getRebase.isNeedReplaceMaster,
|
|
227
|
+
value = _getRebase.value;
|
|
228
|
+
if (canMerge && isNeedReplaceMaster) {
|
|
229
|
+
context.publishSdocRevision().then(function (res) {
|
|
230
|
+
var origin_file_path = res.data.origin_file_path;
|
|
231
|
+
window.location.href = "".concat(siteRoot, "lib/").concat(repoID, "/file/").concat(origin_file_path);
|
|
232
|
+
}).catch(function (error) {
|
|
233
|
+
toaster.danger(t('Error'));
|
|
234
|
+
});
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
if (canMerge && !isNeedReplaceMaster) {
|
|
238
|
+
setShowTip(true);
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
toaster.warning(t('Need_rebase'));
|
|
242
|
+
editorRef.current.setLoading(true);
|
|
243
|
+
editorRef.current.setSlateValue(value);
|
|
244
|
+
setMode(MODE.REBASE);
|
|
245
|
+
editorRef.current.setEditorMode(MODE.REBASE);
|
|
246
|
+
editorRef.current.setLoading(false);
|
|
247
|
+
}).catch(function (error) {
|
|
248
|
+
toaster.danger(t('Error'));
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
252
|
+
}, [document, isShowChanges, mode]);
|
|
253
|
+
var abortRebase = useCallback(function () {
|
|
254
|
+
toggleViewChanges(isShowChanges, true);
|
|
255
|
+
|
|
256
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
257
|
+
}, [isShowChanges, document]);
|
|
125
258
|
var setDiffChanges = useCallback(function (diff) {
|
|
126
259
|
setChanges(diff.changes);
|
|
127
260
|
|
|
128
261
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
129
262
|
}, [isShowChanges]);
|
|
130
|
-
|
|
263
|
+
var closeTipDialog = useCallback(function () {
|
|
264
|
+
setShowTip(false);
|
|
265
|
+
|
|
266
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
267
|
+
}, []);
|
|
268
|
+
var deleteRevision = useCallback(function () {
|
|
269
|
+
context.deleteRevision().then(function (res) {
|
|
270
|
+
if (res.data.success) {
|
|
271
|
+
var repoID = context.getSetting('repoID');
|
|
272
|
+
var siteRoot = context.getSetting('siteRoot');
|
|
273
|
+
var originFilePath = context.getSetting('originFilePath');
|
|
274
|
+
window.location.href = "".concat(siteRoot, "lib/").concat(repoID, "/file/").concat(originFilePath);
|
|
275
|
+
setShowTip(false);
|
|
276
|
+
}
|
|
277
|
+
}).catch(function (error) {
|
|
278
|
+
toaster.danger(t('Error'));
|
|
279
|
+
setShowTip(false);
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
283
|
+
}, []);
|
|
284
|
+
if (isLoadingSdoc) {
|
|
131
285
|
return /*#__PURE__*/React.createElement(Loading, null);
|
|
132
286
|
}
|
|
133
|
-
if (
|
|
287
|
+
if (errorMessage) {
|
|
134
288
|
return /*#__PURE__*/React.createElement("div", {
|
|
135
289
|
className: "error-page"
|
|
136
290
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -143,25 +297,21 @@ var SimpleEditor = function SimpleEditor(_ref) {
|
|
|
143
297
|
isEditMode: !isShowChanges
|
|
144
298
|
}), /*#__PURE__*/React.createElement(DocOperations, {
|
|
145
299
|
isShowChanges: isShowChanges,
|
|
300
|
+
mode: mode,
|
|
146
301
|
changes: changes,
|
|
147
|
-
toggleViewChanges: toggleViewChanges
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}, /*#__PURE__*/React.createElement(
|
|
151
|
-
className: "error-page"
|
|
152
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
153
|
-
className: "error-tip"
|
|
154
|
-
}, t(errorMessage))), !isLoadingSdoc && !errorMessage && /*#__PURE__*/React.createElement(React.Fragment, null, isShowChanges ? /*#__PURE__*/React.createElement(DiffViewer, {
|
|
155
|
-
showToolbar: true,
|
|
156
|
-
showOutline: true,
|
|
157
|
-
currentContent: currentContent,
|
|
158
|
-
lastContent: lastContent,
|
|
159
|
-
didMountCallback: setDiffChanges
|
|
160
|
-
}) : /*#__PURE__*/React.createElement(SDocEditor, {
|
|
161
|
-
config: context.getEditorConfig(),
|
|
162
|
-
document: document,
|
|
302
|
+
toggleViewChanges: toggleViewChanges,
|
|
303
|
+
publishRevision: publishRevision,
|
|
304
|
+
abortRebase: abortRebase
|
|
305
|
+
})), /*#__PURE__*/React.createElement(Content, null, /*#__PURE__*/React.createElement(SDocEditor, {
|
|
163
306
|
ref: editorRef,
|
|
164
|
-
|
|
165
|
-
|
|
307
|
+
document: document,
|
|
308
|
+
mode: mode,
|
|
309
|
+
setDiffChanges: setDiffChanges,
|
|
310
|
+
toggleViewChanges: toggleViewChanges
|
|
311
|
+
}))), showTip && /*#__PURE__*/React.createElement(TipDialog, {
|
|
312
|
+
toggle: closeTipDialog,
|
|
313
|
+
submit: deleteRevision,
|
|
314
|
+
title: t('Rebase_tip')
|
|
315
|
+
}, t('Rebase_delete_no_change_revision_tip')));
|
|
166
316
|
};
|
|
167
317
|
export default withTranslation('sdoc-editor')(SimpleEditor);
|
package/package.json
CHANGED
|
@@ -362,5 +362,11 @@
|
|
|
362
362
|
"No_changes": "No changes",
|
|
363
363
|
"Title": "Title",
|
|
364
364
|
"Subtitle": "Subtitle",
|
|
365
|
-
"Link_sdoc": "Link sdoc"
|
|
365
|
+
"Link_sdoc": "Link sdoc",
|
|
366
|
+
"Keep_my_modification": "Keep my modification",
|
|
367
|
+
"Keep_other_modification": "Keep other's modification",
|
|
368
|
+
"Keep_both_modification": "Keep my modification",
|
|
369
|
+
"Need_rebase": "Need rebase",
|
|
370
|
+
"Abort": "Abort",
|
|
371
|
+
"Rebase_delete_no_change_revision_tip": "No changes have been made in the revision, should the revision be deleted directly ?"
|
|
366
372
|
}
|
|
@@ -362,5 +362,11 @@
|
|
|
362
362
|
"No_changes": "没有变化",
|
|
363
363
|
"Title": "标题",
|
|
364
364
|
"Subtitle": "副标题",
|
|
365
|
-
"Link_sdoc": "链接 sdoc"
|
|
365
|
+
"Link_sdoc": "链接 sdoc",
|
|
366
|
+
"Keep_my_modification": "保留我的更改",
|
|
367
|
+
"Keep_other_modification": "保留其他的更改",
|
|
368
|
+
"Keep_both_modification": "保留两个更改",
|
|
369
|
+
"Need_rebase": "需要变基",
|
|
370
|
+
"Abort": "中止",
|
|
371
|
+
"Rebase_delete_no_change_revision_tip": "No changes have been made in the revision, should the revision be deleted directly ?"
|
|
366
372
|
}
|
package/dist/basic-sdk/editor.js
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
-
import React, { useEffect, useMemo, useState, forwardRef, useImperativeHandle } from 'react';
|
|
3
|
-
import { Editor } from '@seafile/slate';
|
|
4
|
-
import { useTranslation } from 'react-i18next';
|
|
5
|
-
import { createDefaultEditor } from './extension';
|
|
6
|
-
import { focusEditor } from './extension/core';
|
|
7
|
-
import { withSocketIO } from './socket';
|
|
8
|
-
import withNodeId from './node-id';
|
|
9
|
-
import { PAGE_EDIT_AREA_WIDTH } from './constants';
|
|
10
|
-
import context from '../context';
|
|
11
|
-
import { EditorContainer, EditorContent } from './layout';
|
|
12
|
-
import SlateEditor from './slate-editor';
|
|
13
|
-
import InsertElementDialog from './extension/commons/insert-element-dialog';
|
|
14
|
-
var SDocEditor = forwardRef(function (_ref, ref) {
|
|
15
|
-
var document = _ref.document,
|
|
16
|
-
config = _ref.config;
|
|
17
|
-
var _useTranslation = useTranslation(),
|
|
18
|
-
t = _useTranslation.t;
|
|
19
|
-
|
|
20
|
-
// init editor
|
|
21
|
-
var editor = useMemo(function () {
|
|
22
|
-
var defaultEditor = createDefaultEditor();
|
|
23
|
-
var newEditor = withNodeId(withSocketIO(defaultEditor, {
|
|
24
|
-
document: document,
|
|
25
|
-
config: config
|
|
26
|
-
}));
|
|
27
|
-
var cursors = document.cursors;
|
|
28
|
-
newEditor.cursors = cursors || {};
|
|
29
|
-
newEditor.width = PAGE_EDIT_AREA_WIDTH; // default width
|
|
30
|
-
newEditor.readonly = false;
|
|
31
|
-
return newEditor;
|
|
32
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
33
|
-
}, []);
|
|
34
|
-
var _useState = useState(document.children),
|
|
35
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
36
|
-
slateValue = _useState2[0],
|
|
37
|
-
setSlateValue = _useState2[1];
|
|
38
|
-
|
|
39
|
-
// The parent component can call the method of this component through ref
|
|
40
|
-
useImperativeHandle(ref, function () {
|
|
41
|
-
return {
|
|
42
|
-
// get latest value
|
|
43
|
-
getValue: function getValue() {
|
|
44
|
-
return slateValue;
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
}, [slateValue]);
|
|
48
|
-
|
|
49
|
-
// useMount: init socket connection
|
|
50
|
-
useEffect(function () {
|
|
51
|
-
editor.openConnection();
|
|
52
|
-
return function () {
|
|
53
|
-
editor.closeConnection();
|
|
54
|
-
};
|
|
55
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
56
|
-
}, []);
|
|
57
|
-
|
|
58
|
-
// useMount: focus editor
|
|
59
|
-
useEffect(function () {
|
|
60
|
-
var timer = setTimeout(function () {
|
|
61
|
-
var _editor$children = _slicedToArray(editor.children, 1),
|
|
62
|
-
firstNode = _editor$children[0];
|
|
63
|
-
if (firstNode) {
|
|
64
|
-
var _firstNode$children = _slicedToArray(firstNode.children, 1),
|
|
65
|
-
firstNodeFirstChild = _firstNode$children[0];
|
|
66
|
-
if (firstNodeFirstChild) {
|
|
67
|
-
var endOfFirstNode = Editor.end(editor, [0, 0]);
|
|
68
|
-
var range = {
|
|
69
|
-
anchor: endOfFirstNode,
|
|
70
|
-
focus: endOfFirstNode
|
|
71
|
-
};
|
|
72
|
-
focusEditor(editor, range);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}, 300);
|
|
76
|
-
return function () {
|
|
77
|
-
clearTimeout(timer);
|
|
78
|
-
};
|
|
79
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
80
|
-
}, []);
|
|
81
|
-
|
|
82
|
-
// useMount: reset title
|
|
83
|
-
useEffect(function () {
|
|
84
|
-
var isSdocRevision = context.getSetting('isSdocRevision');
|
|
85
|
-
var originFilename = context.getSetting('originFilename');
|
|
86
|
-
if (isSdocRevision) {
|
|
87
|
-
window.document.getElementsByTagName('title')[0].innerText = "".concat(t('Revision'), " - ").concat(originFilename);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
91
|
-
}, []);
|
|
92
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(EditorContainer, {
|
|
93
|
-
editor: editor
|
|
94
|
-
}, /*#__PURE__*/React.createElement(EditorContent, {
|
|
95
|
-
docValue: slateValue,
|
|
96
|
-
showOutline: true
|
|
97
|
-
}, /*#__PURE__*/React.createElement(SlateEditor, {
|
|
98
|
-
editor: editor,
|
|
99
|
-
slateValue: slateValue,
|
|
100
|
-
setSlateValue: setSlateValue
|
|
101
|
-
}))), /*#__PURE__*/React.createElement(InsertElementDialog, {
|
|
102
|
-
editor: editor
|
|
103
|
-
}));
|
|
104
|
-
});
|
|
105
|
-
export default SDocEditor;
|