@seafile/sdoc-editor 0.2.27 → 0.2.29-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.
Files changed (68) hide show
  1. package/dist/api/seafile-api.js +26 -0
  2. package/dist/assets/images/content-replaced.png +0 -0
  3. package/dist/basic-sdk/comment/hooks/use-comment-mount.js +7 -0
  4. package/dist/basic-sdk/editor/sdoc-editor.js +2 -3
  5. package/dist/basic-sdk/extension/constants/element-type.js +3 -2
  6. package/dist/basic-sdk/extension/constants/index.js +2 -2
  7. package/dist/basic-sdk/extension/plugins/html/helper.js +17 -16
  8. package/dist/basic-sdk/extension/plugins/html/rules/blockquote.js +0 -1
  9. package/dist/basic-sdk/extension/plugins/html/rules/check-list.js +0 -2
  10. package/dist/basic-sdk/extension/plugins/html/rules/code-block.js +0 -10
  11. package/dist/basic-sdk/extension/plugins/html/rules/header.js +0 -1
  12. package/dist/basic-sdk/extension/plugins/html/rules/image.js +0 -1
  13. package/dist/basic-sdk/extension/plugins/html/rules/link.js +0 -2
  14. package/dist/basic-sdk/extension/plugins/html/rules/list.js +3 -9
  15. package/dist/basic-sdk/extension/plugins/html/rules/paragraph.js +0 -1
  16. package/dist/basic-sdk/extension/plugins/html/rules/table.js +0 -3
  17. package/dist/basic-sdk/extension/plugins/html/rules/text.js +0 -7
  18. package/dist/basic-sdk/extension/plugins/list/helpers.js +0 -1
  19. package/dist/basic-sdk/extension/plugins/list/model.js +3 -3
  20. package/dist/basic-sdk/extension/plugins/list/plugin/insert-fragment-list.js +4 -4
  21. package/dist/basic-sdk/extension/plugins/list/plugin/normalize-list.js +2 -13
  22. package/dist/basic-sdk/extension/plugins/list/transforms/insert-list-item.js +13 -11
  23. package/dist/basic-sdk/extension/plugins/list/transforms/move-list-items.js +2 -2
  24. package/dist/basic-sdk/extension/plugins/list/transforms/normalize-list-item.js +7 -7
  25. package/dist/basic-sdk/extension/plugins/list/transforms/toggle-list.js +16 -19
  26. package/dist/basic-sdk/extension/plugins/list/transforms/unwrap-list.js +5 -13
  27. package/dist/basic-sdk/extension/plugins/table/helpers.js +0 -1
  28. package/dist/basic-sdk/extension/render/custom-element.js +14 -14
  29. package/dist/basic-sdk/socket/socket-client.js +7 -0
  30. package/dist/basic-sdk/socket/socket-manager.js +3 -0
  31. package/dist/components/doc-operations/index.js +2 -1
  32. package/dist/components/doc-operations/notifications-operation/index.css +14 -0
  33. package/dist/components/doc-operations/notifications-operation/index.js +170 -0
  34. package/dist/components/doc-operations/notifications-operation/notifications-dialog/index.css +97 -0
  35. package/dist/components/doc-operations/notifications-operation/notifications-dialog/index.js +107 -0
  36. package/dist/components/doc-operations/notifications-operation/notifications-dialog/notification.js +25 -0
  37. package/dist/components/doc-operations/notifications-operation/notifications-popover/index.css +173 -0
  38. package/dist/components/doc-operations/notifications-operation/notifications-popover/index.js +78 -0
  39. package/dist/components/doc-operations/notifications-operation/notifications-popover/notification.js +54 -0
  40. package/dist/components/doc-operations/revision-operations/more-revision-operations/index.js +1 -2
  41. package/dist/components/doc-operations/tag-operation/tag-popover/index.css +1 -0
  42. package/dist/components/tip-dialog/index.css +44 -0
  43. package/dist/components/tip-dialog/index.js +51 -18
  44. package/dist/constants/index.js +2 -3
  45. package/dist/context.js +26 -0
  46. package/dist/layout/index.js +2 -1
  47. package/dist/layout/other.js +8 -0
  48. package/dist/model/index.js +2 -1
  49. package/dist/model/notification.js +21 -0
  50. package/dist/pages/published-revision-viewer.js +2 -2
  51. package/dist/pages/simple-editor.js +6 -6
  52. package/dist/utils/index.js +3 -33
  53. package/dist/utils/notification-utils.js +46 -0
  54. package/package.json +1 -1
  55. package/public/locales/cs/sdoc-editor.json +1 -1
  56. package/public/locales/de/sdoc-editor.json +1 -1
  57. package/public/locales/en/sdoc-editor.json +13 -3
  58. package/public/locales/es/sdoc-editor.json +1 -1
  59. package/public/locales/fr/sdoc-editor.json +1 -1
  60. package/public/locales/it/sdoc-editor.json +1 -1
  61. package/public/locales/ru/sdoc-editor.json +1 -1
  62. package/public/locales/zh_CN/sdoc-editor.json +4 -2
  63. package/public/media/sdoc-editor-font/iconfont.eot +0 -0
  64. package/public/media/sdoc-editor-font/iconfont.svg +2 -0
  65. package/public/media/sdoc-editor-font/iconfont.ttf +0 -0
  66. package/public/media/sdoc-editor-font/iconfont.woff +0 -0
  67. package/public/media/sdoc-editor-font/iconfont.woff2 +0 -0
  68. package/public/media/sdoc-editor-font.css +4 -0
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ var Notification = function Notification(_ref) {
4
+ var notification = _ref.notification,
5
+ markNotificationRead = _ref.markNotificationRead;
6
+ var _useTranslation = useTranslation(),
7
+ t = _useTranslation.t;
8
+ return /*#__PURE__*/React.createElement("tr", {
9
+ onClick: function onClick() {
10
+ return markNotificationRead(notification.id);
11
+ }
12
+ }, /*#__PURE__*/React.createElement("td", {
13
+ className: "pl-3"
14
+ }, /*#__PURE__*/React.createElement("img", {
15
+ style: {
16
+ borderRadius: '50%'
17
+ },
18
+ src: notification.userAvatarURL,
19
+ alt: "",
20
+ width: "30"
21
+ })), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("div", {
22
+ className: "sdoc-notification-detail"
23
+ }, notification.msgType === 'comment' ? t('Added_a_new_comment') : t('Added_a_reply'))), /*#__PURE__*/React.createElement("td", null, notification.time));
24
+ };
25
+ export default Notification;
@@ -0,0 +1,173 @@
1
+ .sdoc-notifications-popover {
2
+ max-width: 322px;
3
+ }
4
+
5
+ .sdoc-notifications-popover .popover-inner {
6
+ width: 320px;
7
+ height: 386px;
8
+ overflow: hidden;
9
+ }
10
+
11
+ .sdoc-notifications-popover.sdoc-notifications-empty-popover .popover-inner {
12
+ height: 126px;
13
+ }
14
+
15
+ .sdoc-notifications-popover .sdoc-notification-container {
16
+ width: 100%;
17
+ height: 100%;
18
+ overflow: hidden;
19
+ display: flex;
20
+ flex-direction: column;
21
+ align-items: center;
22
+ justify-content: center;
23
+ }
24
+
25
+ .sdoc-notifications-popover .sdoc-notification-header {
26
+ width: 100%;
27
+ height: 50px;
28
+ border-bottom: 1px solid #ededed;
29
+ font-size: 16px;
30
+ font-weight: 600;
31
+ display: flex;
32
+ align-items: center;
33
+ justify-content: space-between;
34
+ }
35
+
36
+ .sdoc-notifications-popover .sdoc-notification-header .sdoc-notification-header-title {
37
+ flex: 1;
38
+ overflow: hidden;
39
+ text-align: center;
40
+ overflow: hidden;
41
+ text-overflow: ellipsis;
42
+ white-space: nowrap;
43
+ }
44
+
45
+ .sdoc-notifications-popover .sdoc-notification-header .sdoc-notification-header-close-btn {
46
+ width: 24px;
47
+ height: 24px;
48
+ display: flex;
49
+ align-items: center;
50
+ justify-content: center;
51
+ margin-right: 14px;
52
+ color: #000;
53
+ opacity: .5;
54
+ font-weight: 700;
55
+ }
56
+
57
+ .sdoc-notifications-popover .sdoc-notification-header .sdoc-notification-header-close-btn:hover {
58
+ cursor: pointer;
59
+ opacity: .75;
60
+ }
61
+
62
+ .sdoc-notifications-popover .sdoc-notification-body {
63
+ width: 100%;
64
+ flex: 1;
65
+ overflow: hidden;
66
+ display: flex;
67
+ flex-direction: column;
68
+ align-items: center;
69
+ justify-content: center;
70
+ }
71
+
72
+ .sdoc-notifications-popover .sdoc-mark-notifications {
73
+ border-bottom: 1px solid #ededed;
74
+ height: 36px;
75
+ width: 100%;
76
+ display: flex;
77
+ align-items: center;
78
+ justify-content: flex-end;
79
+ padding-right: 1rem;
80
+ }
81
+
82
+ .sdoc-notifications-popover .sdoc-mark-notifications .sdoc-mark-notifications-tip {
83
+ color: #b4b4b4;
84
+ max-width: 100%;
85
+ overflow: hidden;
86
+ text-overflow: ellipsis;
87
+ white-space: nowrap;
88
+ }
89
+
90
+ .sdoc-notifications-popover .sdoc-mark-notifications .sdoc-mark-notifications-tip:hover {
91
+ cursor: pointer;
92
+ text-decoration: underline;
93
+ }
94
+
95
+ .sdoc-notifications-popover .sdoc-notification-list-container {
96
+ flex: 1;
97
+ overflow: hidden;
98
+ width: 100%;
99
+ }
100
+
101
+ .sdoc-notifications-popover .sdoc-notification-list-content {
102
+ height: 100%;
103
+ overflow: scroll;
104
+ }
105
+
106
+ .sdoc-notifications-popover .sdoc-notification-list-content .sdoc-notification-item {
107
+ width: 100%;
108
+ padding: 14px 16px 14px 10px;
109
+ border-bottom: 1px solid #ededed;
110
+ position: relative;
111
+ cursor: pointer;
112
+ }
113
+
114
+ .sdoc-notifications-popover .sdoc-notification-item .sdoc-notification-item-header {
115
+ display: flex;
116
+ align-items: center;
117
+ }
118
+
119
+ .sdoc-notifications-popover .sdoc-notification-item .sdoc-notification-point {
120
+ display: inline-block;
121
+ width: 8px;
122
+ height: 8px;
123
+ border-radius: 50%;
124
+ background: red;
125
+ margin-right: 12px;
126
+ position: absolute;
127
+ }
128
+
129
+ .sdoc-notifications-popover .sdoc-notification-item .sdoc-notification-header-info {
130
+ display: flex;
131
+ justify-content: space-between;
132
+ flex: 1 1;
133
+ margin-left: 20px;
134
+ width: calc(100% - 20px);
135
+ }
136
+
137
+ .sdoc-notifications-popover .sdoc-notification-item .sdoc-notification-user-detail {
138
+ display: flex;
139
+ width: 65%;
140
+ }
141
+
142
+ .sdoc-notifications-popover .sdoc-notification-item .sdoc-notification-user-name {
143
+ text-overflow: ellipsis;
144
+ overflow: hidden;
145
+ white-space: nowrap;
146
+ font-weight: 500;
147
+ margin-left: 8px;
148
+ }
149
+
150
+ .sdoc-notifications-popover .sdoc-notification-item .sdoc-notification-time {
151
+ color: #b4b4b4;
152
+ text-overflow: ellipsis;
153
+ overflow: hidden;
154
+ white-space: nowrap;
155
+ font-size: 13px;
156
+ }
157
+
158
+ .sdoc-notifications-popover .sdoc-notification-item .sdoc-notification-content-wrapper {
159
+ font-size: 13px;
160
+ margin-left: 3rem;
161
+ display: flex;
162
+ }
163
+
164
+ .sdoc-notifications-popover .sdoc-notification-footer {
165
+ width: 100%;
166
+ height: 40px;
167
+ display: flex;
168
+ align-items: center;
169
+ justify-content: center;
170
+ background: #f9f9f9;
171
+ cursor: pointer;
172
+ border-top: 1px solid #ededed;
173
+ }
@@ -0,0 +1,78 @@
1
+ import React, { useRef, useCallback } from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import { UncontrolledPopover } from 'reactstrap';
4
+ import classnames from 'classnames';
5
+ import Notification from './notification';
6
+ import './index.css';
7
+ var NotificationPopover = function NotificationPopover(_ref) {
8
+ var target = _ref.target,
9
+ notifications = _ref.notifications,
10
+ markAllNotificationsRead = _ref.markAllNotificationsRead,
11
+ listNotifications = _ref.listNotifications,
12
+ markNotificationRead = _ref.markNotificationRead,
13
+ onToggleNotificationsDialog = _ref.onToggleNotificationsDialog;
14
+ var _useTranslation = useTranslation(),
15
+ t = _useTranslation.t;
16
+ var ref = useRef(null);
17
+ var notificationContainerRef = useRef(null);
18
+ var notificationContentRef = useRef(null);
19
+ var onNotificationListToggle = useCallback(function () {
20
+ ref.current && ref.current.toggle();
21
+ }, [ref]);
22
+ var onScroll = useCallback(function () {
23
+ if (notificationContainerRef.current.offsetHeight + notificationContainerRef.current.scrollTop + 1 >= notificationContentRef.current.offsetHeight) {
24
+ listNotifications && listNotifications();
25
+ }
26
+ }, [listNotifications, notificationContainerRef, notificationContentRef]);
27
+ var toggleNotificationsDialog = useCallback(function () {
28
+ onToggleNotificationsDialog();
29
+ onNotificationListToggle();
30
+ }, [onToggleNotificationsDialog, onNotificationListToggle]);
31
+ return /*#__PURE__*/React.createElement(UncontrolledPopover, {
32
+ ref: ref,
33
+ target: target,
34
+ placement: "bottom-end",
35
+ popperClassName: classnames('sdoc-notifications-popover', {
36
+ 'sdoc-notifications-empty-popover': notifications.length === 0
37
+ }),
38
+ trigger: "legacy",
39
+ hideArrow: true,
40
+ fade: false,
41
+ security: "fixed"
42
+ }, /*#__PURE__*/React.createElement("div", {
43
+ className: "sdoc-notification-container"
44
+ }, /*#__PURE__*/React.createElement("div", {
45
+ className: "sdoc-notification-header"
46
+ }, /*#__PURE__*/React.createElement("div", {
47
+ className: "sdoc-notification-header-title"
48
+ }, t('Notification')), /*#__PURE__*/React.createElement("div", {
49
+ className: "sdoc-notification-header-close-btn"
50
+ }, /*#__PURE__*/React.createElement("i", {
51
+ className: "sdocfont sdoc-sm-close",
52
+ onClick: onNotificationListToggle
53
+ }))), /*#__PURE__*/React.createElement("div", {
54
+ className: "sdoc-notification-body"
55
+ }, /*#__PURE__*/React.createElement("div", {
56
+ className: "sdoc-mark-notifications"
57
+ }, /*#__PURE__*/React.createElement("div", {
58
+ className: "sdoc-mark-notifications-tip",
59
+ onClick: markAllNotificationsRead
60
+ }, t('Mark_all_as_read'))), /*#__PURE__*/React.createElement("div", {
61
+ className: "sdoc-notification-list-container",
62
+ ref: notificationContainerRef,
63
+ onScroll: onScroll
64
+ }, /*#__PURE__*/React.createElement("div", {
65
+ className: "sdoc-notification-list-content",
66
+ ref: notificationContentRef
67
+ }, Array.isArray(notifications) && notifications.map(function (n) {
68
+ return /*#__PURE__*/React.createElement(Notification, {
69
+ key: n.id,
70
+ notification: n,
71
+ markNotificationRead: markNotificationRead
72
+ });
73
+ })))), /*#__PURE__*/React.createElement("div", {
74
+ className: "sdoc-notification-footer",
75
+ onClick: toggleNotificationsDialog
76
+ }, t('View_all_notifications'))));
77
+ };
78
+ export default NotificationPopover;
@@ -0,0 +1,54 @@
1
+ import React, { useCallback } from 'react';
2
+ import { textToHtml } from '../../../../basic-sdk/comment/utils';
3
+ var Notification = function Notification(_ref) {
4
+ var notification = _ref.notification,
5
+ markNotificationRead = _ref.markNotificationRead;
6
+ var onMarkNotificationRead = useCallback(function () {
7
+ markNotificationRead(notification.id);
8
+ }, [notification, markNotificationRead]);
9
+ if (!notification) return null;
10
+ var seen = notification.seen,
11
+ username = notification.username,
12
+ userAvatarURL = notification.userAvatarURL,
13
+ time = notification.time,
14
+ detail = notification.detail,
15
+ msgType = notification.msgType;
16
+ return /*#__PURE__*/React.createElement("div", {
17
+ className: "sdoc-notification-item",
18
+ onClick: onMarkNotificationRead
19
+ }, /*#__PURE__*/React.createElement("div", {
20
+ className: "sdoc-notification-item-header"
21
+ }, !seen && /*#__PURE__*/React.createElement("span", {
22
+ className: "sdoc-notification-point"
23
+ }), /*#__PURE__*/React.createElement("div", {
24
+ className: "sdoc-notification-header-info"
25
+ }, /*#__PURE__*/React.createElement("div", {
26
+ className: "sdoc-notification-user-detail"
27
+ }, /*#__PURE__*/React.createElement("img", {
28
+ src: userAvatarURL,
29
+ alt: "",
30
+ width: "20",
31
+ height: "20",
32
+ style: {
33
+ borderRadius: '50%'
34
+ }
35
+ }), /*#__PURE__*/React.createElement("span", {
36
+ className: "sdoc-notification-user-name"
37
+ }, username)), /*#__PURE__*/React.createElement("span", {
38
+ className: "sdoc-notification-time"
39
+ }, time))), /*#__PURE__*/React.createElement("div", {
40
+ className: "sdoc-notification-content-wrapper"
41
+ }, msgType === 'comment' ? 'added_a_new_comment' : 'added_a_reply'), /*#__PURE__*/React.createElement("div", {
42
+ className: "sdoc-notification-content-wrapper"
43
+ }, /*#__PURE__*/React.createElement("span", {
44
+ className: "sdoc-notification-content-quotes"
45
+ }, "\""), /*#__PURE__*/React.createElement("div", {
46
+ dangerouslySetInnerHTML: {
47
+ __html: textToHtml(detail)
48
+ },
49
+ className: "sdoc-notification-comment-content"
50
+ }), /*#__PURE__*/React.createElement("span", {
51
+ className: "sdoc-notification-content-quotes"
52
+ }, "\"")));
53
+ };
54
+ export default Notification;
@@ -4,7 +4,6 @@ import { withTranslation } from 'react-i18next';
4
4
  import { Dropdown, DropdownToggle, DropdownMenu, DropdownItem } from 'reactstrap';
