@seafile/sdoc-editor 0.1.65 → 0.1.67-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.
@@ -35,6 +35,12 @@ 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
+ }
38
44
  }]);
39
45
  return SeafileAPI;
40
46
  }();
@@ -3,17 +3,3 @@
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,6 +5,7 @@
5
5
 
6
6
  .sdoc-editor-page-header .doc-info .doc-name {
7
7
  font-size: 18px;
8
+ font-weight: 700;
8
9
  color: #212529;
9
10
  }
10
11
 
@@ -24,3 +25,7 @@
24
25
  .sdoc-editor-page-header .doc-info .sdoc-link {
25
26
  font-size: 14px;
26
27
  }
28
+
29
+ .sdoc-editor-page-header .doc-state {
30
+ font-size: 0.8125rem;
31
+ }
@@ -92,7 +92,7 @@ var CommentItem = function CommentItem(_ref) {
92
92
  onClick: onDeleteToggle
93
93
  }, t('Delete')))))), !isActive && /*#__PURE__*/React.createElement("span", {
94
94
  className: "comment-time"
95
- }, dayjs(comment.updated_at).format('MM:DD HH:mm'))), /*#__PURE__*/React.createElement("div", {
95
+ }, dayjs(comment.updated_at).format('MM-DD HH:mm'))), /*#__PURE__*/React.createElement("div", {
96
96
  className: "comment-content"
97
97
  }, isEditing && /*#__PURE__*/React.createElement(CommentEditor, {
98
98
  comment: comment,
@@ -21,6 +21,6 @@ var DeleteCommentDialog = function DeleteCommentDialog(_ref) {
21
21
  }, t('Cancel')), /*#__PURE__*/React.createElement(Button, {
22
22
  color: "primary",
23
23
  onClick: deleteComment
24
- }, t('Submit'))));
24
+ }, t('Confirm'))));
25
25
  };
26
26
  export default withTranslation('sdoc-editor')(DeleteCommentDialog);
@@ -132,6 +132,10 @@
132
132
  padding: 8px;
133
133
  }
134
134
 
135
+ .sdoc-comment-container .comment-list-container .comment-editor:focus-visible {
136
+ outline: none;
137
+ }
138
+
135
139
  .sdoc-comment-container .comment-list-container .comment-editor:focus {
136
140
  border: 1px solid rgba(0, 0, 0, .12);
137
141
  }
@@ -13,6 +13,10 @@ export var useSelectionPosition = function useSelectionPosition() {
13
13
  return Element.isElement(n) && Editor.isBlock(editor, n);
14
14
  }
15
15
  });
16
+ if (!node) return {
17
+ x: 0,
18
+ y: 0
19
+ };
16
20
  var domNode = ReactEditor.toDOMNode(editor, node[0]);
17
21
  var rect = domNode.getBoundingClientRect();
18
22
  return rect;
@@ -74,4 +74,18 @@ export var decorateOperation = function decorateOperation(editor, operation) {
74
74
  }
75
75
  }
76
76
  return newOperation;
77
+ };
78
+ export var replacePastedDataId = function replacePastedDataId(pastedData) {
79
+ // If children is malformed, return a list of correct child nodes
80
+ if (!Array.isArray(pastedData)) return [{
81
+ id: slugid.nice(),
82
+ text: ''
83
+ }];
84
+ return pastedData.map(function (item) {
85
+ item.id = slugid.nice();
86
+ if (item.children) {
87
+ item.children = replacePastedDataId(item.children);
88
+ }
89
+ return item;
90
+ });
77
91
  };
