@seafile/sdoc-editor 0.2.13-beta3 → 0.2.13
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 -6
- package/dist/basic-sdk/index.js +2 -2
- package/dist/basic-sdk/views/index.js +1 -2
- package/dist/components/doc-info/index.js +1 -4
- package/dist/components/doc-operations/index.js +1 -2
- package/dist/components/doc-operations/revision-operations/index.js +2 -2
- package/dist/context.js +0 -6
- package/dist/hooks/use-document.js +0 -3
- package/dist/index.js +1 -2
- package/dist/pages/simple-editor.js +37 -2
- package/dist/utils/index.js +0 -38
- package/package.json +2 -1
- package/public/locales/en/sdoc-editor.json +1 -2
- package/dist/basic-sdk/views/published-revision-diff-viewer.js +0 -59
- package/dist/pages/published-revision-viewer.js +0 -92
package/dist/api/seafile-api.js
CHANGED
|
@@ -110,12 +110,6 @@ var SeafileAPI = /*#__PURE__*/function () {
|
|
|
110
110
|
var url = 'api/v2.1/seadoc/revision/base-version-content/' + docUuid + '/';
|
|
111
111
|
return this.req.get(url);
|
|
112
112
|
}
|
|
113
|
-
}, {
|
|
114
|
-
key: "getPublishedRevisionContent",
|
|
115
|
-
value: function getPublishedRevisionContent(docUuid) {
|
|
116
|
-
var url = 'api/v2.1/seadoc/revision/published-content/' + docUuid + '/';
|
|
117
|
-
return this.req.get(url);
|
|
118
|
-
}
|
|
119
113
|
|
|
120
114
|
// local files
|
|
121
115
|
}, {
|
package/dist/basic-sdk/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import SDocEditor from './editor/sdoc-editor';
|
|
2
|
-
import { DiffViewer, SDocViewer
|
|
2
|
+
import { DiffViewer, SDocViewer } from './views';
|
|
3
3
|
import SDocOutline from './outline';
|
|
4
4
|
import EventBus from './utils/event-bus';
|
|
5
|
-
export { SDocEditor, SDocViewer, SDocOutline, EventBus, DiffViewer
|
|
5
|
+
export { SDocEditor, SDocViewer, SDocOutline, EventBus, DiffViewer };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import SDocViewer from './sdoc-viewer';
|
|
2
2
|
import DiffViewer from './sdoc-diff-viewer';
|
|
3
3
|
import RevisionDiffViewer from './revision-diff-viewer';
|
|
4
|
-
|
|
5
|
-
export { SDocViewer, DiffViewer, RevisionDiffViewer, PublishedRevisionDiffViewer };
|
|
4
|
+
export { SDocViewer, DiffViewer, RevisionDiffViewer };
|
|
@@ -48,7 +48,6 @@ var DocInfo = function DocInfo(_ref) {
|
|
|
48
48
|
var revisionCreatedAt = context.getSetting('revisionCreatedAt');
|
|
49
49
|
var oldDocName = context.getSetting('originFilename');
|
|
50
50
|
var revisionId = context.getSetting('revisionId');
|
|
51
|
-
var isPublished = context.getSetting('isPublished');
|
|
52
51
|
return /*#__PURE__*/React.createElement("div", {
|
|
53
52
|
className: "doc-info d-flex flex-column align-items-start"
|
|
54
53
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -57,9 +56,7 @@ var DocInfo = function DocInfo(_ref) {
|
|
|
57
56
|
className: "doc-name"
|
|
58
57
|
}, oldDocName), /*#__PURE__*/React.createElement("div", {
|
|
59
58
|
className: "sdoc-revision-order"
|
|
60
|
-
}, t('Revision') + ' ' + revisionId),
|
|
61
|
-
className: "sdoc-revision-order"
|
|
62
|
-
}, t('Published')), /*#__PURE__*/React.createElement(TipMessage, {
|
|
59
|
+
}, t('Revision') + ' ' + revisionId), /*#__PURE__*/React.createElement(TipMessage, {
|
|
63
60
|
isEditMode: isEditMode
|
|
64
61
|
})), /*#__PURE__*/React.createElement("div", {
|
|
65
62
|
className: "doc-state"
|
|
@@ -15,7 +15,6 @@ var DocOperations = function DocOperations(_ref) {
|
|
|
15
15
|
handleViewChangesToggle = _ref.handleViewChangesToggle,
|
|
16
16
|
handleRevisionPublished = _ref.handleRevisionPublished;
|
|
17
17
|
var isSdocRevision = context.getSetting('isSdocRevision');
|
|
18
|
-
var isPublished = context.getSetting('isPublished');
|
|
19
18
|
if (isMobile) {
|
|
20
19
|
return /*#__PURE__*/React.createElement("div", {
|
|
21
20
|
className: "doc-ops"
|
|
@@ -28,6 +27,6 @@ var DocOperations = function DocOperations(_ref) {
|
|
|
28
27
|
changes: changes,
|
|
29
28
|
handleViewChangesToggle: handleViewChangesToggle,
|
|
30
29
|
handleRevisionPublished: handleRevisionPublished
|
|
31
|
-
}),
|
|
30
|
+
}), /*#__PURE__*/React.createElement(CommentsOperation, null), !isSdocRevision && /*#__PURE__*/React.createElement(ShareOperation, null), /*#__PURE__*/React.createElement(HistoryOperation, null), /*#__PURE__*/React.createElement(CollaboratorsOperation, null), !isSdocRevision && /*#__PURE__*/React.createElement(MoreOperations, null));
|
|
32
31
|
};
|
|
33
32
|
export default withTranslation('sdoc-editor')(DocOperations);
|
|
@@ -78,7 +78,7 @@ var RevisionOperations = function RevisionOperations(_ref) {
|
|
|
78
78
|
|
|
79
79
|
// solve show change view in revision editor
|
|
80
80
|
var onViewChangesToggle = useCallback(function (isShowChanges) {
|
|
81
|
-
if (
|
|
81
|
+
if (isShowChanges) {
|
|
82
82
|
// The trick here is to send one more api request in order to use the same information box.
|
|
83
83
|
loadDocument().then(function (revisionContent) {
|
|
84
84
|
// Prevent users from switching if document contains conflicting content
|
|
@@ -94,7 +94,7 @@ var RevisionOperations = function RevisionOperations(_ref) {
|
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
96
|
handleViewChangesToggle(isShowChanges);
|
|
97
|
-
}, [handleViewChangesToggle, loadDocument, t
|
|
97
|
+
}, [handleViewChangesToggle, loadDocument, t]);
|
|
98
98
|
|
|
99
99
|
// publish revision
|
|
100
100
|
var publishRevision = useCallback(function () {
|
package/dist/context.js
CHANGED
|
@@ -216,12 +216,6 @@ var Context = /*#__PURE__*/function () {
|
|
|
216
216
|
var docUuid = this.getSetting('docUuid');
|
|
217
217
|
return this.api.getRevisionBaseVersionContent(docUuid);
|
|
218
218
|
}
|
|
219
|
-
}, {
|
|
220
|
-
key: "getPublishedRevisionContent",
|
|
221
|
-
value: function getPublishedRevisionContent() {
|
|
222
|
-
var docUuid = this.getSetting('docUuid');
|
|
223
|
-
return this.api.getPublishedRevisionContent(docUuid);
|
|
224
|
-
}
|
|
225
219
|
|
|
226
220
|
// local files
|
|
227
221
|
}, {
|
|
@@ -2,8 +2,6 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
2
2
|
import { useCallback, useEffect, useState } from 'react';
|
|
3
3
|
import context from '../context';
|
|
4
4
|
export var useDocument = function useDocument() {
|
|
5
|
-
var isSdocRevision = context.getSetting('isSdocRevision');
|
|
6
|
-
var isPublished = context.getSetting('isPublished');
|
|
7
5
|
var _useState = useState(true),
|
|
8
6
|
_useState2 = _slicedToArray(_useState, 2),
|
|
9
7
|
isFirstLoading = _useState2[0],
|
|
@@ -60,7 +58,6 @@ export var useDocument = function useDocument() {
|
|
|
60
58
|
});
|
|
61
59
|
}, [loadDocument]);
|
|
62
60
|
useEffect(function () {
|
|
63
|
-
if (isSdocRevision && isPublished) return;
|
|
64
61
|
loadDocument().then(function (document) {
|
|
65
62
|
setDocument(document);
|
|
66
63
|
setIsFirstLoading(false);
|
package/dist/index.js
CHANGED
|
@@ -3,5 +3,4 @@ import { EXTERNAL_EVENT } from './constants';
|
|
|
3
3
|
import SimpleEditor from './pages/simple-editor';
|
|
4
4
|
import SimpleViewer from './pages/simple-viewer';
|
|
5
5
|
import DiffViewer from './pages/diff-viewer';
|
|
6
|
-
|
|
7
|
-
export { SDocViewer, SimpleEditor, SimpleViewer, EventBus, EXTERNAL_EVENT, DiffViewer, PublishedRevisionViewer };
|
|
6
|
+
export { SDocViewer, SimpleEditor, SimpleViewer, EventBus, EXTERNAL_EVENT, DiffViewer };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
1
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
3
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
4
|
import { withTranslation } from 'react-i18next';
|
|
@@ -7,10 +8,11 @@ import DocOperations from '../components/doc-operations';
|
|
|
7
8
|
import Layout, { Header, Content } from '../layout';
|
|
8
9
|
import context from '../context';
|
|
9
10
|
import ErrorBoundary from './error-boundary';
|
|
11
|
+
import { REVISION_FIRST_LOAD_KEY, REVISION_FIRST_LOAD_VALUE } from '../constants';
|
|
12
|
+
import toaster from '../components/toast';
|
|
10
13
|
import { SDocEditor } from '../basic-sdk';
|
|
11
14
|
import { RevisionDiffViewer } from '../basic-sdk/views';
|
|
12
15
|
import { useDocument } from '../hooks/use-document';
|
|
13
|
-
import { resetWebTitleAndURL } from '../utils';
|
|
14
16
|
import '../assets/css/simple-editor.css';
|
|
15
17
|
var SimpleEditor = function SimpleEditor(_ref) {
|
|
16
18
|
var isStarred = _ref.isStarred,
|
|
@@ -39,7 +41,40 @@ var SimpleEditor = function SimpleEditor(_ref) {
|
|
|
39
41
|
|
|
40
42
|
// useMount: reset title
|
|
41
43
|
useEffect(function () {
|
|
42
|
-
|
|
44
|
+
var isSdocRevision = context.getSetting('isSdocRevision');
|
|
45
|
+
var originFilename = context.getSetting('originFilename');
|
|
46
|
+
if (isSdocRevision) {
|
|
47
|
+
window.document.getElementsByTagName('title')[0].innerText = "".concat(t('Revision'), " - ").concat(originFilename);
|
|
48
|
+
|
|
49
|
+
// show revision created success info
|
|
50
|
+
var url = new URL(window.location.href);
|
|
51
|
+
var searchParams = new URLSearchParams(url.search);
|
|
52
|
+
if (!searchParams.has(REVISION_FIRST_LOAD_KEY)) return;
|
|
53
|
+
var firstLoadValue = searchParams.get(REVISION_FIRST_LOAD_KEY);
|
|
54
|
+
if (firstLoadValue === REVISION_FIRST_LOAD_VALUE) {
|
|
55
|
+
var revisionId = context.getSetting('revisionId');
|
|
56
|
+
toaster.success(t('Revision_created', {
|
|
57
|
+
id: revisionId
|
|
58
|
+
}));
|
|
59
|
+
searchParams.delete(REVISION_FIRST_LOAD_KEY);
|
|
60
|
+
}
|
|
61
|
+
var newParamsString = '';
|
|
62
|
+
var _iterator = _createForOfIteratorHelper(searchParams.entries()),
|
|
63
|
+
_step;
|
|
64
|
+
try {
|
|
65
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
66
|
+
var item = _step.value;
|
|
67
|
+
newParamsString = newParamsString + "&".concat(item[0], "=").concat(item[1]);
|
|
68
|
+
}
|
|
69
|
+
} catch (err) {
|
|
70
|
+
_iterator.e(err);
|
|
71
|
+
} finally {
|
|
72
|
+
_iterator.f();
|
|
73
|
+
}
|
|
74
|
+
var newURL = "".concat(url.origin).concat(url.pathname).concat(newParamsString ? '/?' + newParamsString : '');
|
|
75
|
+
window.history.replaceState(null, null, newURL);
|
|
76
|
+
}
|
|
77
|
+
|
|
43
78
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
44
79
|
}, []);
|
|
45
80
|
var setDiffChanges = useCallback(function (diff) {
|
package/dist/utils/index.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
2
1
|
import DateUtils from './date-utils';
|
|
3
2
|
import LocalStorage from './local-storage-utils';
|
|
4
|
-
import context from '../context';
|
|
5
|
-
import { REVISION_FIRST_LOAD_KEY, REVISION_FIRST_LOAD_VALUE } from '../constants';
|
|
6
|
-
import toaster from '../components/toast';
|
|
7
3
|
export var getDirPath = function getDirPath(path) {
|
|
8
4
|
var dir = path.slice(0, path.lastIndexOf('/'));
|
|
9
5
|
if (dir === '') {
|
|
@@ -49,38 +45,4 @@ export var isMac = function isMac() {
|
|
|
49
45
|
return platform === 'Mac68K' || platform === 'MacPPC' || platform === 'Macintosh' || platform === 'MacIntel';
|
|
50
46
|
};
|
|
51
47
|
export var isMobile = typeof window !== 'undefined' && (window.innerWidth < 768 || navigator.userAgent.toLowerCase().match(/(ipod|ipad|iphone|android|coolpad|mmp|smartphone|midp|wap|xoom|symbian|j2me|blackberry|wince)/i) != null);
|
|
52
|
-
export var resetWebTitleAndURL = function resetWebTitleAndURL(t) {
|
|
53
|
-
var isSdocRevision = context.getSetting('isSdocRevision');
|
|
54
|
-
var originFilename = context.getSetting('originFilename');
|
|
55
|
-
if (!isSdocRevision) return;
|
|
56
|
-
window.document.getElementsByTagName('title')[0].innerText = "".concat(t('Revision'), " - ").concat(originFilename);
|
|
57
|
-
|
|
58
|
-
// show revision created success info
|
|
59
|
-
var url = new URL(window.location.href);
|
|
60
|
-
var searchParams = new URLSearchParams(url.search);
|
|
61
|
-
if (!searchParams.has(REVISION_FIRST_LOAD_KEY)) return;
|
|
62
|
-
var firstLoadValue = searchParams.get(REVISION_FIRST_LOAD_KEY);
|
|
63
|
-
if (firstLoadValue === REVISION_FIRST_LOAD_VALUE) {
|
|
64
|
-
var revisionId = context.getSetting('revisionId');
|
|
65
|
-
toaster.success(t('Revision_created', {
|
|
66
|
-
id: revisionId
|
|
67
|
-
}));
|
|
68
|
-
searchParams.delete(REVISION_FIRST_LOAD_KEY);
|
|
69
|
-
}
|
|
70
|
-
var newParamsString = '';
|
|
71
|
-
var _iterator = _createForOfIteratorHelper(searchParams.entries()),
|
|
72
|
-
_step;
|
|
73
|
-
try {
|
|
74
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
75
|
-
var item = _step.value;
|
|
76
|
-
newParamsString = newParamsString + "&".concat(item[0], "=").concat(item[1]);
|
|
77
|
-
}
|
|
78
|
-
} catch (err) {
|
|
79
|
-
_iterator.e(err);
|
|
80
|
-
} finally {
|
|
81
|
-
_iterator.f();
|
|
82
|
-
}
|
|
83
|
-
var newURL = "".concat(url.origin).concat(url.pathname).concat(newParamsString ? '/?' + newParamsString : '');
|
|
84
|
-
window.history.replaceState(null, null, newURL);
|
|
85
|
-
};
|
|
86
48
|
export { DateUtils, LocalStorage };
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seafile/sdoc-editor",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.13",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "This is a sdoc editor",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@seafile/react-image-lightbox": "2.0.4",
|
|
9
|
+
"@seafile/sdoc-editor": "0.2.12",
|
|
9
10
|
"@seafile/slate": "0.91.8",
|
|
10
11
|
"@seafile/slate-history": "0.86.2",
|
|
11
12
|
"@seafile/slate-hyperscript": "0.81.7",
|
|
@@ -385,6 +385,5 @@
|
|
|
385
385
|
"Image_border": "Image border",
|
|
386
386
|
"Delete_revision": "Delete revision",
|
|
387
387
|
"Delete_tip": "Are you sure you want to delete {{content}} ?",
|
|
388
|
-
"Revision_deleted": "Revision deleted"
|
|
389
|
-
"Published": "Published"
|
|
388
|
+
"Revision_deleted": "Revision deleted"
|
|
390
389
|
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
-
import React, { useEffect, useState } from 'react';
|
|
3
|
-
import context from '../../context';
|
|
4
|
-
import { getDiff } from '../utils/diff';
|
|
5
|
-
import SDocViewer from './sdoc-viewer';
|
|
6
|
-
import Loading from '../../components/loading';
|
|
7
|
-
import '../../assets/css/diff-viewer.css';
|
|
8
|
-
var PublishedRevisionDiffViewer = function PublishedRevisionDiffViewer(_ref) {
|
|
9
|
-
var isShowChanges = _ref.isShowChanges,
|
|
10
|
-
revisionContent = _ref.revisionContent,
|
|
11
|
-
didMountCallback = _ref.didMountCallback;
|
|
12
|
-
var _useState = useState(true),
|
|
13
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
14
|
-
isLoading = _useState2[0],
|
|
15
|
-
setIsLoading = _useState2[1];
|
|
16
|
-
var _useState3 = useState(null),
|
|
17
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
18
|
-
diff = _useState4[0],
|
|
19
|
-
setDiff = _useState4[1];
|
|
20
|
-
useEffect(function () {
|
|
21
|
-
setIsLoading(true);
|
|
22
|
-
if (isShowChanges) {
|
|
23
|
-
if (diff) {
|
|
24
|
-
didMountCallback && didMountCallback(diff);
|
|
25
|
-
setTimeout(function () {
|
|
26
|
-
setIsLoading(false);
|
|
27
|
-
}, 1);
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
context.getRevisionBaseVersionContent().then(function (res) {
|
|
31
|
-
var baseContentString = res.data.content;
|
|
32
|
-
var baseContent = JSON.parse(baseContentString);
|
|
33
|
-
var diff = getDiff(revisionContent, baseContent);
|
|
34
|
-
setDiff(diff);
|
|
35
|
-
didMountCallback && didMountCallback(diff);
|
|
36
|
-
setIsLoading(false);
|
|
37
|
-
}).catch(function (error) {
|
|
38
|
-
console.log('error');
|
|
39
|
-
setIsLoading(false);
|
|
40
|
-
});
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
setTimeout(function () {
|
|
44
|
-
setIsLoading(false);
|
|
45
|
-
}, 1);
|
|
46
|
-
}, [revisionContent, didMountCallback, isShowChanges, diff]);
|
|
47
|
-
if (isLoading) {
|
|
48
|
-
return /*#__PURE__*/React.createElement(Loading, null);
|
|
49
|
-
}
|
|
50
|
-
var document = {
|
|
51
|
-
children: isShowChanges && (diff === null || diff === void 0 ? void 0 : diff.value) || revisionContent.children
|
|
52
|
-
};
|
|
53
|
-
return /*#__PURE__*/React.createElement(SDocViewer, {
|
|
54
|
-
showToolbar: true,
|
|
55
|
-
showOutline: true,
|
|
56
|
-
document: document
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
export default PublishedRevisionDiffViewer;
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
-
import React, { useCallback, useEffect, useState } from 'react';
|
|
3
|
-
import { useTranslation } from 'react-i18next';
|
|
4
|
-
import Loading from '../components/loading';
|
|
5
|
-
import DocInfo from '../components/doc-info';
|
|
6
|
-
import DocOperations from '../components/doc-operations';
|
|
7
|
-
import Layout, { Header, Content } from '../layout';
|
|
8
|
-
import context from '../context';
|
|
9
|
-
import ErrorBoundary from './error-boundary';
|
|
10
|
-
import { PublishedRevisionDiffViewer } from '../basic-sdk';
|
|
11
|
-
import { resetWebTitleAndURL } from '../utils';
|
|
12
|
-
import '../assets/css/simple-editor.css';
|
|
13
|
-
var PublishedRevisionViewer = function PublishedRevisionViewer() {
|
|
14
|
-
context.initApi();
|
|
15
|
-
var _useTranslation = useTranslation(),
|
|
16
|
-
t = _useTranslation.t;
|
|
17
|
-
var _useState = useState(true),
|
|
18
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
19
|
-
isFirstLoading = _useState2[0],
|
|
20
|
-
setIsFirstLoading = _useState2[1];
|
|
21
|
-
var _useState3 = useState(''),
|
|
22
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
23
|
-
errorMessage = _useState4[0],
|
|
24
|
-
setErrorMessage = _useState4[1];
|
|
25
|
-
var _useState5 = useState(false),
|
|
26
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
27
|
-
isShowChanges = _useState6[0],
|
|
28
|
-
setShowChanges = _useState6[1];
|
|
29
|
-
var _useState7 = useState([]),
|
|
30
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
31
|
-
changes = _useState8[0],
|
|
32
|
-
setChanges = _useState8[1];
|
|
33
|
-
var _useState9 = useState({}),
|
|
34
|
-
_useState10 = _slicedToArray(_useState9, 2),
|
|
35
|
-
document = _useState10[0],
|
|
36
|
-
setDocument = _useState10[1];
|
|
37
|
-
|
|
38
|
-
// useMount: reset title
|
|
39
|
-
useEffect(function () {
|
|
40
|
-
resetWebTitleAndURL(t);
|
|
41
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
42
|
-
}, []);
|
|
43
|
-
useEffect(function () {
|
|
44
|
-
context.getPublishedRevisionContent().then(function (res) {
|
|
45
|
-
var revisionContentString = res.data.content;
|
|
46
|
-
var document = JSON.parse(revisionContentString);
|
|
47
|
-
setDocument(document);
|
|
48
|
-
setIsFirstLoading(false);
|
|
49
|
-
}).catch(function (error) {
|
|
50
|
-
// eslint-disable-next-line
|
|
51
|
-
console.log(error);
|
|
52
|
-
var errorMessage = 'Load_doc_content_error';
|
|
53
|
-
if (error && error.response) {
|
|
54
|
-
var _ref = error.response.data || {},
|
|
55
|
-
error_type = _ref.error_type;
|
|
56
|
-
if (error_type === 'content_invalid') {
|
|
57
|
-
errorMessage = 'Sdoc_format_invalid';
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
setErrorMessage(errorMessage);
|
|
61
|
-
setIsFirstLoading(false);
|
|
62
|
-
});
|
|
63
|
-
}, []);
|
|
64
|
-
var setDiffChanges = useCallback(function (diff) {
|
|
65
|
-
setChanges((diff === null || diff === void 0 ? void 0 : diff.changes) || []);
|
|
66
|
-
}, []);
|
|
67
|
-
var handleViewChangesToggle = useCallback(function (isShowChanges) {
|
|
68
|
-
setShowChanges(isShowChanges);
|
|
69
|
-
}, []);
|
|
70
|
-
if (isFirstLoading) {
|
|
71
|
-
return /*#__PURE__*/React.createElement(Loading, null);
|
|
72
|
-
}
|
|
73
|
-
if (errorMessage) {
|
|
74
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
75
|
-
className: "error-page"
|
|
76
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
77
|
-
className: "error-tip"
|
|
78
|
-
}, t(errorMessage)));
|
|
79
|
-
}
|
|
80
|
-
return /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement(Layout, null, /*#__PURE__*/React.createElement(Header, null, /*#__PURE__*/React.createElement(DocInfo, {
|
|
81
|
-
isEditMode: false
|
|
82
|
-
}), /*#__PURE__*/React.createElement(DocOperations, {
|
|
83
|
-
isShowChanges: isShowChanges,
|
|
84
|
-
changes: changes,
|
|
85
|
-
handleViewChangesToggle: handleViewChangesToggle
|
|
86
|
-
})), /*#__PURE__*/React.createElement(Content, null, /*#__PURE__*/React.createElement(PublishedRevisionDiffViewer, {
|
|
87
|
-
isShowChanges: isShowChanges,
|
|
88
|
-
revisionContent: document,
|
|
89
|
-
didMountCallback: setDiffChanges
|
|
90
|
-
}))));
|
|
91
|
-
};
|
|
92
|
-
export default PublishedRevisionViewer;
|