@seafile/sdoc-editor 0.2.13 → 0.2.15
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 -0
- package/dist/basic-sdk/assets/css/sdoc-editor-plugins.css +26 -0
- package/dist/basic-sdk/comment/comment/comment-item-content.js +5 -10
- package/dist/basic-sdk/comment/comment/comment-list.css +6 -10
- package/dist/basic-sdk/extension/commons/color-menu/index.js +1 -1
- package/dist/basic-sdk/extension/commons/menu/menu-item.js +1 -1
- package/dist/basic-sdk/extension/plugins/code-block/hover-menu/index.css +0 -18
- package/dist/basic-sdk/extension/plugins/code-block/hover-menu/index.js +27 -9
- package/dist/basic-sdk/extension/plugins/code-block/render-elem.js +3 -2
- package/dist/basic-sdk/extension/plugins/font/menu/font-family/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/font/menu/font-size/font-size-scale.js +1 -1
- package/dist/basic-sdk/extension/plugins/font/menu/font-size/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/header/menu/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/image/hover-menu/index.js +18 -2
- package/dist/basic-sdk/extension/plugins/image/render-elem.js +69 -22
- package/dist/basic-sdk/extension/plugins/table/helpers.js +60 -0
- package/dist/basic-sdk/index.js +2 -2
- package/dist/basic-sdk/node-id/index.js +3 -2
- package/dist/basic-sdk/outline/index.js +2 -2
- package/dist/basic-sdk/utils/document-utils.js +11 -1
- package/dist/basic-sdk/views/index.js +2 -1
- package/dist/basic-sdk/views/published-revision-diff-viewer.js +59 -0
- package/dist/components/doc-info/index.js +4 -1
- package/dist/components/doc-operations/index.js +2 -1
- package/dist/components/doc-operations/revision-operations/changes-count/index.js +1 -1
- package/dist/components/doc-operations/revision-operations/index.js +2 -2
- package/dist/components/doc-operations/revision-operations/view-changes/index.js +3 -4
- package/dist/components/tooltip/index.js +31 -0
- package/dist/context.js +6 -0
- package/dist/hooks/use-document.js +8 -1
- package/dist/index.js +2 -1
- package/dist/pages/published-revision-viewer.js +92 -0
- package/dist/pages/simple-editor.js +2 -37
- package/dist/utils/index.js +38 -0
- package/package.json +1 -2
- package/public/locales/cs/sdoc-editor.json +2 -1
- package/public/locales/de/sdoc-editor.json +2 -1
- package/public/locales/en/sdoc-editor.json +5 -1
- package/public/locales/es/sdoc-editor.json +2 -1
- package/public/locales/fr/sdoc-editor.json +2 -1
- package/public/locales/it/sdoc-editor.json +2 -1
- package/public/locales/ru/sdoc-editor.json +2 -1
- package/public/locales/zh_CN/sdoc-editor.json +5 -1
- package/public/media/sdoc-editor-font/iconfont.eot +0 -0
- package/public/media/sdoc-editor-font/iconfont.svg +2 -0
- package/public/media/sdoc-editor-font/iconfont.ttf +0 -0
- package/public/media/sdoc-editor-font/iconfont.woff +0 -0
- package/public/media/sdoc-editor-font/iconfont.woff2 +0 -0
- package/public/media/sdoc-editor-font.css +10 -6
- package/dist/basic-sdk/extension/commons/tooltip/index.js +0 -21
- /package/dist/{basic-sdk/extension/commons → components}/tooltip/index.css +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import SDocViewer from './sdoc-viewer';
|
|
2
2
|
import DiffViewer from './sdoc-diff-viewer';
|
|
3
3
|
import RevisionDiffViewer from './revision-diff-viewer';
|
|
4
|
-
|
|
4
|
+
import PublishedRevisionDiffViewer from './published-revision-diff-viewer';
|
|
5
|
+
export { SDocViewer, DiffViewer, RevisionDiffViewer, PublishedRevisionDiffViewer };
|
|
@@ -0,0 +1,59 @@
|
|
|
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;
|
|
@@ -48,6 +48,7 @@ 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');
|
|
51
52
|
return /*#__PURE__*/React.createElement("div", {
|
|
52
53
|
className: "doc-info d-flex flex-column align-items-start"
|
|
53
54
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -56,7 +57,9 @@ var DocInfo = function DocInfo(_ref) {
|
|
|
56
57
|
className: "doc-name"
|
|
57
58
|
}, oldDocName), /*#__PURE__*/React.createElement("div", {
|
|
58
59
|
className: "sdoc-revision-order"
|
|
59
|
-
}, t('Revision') + ' ' + revisionId), /*#__PURE__*/React.createElement(
|
|
60
|
+
}, t('Revision') + ' ' + revisionId), isPublished && /*#__PURE__*/React.createElement("div", {
|
|
61
|
+
className: "sdoc-revision-order"
|
|
62
|
+
}, t('Published')), /*#__PURE__*/React.createElement(TipMessage, {
|
|
60
63
|
isEditMode: isEditMode
|
|
61
64
|
})), /*#__PURE__*/React.createElement("div", {
|
|
62
65
|
className: "doc-state"
|
|
@@ -15,6 +15,7 @@ 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');
|
|
18
19
|
if (isMobile) {
|
|
19
20
|
return /*#__PURE__*/React.createElement("div", {
|
|
20
21
|
className: "doc-ops"
|
|
@@ -27,6 +28,6 @@ var DocOperations = function DocOperations(_ref) {
|
|
|
27
28
|
changes: changes,
|
|
28
29
|
handleViewChangesToggle: handleViewChangesToggle,
|
|
29
30
|
handleRevisionPublished: handleRevisionPublished
|
|
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));
|
|
31
|
+
}), !isPublished && /*#__PURE__*/React.createElement(CommentsOperation, null), !isSdocRevision && /*#__PURE__*/React.createElement(ShareOperation, null), /*#__PURE__*/React.createElement(HistoryOperation, null), !isPublished && /*#__PURE__*/React.createElement(CollaboratorsOperation, null), !isSdocRevision && /*#__PURE__*/React.createElement(MoreOperations, null));
|
|
31
32
|
};
|
|
32
33
|
export default withTranslation('sdoc-editor')(DocOperations);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
2
|
import React, { useCallback, useState } from 'react';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
|
-
import Tooltip from '
|
|
4
|
+
import Tooltip from '../../../tooltip';
|
|
5
5
|
import './index.css';
|
|
6
6
|
var ChangesCount = function ChangesCount(_ref) {
|
|
7
7
|
var changes = _ref.changes;
|
|
@@ -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 (isShowChanges) {
|
|
81
|
+
if (!isPublished && 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, isPublished]);
|
|
98
98
|
|
|
99
99
|
// publish revision
|
|
100
100
|
var publishRevision = useCallback(function () {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
2
|
import { useTranslation } from 'react-i18next';
|
|
3
|
-
import { UncontrolledTooltip } from 'reactstrap';
|
|
4
3
|
import Switch from '../../../switch';
|
|
4
|
+
import Tooltip from '../../../tooltip';
|
|
5
5
|
import './index.css';
|
|
6
6
|
var ViewChanges = function ViewChanges(_ref) {
|
|
7
7
|
var isShowChanges = _ref.isShowChanges,
|
|
@@ -19,9 +19,8 @@ var ViewChanges = function ViewChanges(_ref) {
|
|
|
19
19
|
checked: isShowChanges,
|
|
20
20
|
onChange: onViewChangesToggle,
|
|
21
21
|
className: "sdoc-toggle-revision-changes d-flex align-items-center"
|
|
22
|
-
})), /*#__PURE__*/React.createElement(
|
|
23
|
-
target: "sdoc-toggle-revision-changes-container"
|
|
24
|
-
fade: false
|
|
22
|
+
})), /*#__PURE__*/React.createElement(Tooltip, {
|
|
23
|
+
target: "sdoc-toggle-revision-changes-container"
|
|
25
24
|
}, t('View_changes')));
|
|
26
25
|
};
|
|
27
26
|
export default ViewChanges;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { UncontrolledTooltip } from 'reactstrap';
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
import './index.css';
|
|
6
|
+
var Tooltip = function Tooltip(_ref) {
|
|
7
|
+
var target = _ref.target,
|
|
8
|
+
children = _ref.children,
|
|
9
|
+
className = _ref.className,
|
|
10
|
+
modifiers = _ref.modifiers,
|
|
11
|
+
_ref$placement = _ref.placement,
|
|
12
|
+
placement = _ref$placement === void 0 ? 'bottom' : _ref$placement,
|
|
13
|
+
_ref$fade = _ref.fade,
|
|
14
|
+
fade = _ref$fade === void 0 ? false : _ref$fade,
|
|
15
|
+
_ref$delay = _ref.delay,
|
|
16
|
+
delay = _ref$delay === void 0 ? 0 : _ref$delay;
|
|
17
|
+
var props = {
|
|
18
|
+
popperClassName: classnames('sdoc-tooltip', className),
|
|
19
|
+
modifiers: _objectSpread(_objectSpread({}, modifiers), {}, {
|
|
20
|
+
preventOverflow: _objectSpread({
|
|
21
|
+
boundariesElement: window.document.body
|
|
22
|
+
}, modifiers === null || modifiers === void 0 ? void 0 : modifiers.preventOverflow)
|
|
23
|
+
}),
|
|
24
|
+
placement: placement,
|
|
25
|
+
target: target,
|
|
26
|
+
fade: fade,
|
|
27
|
+
delay: delay
|
|
28
|
+
};
|
|
29
|
+
return /*#__PURE__*/React.createElement(UncontrolledTooltip, props, children);
|
|
30
|
+
};
|
|
31
|
+
export default Tooltip;
|
package/dist/context.js
CHANGED
|
@@ -216,6 +216,12 @@ 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
|
+
}
|
|
219
225
|
|
|
220
226
|
// local files
|
|
221
227
|
}, {
|
|
@@ -2,6 +2,8 @@ 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');
|
|
5
7
|
var _useState = useState(true),
|
|
6
8
|
_useState2 = _slicedToArray(_useState, 2),
|
|
7
9
|
isFirstLoading = _useState2[0],
|
|
@@ -10,7 +12,11 @@ export var useDocument = function useDocument() {
|
|
|
10
12
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
11
13
|
isReloading = _useState4[0],
|
|
12
14
|
setIsReloading = _useState4[1];
|
|
13
|
-
var _useState5 = useState(
|
|
15
|
+
var _useState5 = useState({
|
|
16
|
+
version: 0,
|
|
17
|
+
children: [],
|
|
18
|
+
cursors: {}
|
|
19
|
+
}),
|
|
14
20
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
15
21
|
document = _useState6[0],
|
|
16
22
|
setDocument = _useState6[1];
|
|
@@ -58,6 +64,7 @@ export var useDocument = function useDocument() {
|
|
|
58
64
|
});
|
|
59
65
|
}, [loadDocument]);
|
|
60
66
|
useEffect(function () {
|
|
67
|
+
if (isSdocRevision && isPublished) return;
|
|
61
68
|
loadDocument().then(function (document) {
|
|
62
69
|
setDocument(document);
|
|
63
70
|
setIsFirstLoading(false);
|
package/dist/index.js
CHANGED
|
@@ -3,4 +3,5 @@ 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
|
-
|
|
6
|
+
import PublishedRevisionViewer from './pages/published-revision-viewer';
|
|
7
|
+
export { SDocViewer, SimpleEditor, SimpleViewer, EventBus, EXTERNAL_EVENT, DiffViewer, PublishedRevisionViewer };
|
|
@@ -0,0 +1,92 @@
|
|
|
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;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
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';
|
|
@@ -8,11 +7,10 @@ import DocOperations from '../components/doc-operations';
|
|
|
8
7
|
import Layout, { Header, Content } from '../layout';
|
|
9
8
|
import context from '../context';
|
|
10
9
|
import ErrorBoundary from './error-boundary';
|
|
11
|
-
import { REVISION_FIRST_LOAD_KEY, REVISION_FIRST_LOAD_VALUE } from '../constants';
|
|
12
|
-
import toaster from '../components/toast';
|
|
13
10
|
import { SDocEditor } from '../basic-sdk';
|
|
14
11
|
import { RevisionDiffViewer } from '../basic-sdk/views';
|
|
15
12
|
import { useDocument } from '../hooks/use-document';
|
|
13
|
+
import { resetWebTitleAndURL } from '../utils';
|
|
16
14
|
import '../assets/css/simple-editor.css';
|
|
17
15
|
var SimpleEditor = function SimpleEditor(_ref) {
|
|
18
16
|
var isStarred = _ref.isStarred,
|
|
@@ -41,40 +39,7 @@ var SimpleEditor = function SimpleEditor(_ref) {
|
|
|
41
39
|
|
|
42
40
|
// useMount: reset title
|
|
43
41
|
useEffect(function () {
|
|
44
|
-
|
|
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
|
-
|
|
42
|
+
resetWebTitleAndURL(t);
|
|
78
43
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
79
44
|
}, []);
|
|
80
45
|
var setDiffChanges = useCallback(function (diff) {
|
package/dist/utils/index.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
1
2
|
import DateUtils from './date-utils';
|
|
2
3
|
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';
|
|
3
7
|
export var getDirPath = function getDirPath(path) {
|
|
4
8
|
var dir = path.slice(0, path.lastIndexOf('/'));
|
|
5
9
|
if (dir === '') {
|
|
@@ -45,4 +49,38 @@ export var isMac = function isMac() {
|
|
|
45
49
|
return platform === 'Mac68K' || platform === 'MacPPC' || platform === 'Macintosh' || platform === 'MacIntel';
|
|
46
50
|
};
|
|
47
51
|
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
|
+
};
|
|
48
86
|
export { DateUtils, LocalStorage };
|
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seafile/sdoc-editor",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.15",
|
|
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",
|
|
10
9
|
"@seafile/slate": "0.91.8",
|
|
11
10
|
"@seafile/slate-history": "0.86.2",
|
|
12
11
|
"@seafile/slate-hyperscript": "0.81.7",
|
|
@@ -385,5 +385,6 @@
|
|
|
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"
|
|
388
|
+
"Revision_deleted": "Revision deleted",
|
|
389
|
+
"Published": "Zveřejněné"
|
|
389
390
|
}
|
|
@@ -385,5 +385,6 @@
|
|
|
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"
|
|
388
|
+
"Revision_deleted": "Revision deleted",
|
|
389
|
+
"Published": "Veröffentlicht"
|
|
389
390
|
}
|
|
@@ -385,5 +385,9 @@
|
|
|
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"
|
|
388
|
+
"Revision_deleted": "Revision deleted",
|
|
389
|
+
"Published": "Published",
|
|
390
|
+
"Delete_Successfully": "Delete Successfully",
|
|
391
|
+
"Delete_failed": "Delete failed",
|
|
392
|
+
"Insert_caption": "Insert caption"
|
|
389
393
|
}
|
|
@@ -385,5 +385,6 @@
|
|
|
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"
|
|
388
|
+
"Revision_deleted": "Revision deleted",
|
|
389
|
+
"Published": "Publicado"
|
|
389
390
|
}
|
|
@@ -385,5 +385,6 @@
|
|
|
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"
|
|
388
|
+
"Revision_deleted": "Revision deleted",
|
|
389
|
+
"Published": "Publié"
|
|
389
390
|
}
|
|
@@ -385,5 +385,6 @@
|
|
|
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"
|
|
388
|
+
"Revision_deleted": "Revision deleted",
|
|
389
|
+
"Published": "Pubblicato"
|
|
389
390
|
}
|
|
@@ -385,5 +385,6 @@
|
|
|
385
385
|
"Image_border": "Граница изображения",
|
|
386
386
|
"Delete_revision": "Удалить редакцию",
|
|
387
387
|
"Delete_tip": "Вы уверены, что хотите удалить {{content}} ?",
|
|
388
|
-
"Revision_deleted": "
|
|
388
|
+
"Revision_deleted": "Версия удалена",
|
|
389
|
+
"Published": "Опубликовано"
|
|
389
390
|
}
|
|
@@ -385,5 +385,9 @@
|
|
|
385
385
|
"Image_border": "图片边框",
|
|
386
386
|
"Delete_revision": "删除修订稿",
|
|
387
387
|
"Delete_tip": "确定要删除 {{content}} 吗?",
|
|
388
|
-
"Revision_deleted": "修订稿已删除"
|
|
388
|
+
"Revision_deleted": "修订稿已删除",
|
|
389
|
+
"Published": "已发布",
|
|
390
|
+
"Delete_Successfully": "删除成功",
|
|
391
|
+
"Delete_failed": "删除失败",
|
|
392
|
+
"Insert_caption": "添加图片描述"
|
|
389
393
|
}
|
|
Binary file
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
/>
|
|
15
15
|
<missing-glyph />
|
|
16
16
|
|
|
17
|
+
<glyph glyph-name="sdoc-describe" unicode="" d="M992 352H32c-19.2 0-32 12.8-32 32V832c0 19.2 12.8 32 32 32h960c19.2 0 32-12.8 32-32v-448c0-19.2-12.8-32-32-32zM96 448h832V768H96v-320z m-96-224v-96h1024v96H0z m0-224v-96h576v96H0z" horiz-adv-x="1024" />
|
|
18
|
+
|
|
17
19
|
<glyph glyph-name="sdoc-add-comment" unicode="" d="M960 896c35.2 0 64-28.8 64-64v-704c0-35.2-28.8-64-64-64h-224l-224-192-224 192H64c-35.2 0-64 28.8-64 64V832C0 867.2 28.8 896 64 896h896z m-32-96H96v-640h227.2l188.8-160 188.8 160H928V800zM288 528h448v-96H288zM464 704h96v-448h-96z" horiz-adv-x="1024" />
|
|
18
20
|
|
|
19
21
|
<glyph glyph-name="sdoc-comment-count" unicode="" d="M1024 832v-704c0-35.2-28.8-64-64-64h-192l-256-192-224 192H64c-35.2 0-64 28.8-64 64V832C0 867.2 28.8 896 64 896h896c35.2 0 64-28.8 64-64z" horiz-adv-x="1024" />
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
@font-face {
|
|
2
2
|
font-family: "sdocfont"; /* Project id 4097705 */
|
|
3
|
-
src: url('./sdoc-editor-font/iconfont.eot?t=
|
|
4
|
-
src: url('./sdoc-editor-font/iconfont.eot?t=
|
|
5
|
-
url('./sdoc-editor-font/iconfont.woff2?t=
|
|
6
|
-
url('./sdoc-editor-font/iconfont.woff?t=
|
|
7
|
-
url('./sdoc-editor-font/iconfont.ttf?t=
|
|
8
|
-
url('./sdoc-editor-font/iconfont.svg?t=
|
|
3
|
+
src: url('./sdoc-editor-font/iconfont.eot?t=1698118988223'); /* IE9 */
|
|
4
|
+
src: url('./sdoc-editor-font/iconfont.eot?t=1698118988223#iefix') format('embedded-opentype'), /* IE6-IE8 */
|
|
5
|
+
url('./sdoc-editor-font/iconfont.woff2?t=1698118988223') format('woff2'),
|
|
6
|
+
url('./sdoc-editor-font/iconfont.woff?t=1698118988223') format('woff'),
|
|
7
|
+
url('./sdoc-editor-font/iconfont.ttf?t=1698118988223') format('truetype'),
|
|
8
|
+
url('./sdoc-editor-font/iconfont.svg?t=1698118988223#sdocfont') format('svg');
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
.sdocfont {
|
|
@@ -16,6 +16,10 @@
|
|
|
16
16
|
-moz-osx-font-smoothing: grayscale;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
.sdoc-describe:before {
|
|
20
|
+
content: "\e657";
|
|
21
|
+
}
|
|
22
|
+
|
|
19
23
|
.sdoc-add-comment:before {
|
|
20
24
|
content: "\e63b";
|
|
21
25
|
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { UncontrolledTooltip } from 'reactstrap';
|
|
3
|
-
import classnames from 'classnames';
|
|
4
|
-
import './index.css';
|
|
5
|
-
var Tooltip = function Tooltip(_ref) {
|
|
6
|
-
var target = _ref.target,
|
|
7
|
-
children = _ref.children,
|
|
8
|
-
className = _ref.className,
|
|
9
|
-
placement = _ref.placement,
|
|
10
|
-
_ref$fade = _ref.fade,
|
|
11
|
-
fade = _ref$fade === void 0 ? false : _ref$fade;
|
|
12
|
-
var popperClassName = classnames('sdoc-tooltip', className);
|
|
13
|
-
return /*#__PURE__*/React.createElement(UncontrolledTooltip, {
|
|
14
|
-
popperClassName: popperClassName,
|
|
15
|
-
target: target,
|
|
16
|
-
fade: fade,
|
|
17
|
-
placement: placement || 'bottom',
|
|
18
|
-
delay: 0
|
|
19
|
-
}, children);
|
|
20
|
-
};
|
|
21
|
-
export default Tooltip;
|
|
File without changes
|