@seafile/sdoc-editor 0.1.67-beta → 0.1.67
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/assets/css/diff-viewer.css +14 -0
- package/dist/assets/css/simple-editor.css +0 -5
- package/dist/components/doc-info/index.js +54 -50
- package/dist/components/doc-operations/index.js +78 -14
- package/dist/context.js +0 -10
- package/dist/pages/diff-viewer/diff-viewer.js +2 -2
- package/dist/utils/index.js +1 -18
- package/package.json +1 -1
- package/public/locales/en/sdoc-editor.json +1 -4
- package/public/locales/zh-CN/sdoc-editor.json +1 -4
- package/dist/components/doc-operations/history-operation.js +0 -21
- package/dist/components/doc-operations/more-operations.js +0 -44
- package/dist/components/doc-operations/revision-operations/index.js +0 -42
- package/dist/utils/date-utils.js +0 -86
package/dist/api/seafile-api.js
CHANGED
|
@@ -35,12 +35,6 @@ var SeafileAPI = /*#__PURE__*/function () {
|
|
|
35
35
|
var url = '/api/v2.1/seadoc/download-image/' + docUuid + '/' + encodeURIComponent(imageName);
|
|
36
36
|
return this.req.get(url);
|
|
37
37
|
}
|
|
38
|
-
}, {
|
|
39
|
-
key: "sdocPublishRevision",
|
|
40
|
-
value: function sdocPublishRevision(docUuid) {
|
|
41
|
-
var url = '/api/v2.1/seadoc/publish-revision/' + docUuid + '/';
|
|
42
|
-
return this.req.post(url);
|
|
43
|
-
}
|
|
44
38
|
}]);
|
|
45
39
|
return SeafileAPI;
|
|
46
40
|
}();
|
|
@@ -3,3 +3,17 @@
|
|
|
3
3
|
margin: 0 -5px;
|
|
4
4
|
overflow: hidden;
|
|
5
5
|
}
|
|
6
|
+
|
|
7
|
+
.sdoc-diff-added {
|
|
8
|
+
background-color: #e6ffed;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.sdoc-diff-removed {
|
|
12
|
+
background-color: #ffeef0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.sdoc-diff-modify {
|
|
16
|
+
padding-left: 2px;
|
|
17
|
+
margin-left: -5px;
|
|
18
|
+
border-left: 3px solid #f9c513;
|
|
19
|
+
}
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
|
|
6
6
|
.sdoc-editor-page-header .doc-info .doc-name {
|
|
7
7
|
font-size: 18px;
|
|
8
|
-
font-weight: 700;
|
|
9
8
|
color: #212529;
|
|
10
9
|
}
|
|
11
10
|
|
|
@@ -25,7 +24,3 @@
|
|
|
25
24
|
.sdoc-editor-page-header .doc-info .sdoc-link {
|
|
26
25
|
font-size: 14px;
|
|
27
26
|
}
|
|
28
|
-
|
|
29
|
-
.sdoc-editor-page-header .doc-state {
|
|
30
|
-
font-size: 0.8125rem;
|
|
31
|
-
}
|
|
@@ -1,57 +1,61 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
|
+
import React from 'react';
|
|
2
6
|
import TipMessage from '../tip-message';
|
|
3
7
|
import { withTranslation } from 'react-i18next';
|
|
4
8
|
import context from '../../context';
|
|
5
9
|
import { EventBus } from '../../basic-sdk';
|
|
6
10
|
import { EXTERNAL_EVENT } from '../../constants';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
title: isStarred ? t('Starred') : t('Unstarred'),
|
|
27
|
-
"aria-label": isStarred ? t('Unstar') : t('Star'),
|
|
28
|
-
onClick: toggleStar
|
|
29
|
-
}), isShowInternalLink && /*#__PURE__*/React.createElement("span", {
|
|
30
|
-
className: "doc-icon"
|
|
31
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
32
|
-
className: "internal-link sdocfont sdoc-link",
|
|
33
|
-
title: t('Internal_link'),
|
|
34
|
-
onClick: onInternalLinkClick
|
|
35
|
-
})), /*#__PURE__*/React.createElement(TipMessage, null));
|
|
36
|
-
if (!isSdocRevision) {
|
|
37
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
38
|
-
className: "doc-info"
|
|
39
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
40
|
-
className: "doc-name"
|
|
41
|
-
}, docName), docInfo);
|
|
11
|
+
var DocInfo = /*#__PURE__*/function (_React$Component) {
|
|
12
|
+
_inherits(DocInfo, _React$Component);
|
|
13
|
+
var _super = _createSuper(DocInfo);
|
|
14
|
+
function DocInfo() {
|
|
15
|
+
var _this;
|
|
16
|
+
_classCallCheck(this, DocInfo);
|
|
17
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
18
|
+
args[_key] = arguments[_key];
|
|
19
|
+
}
|
|
20
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
21
|
+
_this.onInternalLinkClick = function () {
|
|
22
|
+
var eventBus = EventBus.getInstance();
|
|
23
|
+
eventBus.dispatch(EXTERNAL_EVENT.INTERNAL_LINK_CLICK);
|
|
24
|
+
};
|
|
25
|
+
_this.toggleStar = function () {
|
|
26
|
+
var eventBus = EventBus.getInstance();
|
|
27
|
+
eventBus.dispatch(EXTERNAL_EVENT.TOGGLE_STAR);
|
|
28
|
+
};
|
|
29
|
+
return _this;
|
|
42
30
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
31
|
+
_createClass(DocInfo, [{
|
|
32
|
+
key: "render",
|
|
33
|
+
value: function render() {
|
|
34
|
+
var _this$props = this.props,
|
|
35
|
+
t = _this$props.t,
|
|
36
|
+
isStarred = _this$props.isStarred;
|
|
37
|
+
var docName = context.getSetting('docName');
|
|
38
|
+
var _context$getSettings = context.getSettings(),
|
|
39
|
+
isShowInternalLink = _context$getSettings.isShowInternalLink,
|
|
40
|
+
isStarIconShown = _context$getSettings.isStarIconShown;
|
|
41
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
42
|
+
className: "doc-info"
|
|
43
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
44
|
+
className: "doc-name"
|
|
45
|
+
}, docName), isStarIconShown && /*#__PURE__*/React.createElement("button", {
|
|
46
|
+
className: "doc-icon sdocfont ".concat(isStarred ? 'sdoc-starred' : 'sdoc-unstarred', " border-0 p-0 bg-transparent"),
|
|
47
|
+
title: isStarred ? t('Starred') : t('Unstarred'),
|
|
48
|
+
"aria-label": isStarred ? t('Unstar') : t('Star'),
|
|
49
|
+
onClick: this.toggleStar
|
|
50
|
+
}), isShowInternalLink && /*#__PURE__*/React.createElement("span", {
|
|
51
|
+
className: "doc-icon"
|
|
52
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
53
|
+
className: "internal-link sdocfont sdoc-link",
|
|
54
|
+
title: t('Internal_link'),
|
|
55
|
+
onClick: this.onInternalLinkClick
|
|
56
|
+
})), /*#__PURE__*/React.createElement(TipMessage, null));
|
|
57
|
+
}
|
|
58
|
+
}]);
|
|
59
|
+
return DocInfo;
|
|
60
|
+
}(React.Component);
|
|
57
61
|
export default withTranslation('sdoc-editor')(DocInfo);
|
|
@@ -1,17 +1,81 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
|
+
import React, { Fragment } from 'react';
|
|
6
|
+
import { Dropdown, DropdownToggle, DropdownMenu, DropdownItem } from 'reactstrap';
|
|
5
7
|
import CollaboratorsOperation from './collaborators-operation';
|
|
6
|
-
import
|
|
8
|
+
import context from '../../context';
|
|
9
|
+
import { withTranslation } from 'react-i18next';
|
|
7
10
|
import './style.css';
|
|
8
|
-
var DocOperations = function
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
var DocOperations = /*#__PURE__*/function (_React$Component) {
|
|
12
|
+
_inherits(DocOperations, _React$Component);
|
|
13
|
+
var _super = _createSuper(DocOperations);
|
|
14
|
+
function DocOperations(props) {
|
|
15
|
+
var _this;
|
|
16
|
+
_classCallCheck(this, DocOperations);
|
|
17
|
+
_this = _super.call(this, props);
|
|
18
|
+
_this.toggleDropdown = function () {
|
|
19
|
+
_this.setState({
|
|
20
|
+
isDropdownOpen: !_this.state.isDropdownOpen
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
_this.toggleHistory = function (event) {
|
|
24
|
+
event.stopPropagation();
|
|
25
|
+
event.nativeEvent.stopImmediatePropagation();
|
|
26
|
+
var historyURL = context.getSetting('historyURL');
|
|
27
|
+
window.location.href = historyURL;
|
|
28
|
+
};
|
|
29
|
+
_this.state = {
|
|
30
|
+
isDropdownOpen: false
|
|
31
|
+
};
|
|
32
|
+
return _this;
|
|
33
|
+
}
|
|
34
|
+
_createClass(DocOperations, [{
|
|
35
|
+
key: "render",
|
|
36
|
+
value: function render() {
|
|
37
|
+
var t = this.props.t;
|
|
38
|
+
var isDropdownOpen = this.state.isDropdownOpen;
|
|
39
|
+
var docPerm = context.getSetting('docPerm');
|
|
40
|
+
var historyURL = context.getSetting('historyURL');
|
|
41
|
+
var parentFolderURL = context.getSetting('parentFolderURL');
|
|
42
|
+
var dropdownItems = [];
|
|
43
|
+
if (parentFolderURL) {
|
|
44
|
+
dropdownItems.push({
|
|
45
|
+
text: t('Open_parent_folder'),
|
|
46
|
+
URL: parentFolderURL
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
50
|
+
className: "doc-ops"
|
|
51
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
52
|
+
className: "op-item"
|
|
53
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
54
|
+
className: "sdocfont sdoc-share"
|
|
55
|
+
})), docPerm === 'rw' && historyURL && /*#__PURE__*/React.createElement("span", {
|
|
56
|
+
className: "op-item",
|
|
57
|
+
onClick: this.toggleHistory
|
|
58
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
59
|
+
className: "sdocfont sdoc-history"
|
|
60
|
+
})), /*#__PURE__*/React.createElement(CollaboratorsOperation, null), dropdownItems.length > 0 && /*#__PURE__*/React.createElement(Dropdown, {
|
|
61
|
+
isOpen: isDropdownOpen,
|
|
62
|
+
toggle: this.toggleDropdown
|
|
63
|
+
}, /*#__PURE__*/React.createElement(DropdownToggle, {
|
|
64
|
+
className: "op-item",
|
|
65
|
+
tag: "span"
|
|
66
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
67
|
+
className: "sdocfont sdoc-menu"
|
|
68
|
+
})), /*#__PURE__*/React.createElement(DropdownMenu, {
|
|
69
|
+
right: true
|
|
70
|
+
}, dropdownItems.map(function (item, index) {
|
|
71
|
+
return /*#__PURE__*/React.createElement(DropdownItem, {
|
|
72
|
+
tag: "a",
|
|
73
|
+
href: item.URL,
|
|
74
|
+
key: index
|
|
75
|
+
}, item.text);
|
|
76
|
+
})))));
|
|
77
|
+
}
|
|
78
|
+
}]);
|
|
79
|
+
return DocOperations;
|
|
80
|
+
}(React.Component);
|
|
17
81
|
export default withTranslation('sdoc-editor')(DocOperations);
|
package/dist/context.js
CHANGED
|
@@ -101,8 +101,6 @@ var Context = /*#__PURE__*/function () {
|
|
|
101
101
|
avatar_url: avatarURL
|
|
102
102
|
};
|
|
103
103
|
}
|
|
104
|
-
|
|
105
|
-
// comments
|
|
106
104
|
}, {
|
|
107
105
|
key: "listComments",
|
|
108
106
|
value: function listComments() {
|
|
@@ -123,14 +121,6 @@ var Context = /*#__PURE__*/function () {
|
|
|
123
121
|
value: function updateComment(commentId, newComment) {
|
|
124
122
|
return this.sdocServerApi.updateComment(commentId, newComment);
|
|
125
123
|
}
|
|
126
|
-
|
|
127
|
-
// revision
|
|
128
|
-
}, {
|
|
129
|
-
key: "publishSdocRevision",
|
|
130
|
-
value: function publishSdocRevision() {
|
|
131
|
-
var docUuid = this.getSetting('docUuid');
|
|
132
|
-
return this.api.sdocPublishRevision(docUuid);
|
|
133
|
-
}
|
|
134
124
|
}]);
|
|
135
125
|
return Context;
|
|
136
126
|
}();
|
|
@@ -27,8 +27,8 @@ var DiffViewer = function DiffViewer(_ref) {
|
|
|
27
27
|
var type = element.type;
|
|
28
28
|
if (type === ELEMENT_TYPE.IMAGE && (element.ADD || element.DELETE)) {
|
|
29
29
|
var style = element.ADD ? ADDED_STYLE : DELETED_STYLE;
|
|
30
|
-
return /*#__PURE__*/React.createElement("
|
|
31
|
-
className: "
|
|
30
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
31
|
+
className: "p-1",
|
|
32
32
|
style: {
|
|
33
33
|
backgroundColor: style.background_color,
|
|
34
34
|
width: 'fit-content',
|
package/dist/utils/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import DateUtils from './date-utils';
|
|
2
1
|
export var getDirPath = function getDirPath(path) {
|
|
3
2
|
var dir = path.slice(0, path.lastIndexOf('/'));
|
|
4
3
|
if (dir === '') {
|
|
@@ -23,20 +22,4 @@ export var generateDefaultDocContent = function generateDefaultDocContent() {
|
|
|
23
22
|
export var getImageFileNameWithTimestamp = function getImageFileNameWithTimestamp() {
|
|
24
23
|
var d = Date.now();
|
|
25
24
|
return 'image-' + d.toString() + '.png';
|
|
26
|
-
};
|
|
27
|
-
export var getErrorMsg = function getErrorMsg(error) {
|
|
28
|
-
var errorMsg = '';
|
|
29
|
-
if (error.response) {
|
|
30
|
-
if (error.response.status === 403) {
|
|
31
|
-
errorMsg = 'Permission_denied';
|
|
32
|
-
} else if (error.response.data && error.response.data['error_msg']) {
|
|
33
|
-
errorMsg = error.response.data['error_msg'];
|
|
34
|
-
} else {
|
|
35
|
-
errorMsg = 'Error';
|
|
36
|
-
}
|
|
37
|
-
} else {
|
|
38
|
-
errorMsg = 'Please_check_the_network';
|
|
39
|
-
}
|
|
40
|
-
return errorMsg;
|
|
41
|
-
};
|
|
42
|
-
export { DateUtils };
|
|
25
|
+
};
|
package/package.json
CHANGED
|
@@ -251,8 +251,5 @@
|
|
|
251
251
|
"Add_comment": "Add comment",
|
|
252
252
|
"Delete_comment": "Delete comment",
|
|
253
253
|
"Are_you_sure_to_delete_this_comment": "Are you sure to delete this comment?",
|
|
254
|
-
"Confirm": "Confirm"
|
|
255
|
-
"View_changes": "View changes",
|
|
256
|
-
"Revision": "Revision",
|
|
257
|
-
"Error": "Error"
|
|
254
|
+
"Confirm": "Confirm"
|
|
258
255
|
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import React, { useCallback } from 'react';
|
|
2
|
-
import context from '../../context';
|
|
3
|
-
var HistoryOperation = function HistoryOperation() {
|
|
4
|
-
var docPerm = context.getSetting('docPerm');
|
|
5
|
-
var historyURL = context.getSetting('historyURL');
|
|
6
|
-
var toggleHistory = useCallback(function (event) {
|
|
7
|
-
event.stopPropagation();
|
|
8
|
-
event.nativeEvent.stopImmediatePropagation();
|
|
9
|
-
window.location.href = historyURL;
|
|
10
|
-
|
|
11
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
12
|
-
}, []);
|
|
13
|
-
if (docPerm !== 'rw' || !historyURL) return null;
|
|
14
|
-
return /*#__PURE__*/React.createElement("span", {
|
|
15
|
-
className: "op-item",
|
|
16
|
-
onClick: toggleHistory
|
|
17
|
-
}, /*#__PURE__*/React.createElement("i", {
|
|
18
|
-
className: "sdocfont sdoc-history"
|
|
19
|
-
}));
|
|
20
|
-
};
|
|
21
|
-
export default HistoryOperation;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
-
import React, { useCallback, useState } from 'react';
|
|
3
|
-
import { withTranslation } from 'react-i18next';
|
|
4
|
-
import { Dropdown, DropdownToggle, DropdownMenu, DropdownItem } from 'reactstrap';
|
|
5
|
-
import context from '../../context';
|
|
6
|
-
var MoreOperations = function MoreOperations(_ref) {
|
|
7
|
-
var t = _ref.t;
|
|
8
|
-
var _useState = useState(false),
|
|
9
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
10
|
-
isDropdownOpen = _useState2[0],
|
|
11
|
-
setIsDropdownOpen = _useState2[1];
|
|
12
|
-
var toggleDropdown = useCallback(function (isDropdownOpen) {
|
|
13
|
-
setIsDropdownOpen(!isDropdownOpen);
|
|
14
|
-
}, []);
|
|
15
|
-
var parentFolderURL = context.getSetting('parentFolderURL');
|
|
16
|
-
var dropdownItems = [];
|
|
17
|
-
if (parentFolderURL) {
|
|
18
|
-
dropdownItems.push({
|
|
19
|
-
text: t('Open_parent_folder'),
|
|
20
|
-
URL: parentFolderURL
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
if (dropdownItems.length === 0) return null;
|
|
24
|
-
return /*#__PURE__*/React.createElement(Dropdown, {
|
|
25
|
-
isOpen: isDropdownOpen,
|
|
26
|
-
toggle: function toggle() {
|
|
27
|
-
return toggleDropdown(isDropdownOpen);
|
|
28
|
-
}
|
|
29
|
-
}, /*#__PURE__*/React.createElement(DropdownToggle, {
|
|
30
|
-
className: "op-item",
|
|
31
|
-
tag: "span"
|
|
32
|
-
}, /*#__PURE__*/React.createElement("i", {
|
|
33
|
-
className: "sdocfont sdoc-menu"
|
|
34
|
-
})), /*#__PURE__*/React.createElement(DropdownMenu, {
|
|
35
|
-
right: true
|
|
36
|
-
}, dropdownItems.map(function (item, index) {
|
|
37
|
-
return /*#__PURE__*/React.createElement(DropdownItem, {
|
|
38
|
-
tag: "a",
|
|
39
|
-
href: item.URL,
|
|
40
|
-
key: index
|
|
41
|
-
}, item.text);
|
|
42
|
-
})));
|
|
43
|
-
};
|
|
44
|
-
export default withTranslation('sdoc-editor')(MoreOperations);
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import React, { useCallback } from 'react';
|
|
2
|
-
import { Button } from 'reactstrap';
|
|
3
|
-
import { withTranslation } from 'react-i18next';
|
|
4
|
-
import context from '../../../context';
|
|
5
|
-
import toaster from '../../../components/toast';
|
|
6
|
-
var RevisionOperations = function RevisionOperations(_ref) {
|
|
7
|
-
var t = _ref.t;
|
|
8
|
-
var isSdocRevision = context.getSetting('isSdocRevision');
|
|
9
|
-
var revisionURL = context.getSetting('revisionURL');
|
|
10
|
-
var isPublished = context.getSetting('isPublished');
|
|
11
|
-
var repoID = context.getSetting('repoID');
|
|
12
|
-
var siteRoot = context.getSetting('siteRoot');
|
|
13
|
-
var viewChanges = useCallback(function (event) {
|
|
14
|
-
event.stopPropagation();
|
|
15
|
-
event.nativeEvent.stopImmediatePropagation();
|
|
16
|
-
window.location.href = revisionURL;
|
|
17
|
-
|
|
18
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
19
|
-
}, []);
|
|
20
|
-
var publishRevision = useCallback(function (event) {
|
|
21
|
-
event.stopPropagation();
|
|
22
|
-
event.nativeEvent.stopImmediatePropagation();
|
|
23
|
-
context.publishSdocRevision().then(function (res) {
|
|
24
|
-
var origin_file_path = res.data.origin_file_path;
|
|
25
|
-
window.location.href = "".concat(siteRoot, "lib/").concat(repoID, "/file/").concat(origin_file_path);
|
|
26
|
-
}).catch(function (error) {
|
|
27
|
-
toaster.danger(t('Error'));
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
31
|
-
}, []);
|
|
32
|
-
if (!isSdocRevision) return null;
|
|
33
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, revisionURL && /*#__PURE__*/React.createElement(Button, {
|
|
34
|
-
color: "success",
|
|
35
|
-
className: "mr-4",
|
|
36
|
-
onClick: viewChanges
|
|
37
|
-
}, t('View_changes')), !isPublished && /*#__PURE__*/React.createElement(Button, {
|
|
38
|
-
color: "success",
|
|
39
|
-
onClick: publishRevision
|
|
40
|
-
}, t('Publish')));
|
|
41
|
-
};
|
|
42
|
-
export default withTranslation('sdoc-editor')(RevisionOperations);
|
package/dist/utils/date-utils.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
var DateUtils = /*#__PURE__*/function () {
|
|
4
|
-
function DateUtils() {
|
|
5
|
-
_classCallCheck(this, DateUtils);
|
|
6
|
-
}
|
|
7
|
-
_createClass(DateUtils, null, [{
|
|
8
|
-
key: "format",
|
|
9
|
-
value:
|
|
10
|
-
/**
|
|
11
|
-
* return the formatted date with target format.
|
|
12
|
-
* @param {string|date object} date
|
|
13
|
-
* @param {string} format
|
|
14
|
-
* @returns formatted date
|
|
15
|
-
*/
|
|
16
|
-
function format(date, _format) {
|
|
17
|
-
var dateObject = this.getValidDate(date);
|
|
18
|
-
if (!dateObject) {
|
|
19
|
-
return '';
|
|
20
|
-
}
|
|
21
|
-
var upperCaseFormat = _format && _format.toUpperCase();
|
|
22
|
-
var year = dateObject.getFullYear();
|
|
23
|
-
var month = dateObject.getMonth() + 1;
|
|
24
|
-
var day = dateObject.getDate();
|
|
25
|
-
var displayMonth = month < 10 ? "0".concat(month) : month;
|
|
26
|
-
var displayDay = day < 10 ? "0".concat(day) : day;
|
|
27
|
-
switch (upperCaseFormat) {
|
|
28
|
-
case 'YYYY-MM-DD HH:MM:SS':
|
|
29
|
-
{
|
|
30
|
-
var hours = dateObject.getHours();
|
|
31
|
-
var minutes = dateObject.getMinutes();
|
|
32
|
-
var seconds = dateObject.getSeconds();
|
|
33
|
-
var disPlayHours = hours < 10 ? "0".concat(hours) : hours;
|
|
34
|
-
var disPlayMinutes = minutes < 10 ? "0".concat(minutes) : minutes;
|
|
35
|
-
var disPlaySeconds = seconds < 10 ? "0".concat(seconds) : seconds;
|
|
36
|
-
return "".concat(year, "-").concat(displayMonth, "-").concat(displayDay, " ").concat(disPlayHours, ":").concat(disPlayMinutes, ":").concat(disPlaySeconds);
|
|
37
|
-
}
|
|
38
|
-
case 'YYYY-MM-DD HH:MM':
|
|
39
|
-
{
|
|
40
|
-
var _hours = dateObject.getHours();
|
|
41
|
-
var _minutes = dateObject.getMinutes();
|
|
42
|
-
var _disPlayHours = _hours < 10 ? "0".concat(_hours) : _hours;
|
|
43
|
-
var _disPlayMinutes = _minutes < 10 ? "0".concat(_minutes) : _minutes;
|
|
44
|
-
return "".concat(year, "-").concat(displayMonth, "-").concat(displayDay, " ").concat(_disPlayHours, ":").concat(_disPlayMinutes);
|
|
45
|
-
}
|
|
46
|
-
default:
|
|
47
|
-
{
|
|
48
|
-
return "".concat(year, "-").concat(displayMonth, "-").concat(displayDay);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}, {
|
|
53
|
-
key: "isValidDateObject",
|
|
54
|
-
value: function isValidDateObject(dateObject) {
|
|
55
|
-
return dateObject instanceof Date && !isNaN(dateObject.getTime());
|
|
56
|
-
}
|
|
57
|
-
}, {
|
|
58
|
-
key: "getValidDate",
|
|
59
|
-
value: function getValidDate(date) {
|
|
60
|
-
if (!date) {
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
var isDateTypeString = typeof date === 'string';
|
|
64
|
-
var dateString = date;
|
|
65
|
-
var dateObject = date;
|
|
66
|
-
if (isDateTypeString) {
|
|
67
|
-
if (dateString.split(' ').length > 1 || dateString.includes('T')) {
|
|
68
|
-
dateObject = new Date(date);
|
|
69
|
-
} else {
|
|
70
|
-
// given date is without time precision
|
|
71
|
-
dateString = "".concat(date, " 00:00:00");
|
|
72
|
-
dateObject = new Date(dateString);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
if (this.isValidDateObject(dateObject)) return dateObject;
|
|
76
|
-
if (!isDateTypeString) return null;
|
|
77
|
-
|
|
78
|
-
//ios phone and safari browser not support use '2021-09-10 12:30', support '2021/09/10 12:30'
|
|
79
|
-
dateObject = new Date(dateString.replace(/-/g, '/'));
|
|
80
|
-
if (this.isValidDateObject(dateObject)) return dateObject;
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
}]);
|
|
84
|
-
return DateUtils;
|
|
85
|
-
}();
|
|
86
|
-
export default DateUtils;
|