5
5
  import context from '../../../../context';
6
6
  import toaster from '../../../toast';
7
- import { REVISION_FIRST_LOAD_KEY, REVISION_FIRST_LOAD_VALUE } from '../../../../constants';
8
7
  import './index.css';
9
8
  var MoreRevisionOperations = function MoreRevisionOperations(_ref) {
10
9
  var t = _ref.t;
@@ -19,7 +18,7 @@ var MoreRevisionOperations = function MoreRevisionOperations(_ref) {
19
18
  context.startRevise().then(function (res) {
20
19
  var repoID = context.getSetting('repoID');
21
20
  var siteRoot = context.getSetting('siteRoot');
22
- var revisionURL = "".concat(siteRoot, "lib/").concat(repoID, "/revisions/").concat(res.data.revision_id, "/?").concat(REVISION_FIRST_LOAD_KEY, "=").concat(REVISION_FIRST_LOAD_VALUE);
21
+ var revisionURL = "".concat(siteRoot, "lib/").concat(repoID, "/revisions/").concat(res.data.revision_id, "/");
23
22
  window.open(revisionURL, '_blank');
24
23
  }).catch(function (error) {
25
24
  toaster.danger(t('Error'));
@@ -41,6 +41,7 @@
41
41
  text-overflow: ellipsis;
42
42
  overflow: hidden;
43
43
  font-size: 13px;
44
+ font-weight: normal;
44
45
  }
45
46
 
46
47
  .sdoc-tag-item .sdoc-tag-added-mark {
@@ -2,3 +2,47 @@
2
2
  background-color: #FF8000;
3
3
  border-color: #FF8000;
4
4
  }
5
+
6
+ .sdoc-tip-dialog .sdoc-tip-dialog-custom-container {
7
+ display: flex;
8
+ flex-direction: column;
9
+ align-items: center;
10
+ padding-top: 46px;
11
+ padding-bottom: 40px;
12
+ }
13
+
14
+ .sdoc-tip-dialog .sdoc-tip-dialog-custom-container .sdoc-tip-img-container {
15
+ display: flex;
16
+ align-items: center;
17
+ justify-content: center;
18
+ width: 140px;
19
+ height: 140px;
20
+ overflow: hidden;
21
+ }
22
+
23
+ .sdoc-tip-dialog .sdoc-tip-dialog-custom-container .sdoc-tip-content {
24
+ width: 100%;
25
+ padding: 10px 16px 64px 16px;
26
+ text-align: center;
27
+ }
28
+
29
+ .sdoc-tip-dialog .sdoc-tip-dialog-custom-container .sdoc-tip-operation-btn {
30
+ min-width: 140px;
31
+ }
32
+
33
+ .sdoc-tip-dialog .sdoc-tip-dialog-custom-container.publishing {
34
+ padding: 2rem;
35
+ height: 180px;
36
+ justify-content: center;
37
+ }
38
+
39
+ .sdoc-tip-dialog .sdoc-tip-dialog-custom-container.publishing .common-loading-tip {
40
+ width: 30px;
41
+ height: 30px;
42
+ border-width: 4px;
43
+ }
44
+
45
+ .sdoc-tip-dialog .sdoc-tip-dialog-custom-container.publishing .sdoc-tip-content {
46
+ margin-top: 8px;
47
+ padding: 0;
48
+ }
@@ -5,6 +5,7 @@ import { Modal, ModalHeader, ModalBody, ModalFooter, Button } from 'reactstrap';
5
5
  import classnames from 'classnames';
6
6
  import { TIP_TYPE, TIP_TITLE, TIP_CONTENT } from '../../constants';
7
7
  import CommonLoading from '../common-loading';
8
+ import ContentReplaced from '../../assets/images/content-replaced.png';
8
9
  import './index.css';
9
10
  var NOT_CLOSE_DIALOG_TIP_TYPE = [TIP_TYPE.HAS_BEEN_REPLACED, TIP_TYPE.HAS_BEEN_PUBLISHED, TIP_TYPE.CHECKING, TIP_TYPE.PUBLISHING];
10
11
  var TipDialog = function TipDialog(_ref) {
@@ -45,6 +46,55 @@ var TipDialog = function TipDialog(_ref) {
45
46
  };
46
47
  }
47
48
  }, [isSubmitting]);
49
+ var refreshPage = useCallback(function () {
50
+ window.location.reload();
51
+ }, []);
52
+ var renderTip = useCallback(function () {
53
+ if (tipType === TIP_TYPE.HAS_BEEN_REPLACED) {
54
+ return /*#__PURE__*/React.createElement("div", {
55
+ className: "sdoc-tip-dialog-custom-container"
56
+ }, /*#__PURE__*/React.createElement("div", {
57
+ className: "sdoc-tip-img-container"
58
+ }, /*#__PURE__*/React.createElement("img", {
59
+ src: ContentReplaced,
60
+ alt: "",
61
+ height: "140"
62
+ })), /*#__PURE__*/React.createElement("div", {
63
+ className: "sdoc-tip-content"
64
+ }, t(TIP_CONTENT[tipType])), /*#__PURE__*/React.createElement("div", {
65
+ className: "sdoc-tip-operations-container"
66
+ }, /*#__PURE__*/React.createElement(Button, {
67
+ color: "primary",
68
+ className: "highlight-bg-color sdoc-tip-operation-btn",
69
+ onClick: refreshPage
70
+ }, t('Refresh'))));
71
+ }
72
+ if (tipType === TIP_TYPE.PUBLISHING) {
73
+ return /*#__PURE__*/React.createElement("div", {
74
+ className: "sdoc-tip-dialog-custom-container publishing"
75
+ }, /*#__PURE__*/React.createElement(CommonLoading, null), /*#__PURE__*/React.createElement("div", {
76
+ className: "sdoc-tip-content"
77
+ }, t(TIP_CONTENT[tipType])));
78
+ }
79
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ModalHeader, {
80
+ toggle: NOT_CLOSE_DIALOG_TIP_TYPE.includes(tipType) ? undefined : closeDialog
81
+ }, t(TIP_TITLE[tipType])), /*#__PURE__*/React.createElement(ModalBody, {
82
+ className: "sdoc-tip-body"
83
+ }, children ? children : /*#__PURE__*/React.createElement(React.Fragment, null, t(TIP_CONTENT[tipType]))), !NOT_CLOSE_DIALOG_TIP_TYPE.includes(tipType) && /*#__PURE__*/React.createElement(ModalFooter, null, /*#__PURE__*/React.createElement(Button, {
84
+ color: "secondary",
85
+ className: "mr-2",
86
+ onClick: closeDialog
87
+ }, t('Cancel')), /*#__PURE__*/React.createElement(Button, {
88
+ color: "primary",
89
+ className: classnames('highlight-bg-color', {
90
+ 'd-flex align-items-center': isSubmitting
91
+ }),
92
+ disabled: isSubmitting,
93
+ onClick: onSubmit
94
+ }, isSubmitting && /*#__PURE__*/React.createElement("span", {
95
+ className: "submit-loading-container mr-2"
96
+ }, /*#__PURE__*/React.createElement(CommonLoading, null)), t('Confirm'))));
97
+ }, [children, closeDialog, isSubmitting, onSubmit, t, tipType, refreshPage]);
48
98
  return /*#__PURE__*/React.createElement(Modal, {
49
99
  isOpen: true,
50
100
  autoFocus: false,
@@ -53,23 +103,6 @@ var TipDialog = function TipDialog(_ref) {
53
103
  toggle: closeDialog,
54
104
  className: classnames('sdoc-tip-dialog', className),
55
105
  contentClassName: "sdoc-tip-modal"
56
- }, /*#__PURE__*/React.createElement(ModalHeader, {
57
- toggle: NOT_CLOSE_DIALOG_TIP_TYPE.includes(tipType) ? undefined : closeDialog
58
- }, t(TIP_TITLE[tipType])), /*#__PURE__*/React.createElement(ModalBody, {
59
- className: "sdoc-tip-body"
60
- }, children ? children : /*#__PURE__*/React.createElement(React.Fragment, null, t(TIP_CONTENT[tipType]))), !NOT_CLOSE_DIALOG_TIP_TYPE.includes(tipType) && /*#__PURE__*/React.createElement(ModalFooter, null, /*#__PURE__*/React.createElement(Button, {
61
- color: "secondary",
62
- className: "mr-2",
63
- onClick: closeDialog
64
- }, t('Cancel')), /*#__PURE__*/React.createElement(Button, {
65
- color: "primary",
66
- className: classnames('highlight-bg-color', {
67
- 'd-flex align-items-center': isSubmitting
68
- }),
69
- disabled: isSubmitting,
70
- onClick: onSubmit
71
- }, isSubmitting && /*#__PURE__*/React.createElement("span", {
72
- className: "submit-loading-container mr-2"
73
- }, /*#__PURE__*/React.createElement(CommonLoading, null)), t('Confirm'))));
106
+ }, renderTip());
74
107
  };
