@seafile/sdoc-editor 0.2.28 → 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.
- package/dist/api/seafile-api.js +26 -0
- package/dist/basic-sdk/comment/hooks/use-comment-mount.js +7 -0
- package/dist/basic-sdk/editor/sdoc-editor.js +2 -3
- package/dist/basic-sdk/extension/constants/element-type.js +0 -1
- package/dist/basic-sdk/extension/constants/index.js +2 -2
- package/dist/basic-sdk/extension/plugins/html/helper.js +0 -1
- package/dist/basic-sdk/extension/plugins/html/rules/list.js +3 -3
- package/dist/basic-sdk/extension/plugins/list/helpers.js +0 -1
- package/dist/basic-sdk/extension/plugins/list/model.js +3 -3
- package/dist/basic-sdk/extension/plugins/list/plugin/insert-fragment-list.js +4 -4
- package/dist/basic-sdk/extension/plugins/list/plugin/normalize-list.js +2 -13
- package/dist/basic-sdk/extension/plugins/list/transforms/insert-list-item.js +13 -11
- package/dist/basic-sdk/extension/plugins/list/transforms/move-list-items.js +2 -2
- package/dist/basic-sdk/extension/plugins/list/transforms/normalize-list-item.js +7 -7
- package/dist/basic-sdk/extension/plugins/list/transforms/toggle-list.js +16 -19
- package/dist/basic-sdk/extension/plugins/list/transforms/unwrap-list.js +5 -13
- package/dist/basic-sdk/extension/plugins/table/helpers.js +0 -1
- package/dist/basic-sdk/extension/render/custom-element.js +14 -14
- package/dist/basic-sdk/socket/socket-client.js +7 -0
- package/dist/basic-sdk/socket/socket-manager.js +3 -0
- package/dist/components/doc-operations/index.js +2 -1
- package/dist/components/doc-operations/notifications-operation/index.css +14 -0
- package/dist/components/doc-operations/notifications-operation/index.js +170 -0
- package/dist/components/doc-operations/notifications-operation/notifications-dialog/index.css +97 -0
- package/dist/components/doc-operations/notifications-operation/notifications-dialog/index.js +107 -0
- package/dist/components/doc-operations/notifications-operation/notifications-dialog/notification.js +25 -0
- package/dist/components/doc-operations/notifications-operation/notifications-popover/index.css +173 -0
- package/dist/components/doc-operations/notifications-operation/notifications-popover/index.js +78 -0
- package/dist/components/doc-operations/notifications-operation/notifications-popover/notification.js +54 -0
- package/dist/components/tip-dialog/index.css +17 -0
- package/dist/components/tip-dialog/index.js +7 -0
- package/dist/constants/index.js +2 -1
- package/dist/context.js +26 -0
- package/dist/layout/index.js +2 -1
- package/dist/layout/other.js +8 -0
- package/dist/model/index.js +2 -1
- package/dist/model/notification.js +21 -0
- package/dist/pages/simple-editor.js +3 -3
- package/dist/utils/index.js +2 -1
- package/dist/utils/notification-utils.js +46 -0
- package/package.json +1 -1
- package/public/locales/en/sdoc-editor.json +12 -1
- package/public/locales/zh_CN/sdoc-editor.json +3 -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 +4 -0
package/dist/components/doc-operations/notifications-operation/notifications-popover/notification.js
ADDED
|
@@ -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;
|
|
@@ -29,3 +29,20 @@
|
|
|
29
29
|
.sdoc-tip-dialog .sdoc-tip-dialog-custom-container .sdoc-tip-operation-btn {
|
|
30
30
|
min-width: 140px;
|
|
31
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
|
+
}
|
|
@@ -69,6 +69,13 @@ var TipDialog = function TipDialog(_ref) {
|
|
|
69
69
|
onClick: refreshPage
|
|
70
70
|
}, t('Refresh'))));
|
|
71
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
|
+
}
|
|
72
79
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ModalHeader, {
|
|
73
80
|
toggle: NOT_CLOSE_DIALOG_TIP_TYPE.includes(tipType) ? undefined : closeDialog
|
|
74
81
|
}, t(TIP_TITLE[tipType])), /*#__PURE__*/React.createElement(ModalBody, {
|
package/dist/constants/index.js
CHANGED
|
@@ -12,7 +12,8 @@ export var EXTERNAL_EVENT = {
|
|
|
12
12
|
DOCUMENT_REPLACED: 'document_replaced',
|
|
13
13
|
DOCUMENT_REPLACED_ERROR: 'document_replaced_error',
|
|
14
14
|
REMOVE_DOCUMENT: 'remove_document',
|
|
15
|
-
REMOVE_DOCUMENT_ERROR: 'remove_document_error'
|
|
15
|
+
REMOVE_DOCUMENT_ERROR: 'remove_document_error',
|
|
16
|
+
NEW_NOTIFICATION: 'new_notification'
|
|
16
17
|
};
|
|
17
18
|
export var TIP_TYPE = {
|
|
18
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
|
}();
|
package/dist/layout/index.js
CHANGED
package/dist/model/index.js
CHANGED
|
@@ -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;
|
|
@@ -9,7 +9,7 @@ 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';
|
|
12
|
+
import { useDocument, CollaboratorsProvider } from '../hooks';
|
|
13
13
|
import { resetWebTitle } from '../utils';
|
|
14
14
|
import '../assets/css/simple-editor.css';
|
|
15
15
|
var SimpleEditor = function SimpleEditor(_ref) {
|
|
@@ -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);
|
package/dist/utils/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import LocalStorage from './local-storage-utils';
|
|
|
3
3
|
import context from '../context';
|
|
4
4
|
import getEventTransfer from './get-event-transfer';
|
|
5
5
|
import * as Hotkey from './hotkey';
|
|
6
|
+
import { createNotify } from './notification-utils';
|
|
6
7
|
export var getDirPath = function getDirPath(path) {
|
|
7
8
|
var dir = path.slice(0, path.lastIndexOf('/'));
|
|
8
9
|
if (dir === '') {
|
|
@@ -109,4 +110,4 @@ export var getSelectionCoords = function getSelectionCoords() {
|
|
|
109
110
|
y: y
|
|
110
111
|
};
|
|
111
112
|
};
|
|
112
|
-
export { DateUtils, LocalStorage, getEventTransfer, Hotkey };
|
|
113
|
+
export { DateUtils, LocalStorage, getEventTransfer, Hotkey, createNotify };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import relativeTime from 'dayjs/plugin/relativeTime';
|
|
3
|
+
import context from '../context';
|
|
4
|
+
dayjs.extend(relativeTime);
|
|
5
|
+
var PERMISSION_GRANTED = 'granted';
|
|
6
|
+
var notify = function notify($title, $options) {
|
|
7
|
+
var notification = new Notification($title, $options);
|
|
8
|
+
|
|
9
|
+
//auto clear notifications
|
|
10
|
+
var timer = setTimeout(notification.close.bind(notification), 5000);
|
|
11
|
+
notification.onshow = function (event) {
|
|
12
|
+
var _context$getSetting = context.getSetting('mediaUrl'),
|
|
13
|
+
mediaUrl = _context$getSetting.mediaUrl;
|
|
14
|
+
var newAudioElement = document.createElement('audio');
|
|
15
|
+
newAudioElement.setAttribute('src', "".concat(mediaUrl, "audio/classic.mp3"));
|
|
16
|
+
newAudioElement.setAttribute('autoplay', 'autoplay');
|
|
17
|
+
newAudioElement.setAttribute('id', 'seatable-audio');
|
|
18
|
+
var audioElement = document.getElementById('seatable-audio');
|
|
19
|
+
if (audioElement) {
|
|
20
|
+
document.body.removeChild(audioElement);
|
|
21
|
+
}
|
|
22
|
+
document.body.appendChild(newAudioElement);
|
|
23
|
+
};
|
|
24
|
+
notification.onclose = function () {
|
|
25
|
+
clearTimeout(timer);
|
|
26
|
+
};
|
|
27
|
+
notification.onclick = function () {
|
|
28
|
+
notification.close();
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
var createNotify = function createNotify(title, options) {
|
|
32
|
+
// Let's check if the browser supports notifications
|
|
33
|
+
if (!('Notification' in window)) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
if (Notification.permission === PERMISSION_GRANTED) {
|
|
37
|
+
notify(title, options);
|
|
38
|
+
} else {
|
|
39
|
+
Notification.requestPermission(function (res) {
|
|
40
|
+
if (res === PERMISSION_GRANTED) {
|
|
41
|
+
notify(title, options);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
export { createNotify };
|
package/package.json
CHANGED
|
@@ -407,5 +407,16 @@
|
|
|
407
407
|
"Add_option": "Create a new tag",
|
|
408
408
|
"Find_an_option": "Search tags",
|
|
409
409
|
"Copy_link_of_section": "Copy link of section",
|
|
410
|
-
"revision": "revision"
|
|
410
|
+
"revision": "revision",
|
|
411
|
+
"xxx_added_a_new_comment": "{{author}} added a new comment",
|
|
412
|
+
"xxx_added_a_reply": "{{author}} added a reply",
|
|
413
|
+
"Added_a_new_comment": "Added a new comment",
|
|
414
|
+
"Added_a_reply": "Added a reply",
|
|
415
|
+
"All_notifications": "All notifications",
|
|
416
|
+
"No_notification": "No notification",
|
|
417
|
+
"Mark_all_as_read": "Mark all as read",
|
|
418
|
+
"Delete_all_notifications": "Delete all notifications",
|
|
419
|
+
"View_all_notifications": "View all notifications",
|
|
420
|
+
"Notification": "Notification",
|
|
421
|
+
"Update_date": "Update date"
|
|
411
422
|
}
|
|
Binary file
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
/>
|
|
15
15
|
<missing-glyph />
|
|
16
16
|
|
|
17
|
+
<glyph glyph-name="sdoc-notification" unicode="" d="M931.2 80c-3.2 80-44.8 150.4-105.6 198.4V496c0 124.8-89.6 233.6-208 256v6.4C617.6 816 572.8 864 515.2 864S409.6 816 409.6 758.4v-6.4c-118.4-25.6-208-131.2-208-256v-217.6C137.6 233.6 99.2 160 96 80h835.2zM492.8-96h25.6c67.2 0 124.8 51.2 134.4 118.4H377.6c9.6-67.2 64-118.4 134.4-118.4h-19.2z" horiz-adv-x="1024" />
|
|
18
|
+
|
|
17
19
|
<glyph glyph-name="sdoc-add" unicode="" d="M512-128C227.2-128 0 99.2 0 384S227.2 896 512 896s512-227.2 512-512-227.2-512-512-512z m-51.2 563.2H291.2c-19.2 0-35.2-12.8-35.2-35.2v-35.2c0-19.2 12.8-35.2 35.2-35.2h169.6V160c0-19.2 12.8-35.2 35.2-35.2h35.2c19.2 0 35.2 12.8 35.2 35.2v169.6H736c19.2 0 35.2 12.8 35.2 35.2v35.2c0 19.2-12.8 35.2-35.2 35.2h-169.6V604.8c0 19.2-12.8 35.2-35.2 35.2h-35.2c-19.2 0-35.2-12.8-35.2-35.2v-169.6z" horiz-adv-x="1024" />
|
|
18
20
|
|
|
19
21
|
<glyph glyph-name="sdoc-tag" unicode="" d="M521.353986 860.33363l466.979644-466.979644c22.389435-22.389435 35.183398-51.175851 35.183398-83.160758s-12.793963-60.771324-35.183398-83.160759l-323.047562-319.849071c-22.389435-22.389435-51.175851-35.183398-79.962268-35.183398-31.984907 0-60.771324 12.793963-83.160758 35.183398L35.183398 374.163042c-25.587926 25.587926-38.381889 60.771324-31.984907 95.954721l31.984907 291.062655c6.396981 54.374342 47.977361 95.954721 102.351703 102.351703l291.062654 31.984907c31.984907 3.198491 67.168305-9.595472 92.756231-35.183398zM444.590209 767.577399L159.924536 735.592492l-31.984908-281.467182L578.926819-0.060372l316.65058 313.45209L444.590209 767.577399z m12.793963-127.939628c57.572833-57.572833 57.572833-147.130573 0-204.703406-25.587926-25.587926-63.969814-41.580379-102.351703-41.580379-38.381889 0-73.565286 12.793963-102.351703 41.580379-57.572833 57.572833-57.572833 147.130573 0 204.703406 57.572833 57.572833 150.329063 57.572833 204.703406 0z m-102.351703-70.366796c-6.396981 0-15.992454-3.198491-22.389435-9.595472-12.793963-12.793963-12.793963-31.984907 0-44.77887 12.793963-12.793963 31.984907-12.793963 44.77887 0 12.793963 12.793963 12.793963 31.984907 0 44.77887-6.396981 6.396981-12.793963 9.595472-22.389435 9.595472z" horiz-adv-x="1024" />
|
|
Binary file
|
|
Binary file
|
|
Binary file
|