@@ -1,4 +1,14 @@
1
- import { decorateOperation } from './helpers';
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import { decorateOperation, replacePastedDataId } from './helpers';
3
+ var clipboardFormatKey = 'x-slate-fragment';
4
+ var catchSlateFragment = /data-slate-fragment="(.+?)"/m;
5
+ var getSlateFragmentAttribute = function getSlateFragmentAttribute(dataTransfer) {
6
+ var htmlData = dataTransfer.getData('text/html');
7
+ var _ref = htmlData.match(catchSlateFragment) || [],
8
+ _ref2 = _slicedToArray(_ref, 2),
9
+ fragment = _ref2[1];
10
+ return fragment;
11
+ };
2
12
  var withNodeId = function withNodeId(editor) {
3
13
  var apply = editor.apply;
4
14
  var newEditor = editor;
@@ -6,6 +16,18 @@ var withNodeId = function withNodeId(editor) {
6
16
  var newOp = decorateOperation(newEditor, op);
7
17
  apply(newOp);
8
18
  };
19
+
20
+ // rewrite insert fragment data
21
+ newEditor.insertFragmentData = function (data) {
22
+ var fragment = data.getData("application/".concat(clipboardFormatKey)) || getSlateFragmentAttribute(data);
23
+ if (fragment) {
24
+ var decoded = decodeURIComponent(window.atob(fragment));
25
+ var parsed = JSON.parse(decoded);
26
+ var newData = replacePastedDataId(parsed);
27
+ newEditor.insertFragment(newData);
28
+ return true;
29
+ }
30
+ };
9
31
  return newEditor;
10
32
  };
11
33
  export default withNodeId;
@@ -1,61 +1,57 @@
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';
1
+ import React, { useCallback } from 'react';
6
2
  import TipMessage from '../tip-message';
7
3
  import { withTranslation } from 'react-i18next';
8
4
  import context from '../../context';
9
5
  import { EventBus } from '../../basic-sdk';
10
6
  import { EXTERNAL_EVENT } from '../../constants';
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;
7
+ import { DateUtils } from '../../utils';
8
+ var DocInfo = function DocInfo(_ref) {
9
+ var t = _ref.t,
10
+ isStarred = _ref.isStarred;
11
+ var onInternalLinkClick = useCallback(function () {
12
+ var eventBus = EventBus.getInstance();
13
+ eventBus.dispatch(EXTERNAL_EVENT.INTERNAL_LINK_CLICK);
14
+ }, []);
15
+ var toggleStar = useCallback(function () {
16
+ var eventBus = EventBus.getInstance();
17
+ eventBus.dispatch(EXTERNAL_EVENT.TOGGLE_STAR);
18
+ }, []);
19
+ var isSdocRevision = context.getSetting('isSdocRevision');
20
+ var docName = context.getSetting('docName');
21
+ var _context$getSettings = context.getSettings(),
22
+ isShowInternalLink = _context$getSettings.isShowInternalLink,
23
+ isStarIconShown = _context$getSettings.isStarIconShown;
24
+ var docInfo = /*#__PURE__*/React.createElement(React.Fragment, null, isStarIconShown && /*#__PURE__*/React.createElement("button", {
25
+ className: "doc-icon sdocfont ".concat(isStarred ? 'sdoc-starred' : 'sdoc-unstarred', " border-0 p-0 bg-transparent"),
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);
30
42
  }
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);
43
+ var revisionCreatedAt = context.getSetting('revisionCreatedAt');
44
+ var oldDocName = context.getSetting('originFilename');
45
+ return /*#__PURE__*/React.createElement("div", {
46
+ className: "doc-info d-flex flex-column"
47
+ }, /*#__PURE__*/React.createElement("div", {
48
+ className: "doc-name-container d-flex align-items-center justify-content-start w-100"
49
+ }, /*#__PURE__*/React.createElement("div", {
50
+ className: "doc-name"
51
+ }, oldDocName), docInfo), /*#__PURE__*/React.createElement("div", {
52
+ className: "doc-state"
53
+ }, /*#__PURE__*/React.createElement("span", {
54
+ className: "mr-2"
55
+ }, t('Revision')), /*#__PURE__*/React.createElement("span", null, DateUtils.format(revisionCreatedAt, 'YYYY-MM-DD HH:MM'))));
56
+ };
61
57
  export default withTranslation('sdoc-editor')(DocInfo);