75
108
  export default TipDialog;
@@ -2,8 +2,6 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
2
  var _TIP_TITLE, _TIP_CONTENT;
3
3
  import KeyCodes from './key-codes';
4
4
  import * as TransferTypes from './transfer-types';
5
- export var REVISION_FIRST_LOAD_KEY = 'first-load';
6
- export var REVISION_FIRST_LOAD_VALUE = '1';
7
5
  export var EXTERNAL_EVENT = {
8
6
  INTERNAL_LINK_CLICK: 'internal_link_click',
9
7
  TOGGLE_STAR: 'toggle_star',
@@ -14,7 +12,8 @@ export var EXTERNAL_EVENT = {
14
12
  DOCUMENT_REPLACED: 'document_replaced',
15
13
  DOCUMENT_REPLACED_ERROR: 'document_replaced_error',
16
14
  REMOVE_DOCUMENT: 'remove_document',
17
- REMOVE_DOCUMENT_ERROR: 'remove_document_error'
15
+ REMOVE_DOCUMENT_ERROR: 'remove_document_error',
16
+ NEW_NOTIFICATION: 'new_notification'
18
17
  };
19
18
  export var TIP_TYPE = {
20
19
  DELETE_NO_CHANGES_REVISION: 'delete_no_changes_revision',
package/dist/context.js CHANGED
@@ -344,6 +344,32 @@ var Context = /*#__PURE__*/function () {
344
344
  var docUuid = this.getDocUuid();
345
345
  return this.api.updateRepoTag(docUuid, repoTagId, repoTagName, color);
346
346
  }
347
+
348
+ // comment notification
349
+ }, {
350
+ key: "listNotifications",
351
+ value: function listNotifications(page, perPage) {
352
+ var docUuid = this.getDocUuid();
353
+ return this.api.listNotifications(docUuid, page, perPage);
354
+ }
355
+ }, {
356
+ key: "markAllNotificationsRead",
357
+ value: function markAllNotificationsRead() {
358
+ var docUuid = this.getDocUuid();
359
+ return this.api.markAllNotificationsRead(docUuid);
360
+ }
361
+ }, {
362
+ key: "deleteAllNotifications",
363
+ value: function deleteAllNotifications() {
364
+ var docUuid = this.getDocUuid();
365
+ return this.api.deleteAllNotifications(docUuid);
366
+ }
367
+ }, {
368
+ key: "markNotificationRead",
369
+ value: function markNotificationRead(notificationId) {
370
+ var docUuid = this.getDocUuid();
371
+ return this.api.markNotificationRead(docUuid, notificationId);
372
+ }
347
373
  }]);
348
374
  return Context;
349
375
  }();
@@ -1,6 +1,7 @@
1
1
  import Layout from './layout';
2
2
  import Header from './header';
3
3
  import Content from './content';
4
+ import Other from './other';
4
5
  import './layout.css';
5
- export { Header, Content };
6
+ export { Header, Content, Other };
6
7
  export default Layout;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ var Other = function Other(_ref) {
3
+ var children = _ref.children;
4
+ return /*#__PURE__*/React.createElement("div", {
5
+ className: "h-0 w-0 o-hidden position-relative"
6
+ }, children);
7
+ };
8
+ export default Other;
@@ -1,3 +1,4 @@
1
1
  import Revision from './revision';
2
2
  import User from './user';
3
- export { Revision, User };
3
+ import Notification from './notification';
4
+ export { Revision, User, Notification };
@@ -0,0 +1,21 @@
1
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
2
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
+ import context from '../context';
4
+ import dayjs from 'dayjs';
5
+ var Notification = /*#__PURE__*/_createClass(function Notification(options) {
6
+ _classCallCheck(this, Notification);
7
+ this.id = options.id || '';
8
+ this.username = options.user_name || options.name || '';
9
+ this.userEmail = options.user_email;
10
+ this.userAvatarURL = options.avatar_url;
11
+ this.docUuid = options.doc_uuid || '';
12
+ this.msgType = options.msg_type || '';
13
+ this.detail = options.detail.comment || options.detail.reply || '';
14
+ this.seen = options.seen;
15
+ var createdAt = options.created_at || '';
16
+ var lang = context.getSetting('lang');
17
+ var oldTime = new Date(createdAt).getTime();
18
+ dayjs.locale(lang);
19
+ this.time = dayjs(oldTime).fromNow();
20
+ });
21
+ export default Notification;
@@ -8,7 +8,7 @@ import Layout, { Header, Content } from '../layout';
8
8
  import context from '../context';