@@ -0,0 +1,21 @@
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,81 +1,17 @@
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';
7
- import CollaboratorsOperation from './collaborators-operation';
8
- import context from '../../context';
1
+ import React from 'react';
9
2
  import { withTranslation } from 'react-i18next';
3
+ import RevisionOperations from './revision-operations';
4
+ import HistoryOperation from './history-operation';
5
+ import CollaboratorsOperation from './collaborators-operation';
6
+ import MoreOperations from './more-operations';
10
7
  import './style.css';
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);
8
+ var DocOperations = function DocOperations() {
9
+ return /*#__PURE__*/React.createElement("div", {
10
+ className: "doc-ops"
11
+ }, /*#__PURE__*/React.createElement(RevisionOperations, null), /*#__PURE__*/React.createElement("span", {
12
+ className: "op-item"
13
+ }, /*#__PURE__*/React.createElement("i", {
14
+ className: "sdocfont sdoc-share"
15
+ })), /*#__PURE__*/React.createElement(HistoryOperation, null), /*#__PURE__*/React.createElement(CollaboratorsOperation, null), /*#__PURE__*/React.createElement(MoreOperations, null));
16
+ };
81
17
  export default withTranslation('sdoc-editor')(DocOperations);
@@ -0,0 +1,44 @@
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);
@@ -0,0 +1,42 @@
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/context.js CHANGED
@@ -101,6 +101,8 @@ var Context = /*#__PURE__*/function () {
101
101
  avatar_url: avatarURL
102
102
  };
103
103
  }
104
+
105
+ // comments
104
106
  }, {
105
107
  key: "listComments",
106
108
  value: function listComments() {
@@ -121,6 +123,14 @@ var Context = /*#__PURE__*/function () {
121
123
  value: function updateComment(commentId, newComment) {
122
124
  return this.sdocServerApi.updateComment(commentId, newComment);
123
125
  }
126
+
127
+ // revision
128
+ }, {
129
+ key: "publishSdocRevision",
130
+ value: function publishSdocRevision() {
131
+ var docUuid = this.getSetting('docUuid');
132
+ return this.api.sdocPublishRevision(docUuid);
133
+ }
124
134
  }]);
125
135
  return Context;
126
136
  }();
@@ -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("div", {
31
- className: "p-1",
30
+ return /*#__PURE__*/React.createElement("span", {
31
+ className: "d-inline-block p-1",
32
32
  style: {
33
33
  backgroundColor: style.background_color,
34
34
  width: 'fit-content',
@@ -0,0 +1,86 @@
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;
@@ -1,3 +1,4 @@
1
+ import DateUtils from './date-utils';
1
2
  export var getDirPath = function getDirPath(path) {
2
3
  var dir = path.slice(0, path.lastIndexOf('/'));
3
4
  if (dir === '') {
@@ -22,4 +23,20 @@ export var generateDefaultDocContent = function generateDefaultDocContent() {
22
23
  export var getImageFileNameWithTimestamp = function getImageFileNameWithTimestamp() {
23
24
  var d = Date.now();
24
25
  return 'image-' + d.toString() + '.png';
25
- };
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.1.65",
3
+ "version": "0.1.67beta",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",
@@ -250,5 +250,9 @@
250
250
  "Auto_wrap": "Auto wrap",
251
251
  "Add_comment": "Add comment",
252
252
  "Delete_comment": "Delete comment",
253
- "Are_you_sure_to_delete_this_comment": "Are you sure to delete this comment?"
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
258
  }
@@ -250,5 +250,9 @@
250
250
  "Auto_wrap": "自动换行",
251
251
  "Add_comment": "添加评论",
252
252
  "Delete_comment": "删除评论",
253
- "Are_you_sure_to_delete_this_comment": "你确定要删除这个评论吗?"
253
+ "Are_you_sure_to_delete_this_comment": "你确定要删除这个评论吗?",
254
+ "Confirm": "确定",
255
+ "View_changes": "查看改动",
256
+ "Revision": "修订",
257
+ "Error": "错误"
254
258
  }