9
9
  import ErrorBoundary from './error-boundary';
10
10
  import { PublishedRevisionDiffViewer } from '../basic-sdk';
11
- import { resetWebTitleAndURL } from '../utils';
11
+ import { resetWebTitle } from '../utils';
12
12
  import '../assets/css/simple-editor.css';
13
13
  var PublishedRevisionViewer = function PublishedRevisionViewer() {
14
14
  context.initApi();
@@ -37,7 +37,7 @@ var PublishedRevisionViewer = function PublishedRevisionViewer() {
37
37
 
38
38
  // useMount: reset title
39
39
  useEffect(function () {
40
- resetWebTitleAndURL(t);
40
+ resetWebTitle(t);
41
41
  // eslint-disable-next-line react-hooks/exhaustive-deps
42
42
  }, []);
43
43
  useEffect(function () {
@@ -9,8 +9,8 @@ import context from '../context';
9
9
  import ErrorBoundary from './error-boundary';
10
10
  import { SDocEditor } from '../basic-sdk';
11
11
  import { PublishedRevisionDiffViewer, RevisionDiffViewer } from '../basic-sdk/views';
12
- import { useDocument } from '../hooks';
13
- import { resetWebTitleAndURL } from '../utils';
12
+ import { useDocument, CollaboratorsProvider } from '../hooks';
13
+ import { resetWebTitle } from '../utils';
14
14
  import '../assets/css/simple-editor.css';
15
15
  var SimpleEditor = function SimpleEditor(_ref) {
16
16
  var isStarred = _ref.isStarred,
@@ -37,7 +37,7 @@ var SimpleEditor = function SimpleEditor(_ref) {
37
37
  _useState6 = _slicedToArray(_useState5, 2),
38
38
  changes = _useState6[0],
39
39
  setChanges = _useState6[1];
40
- var initIsPublished = context.getSetting('isPublished');
40
+ var initIsPublished = context.getSetting('isPublished') || false;
41
41
  var _useState7 = useState(initIsPublished),
42
42
  _useState8 = _slicedToArray(_useState7, 2),
43
43
  isPublished = _useState8[0],
@@ -45,7 +45,7 @@ var SimpleEditor = function SimpleEditor(_ref) {
45
45
 
46
46
  // useMount: reset title
47
47
  useEffect(function () {
48
- resetWebTitleAndURL(t);
48
+ resetWebTitle(t);
49
49
  // eslint-disable-next-line react-hooks/exhaustive-deps
50
50
  }, []);
51
51
  var setDiffChanges = useCallback(function (diff) {
@@ -110,7 +110,7 @@ var SimpleEditor = function SimpleEditor(_ref) {
110
110
  className: "error-tip"
111
111
  }, t(errorMessage)));
112
112
  }
113
- return /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement(Layout, null, /*#__PURE__*/React.createElement(Header, null, /*#__PURE__*/React.createElement(DocInfo, {
113
+ return /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement(CollaboratorsProvider, null, /*#__PURE__*/React.createElement(Layout, null, /*#__PURE__*/React.createElement(Header, null, /*#__PURE__*/React.createElement(DocInfo, {
114
114
  isStarred: isStarred,
115
115
  isDraft: isDraft,
116
116
  isPublished: isPublished,
@@ -133,6 +133,6 @@ var SimpleEditor = function SimpleEditor(_ref) {
133
133
  }), !isPublished && isShowChanges && /*#__PURE__*/React.createElement(RevisionDiffViewer, {
134
134
  revisionContent: revisionContent,
135
135
  didMountCallback: setDiffChanges
136
- }))));
136
+ })))));
137
137
  };
138
138
  export default withTranslation('sdoc-editor')(SimpleEditor);