@seafile/sdoc-editor 0.2.17 → 0.2.18

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 (66) hide show
  1. package/dist/api/seafile-api.js +36 -2
  2. package/dist/assets/css/simple-editor.css +0 -32
  3. package/dist/assets/images/revision-avatar.png +0 -0
  4. package/dist/basic-sdk/comment/components/comment-all-participants/index.css +83 -0
  5. package/dist/basic-sdk/comment/components/comment-all-participants/index.js +56 -0
  6. package/dist/basic-sdk/comment/components/comment-all-participants/participant-avatar.js +35 -0
  7. package/dist/basic-sdk/comment/{comment → components}/comment-editor.js +18 -36
  8. package/dist/basic-sdk/comment/components/comment-input/comment-participant-item.js +47 -0
  9. package/dist/basic-sdk/comment/components/comment-input/index.css +45 -0
  10. package/dist/basic-sdk/comment/components/comment-input/index.js +295 -0
  11. package/dist/basic-sdk/comment/{comment → components}/comment-item-content.js +7 -2
  12. package/dist/basic-sdk/comment/{comment → components}/comment-item-reply.js +6 -1
  13. package/dist/basic-sdk/comment/{comment → components}/comment-item-wrapper.js +3 -1
  14. package/dist/basic-sdk/comment/components/comment-participants-editor/index.css +132 -0
  15. package/dist/basic-sdk/comment/components/comment-participants-editor/index.js +67 -0
  16. package/dist/basic-sdk/comment/components/comment-participants-editor/searched-collaborators.js +53 -0
  17. package/dist/basic-sdk/comment/components/comment-participants-editor/selected-participants.js +39 -0
  18. package/dist/basic-sdk/comment/{comment → components}/global-comment-header.js +5 -6
  19. package/dist/basic-sdk/comment/{comment → components}/style.css +8 -1
  20. package/dist/basic-sdk/comment/constants/index.js +11 -0
  21. package/dist/basic-sdk/comment/hooks/use-comment-list.js +1 -1
  22. package/dist/basic-sdk/comment/hooks/use-participants.js +90 -0
  23. package/dist/basic-sdk/comment/index.js +3 -2
  24. package/dist/basic-sdk/comment/utils/index.js +206 -0
  25. package/dist/basic-sdk/editor/sdoc-editor.js +3 -2
  26. package/dist/components/doc-info/index.css +53 -0
  27. package/dist/components/doc-info/index.js +11 -2
  28. package/dist/components/modal-portal/index.js +36 -0
  29. package/dist/constants/index.js +4 -1
  30. package/dist/constants/key-codes.js +102 -0
  31. package/dist/constants/transfer-types.js +3 -0
  32. package/dist/context.js +38 -8
  33. package/dist/hooks/index.js +3 -0
  34. package/dist/hooks/use-collaborators.js +44 -0
  35. package/dist/layout/layout.js +10 -27
  36. package/dist/model/index.js +2 -1
  37. package/dist/model/user.js +12 -0
  38. package/dist/pages/simple-editor.js +1 -1
  39. package/dist/utils/get-event-transfer.js +73 -0
  40. package/dist/utils/hotkey.js +25 -0
  41. package/dist/utils/index.js +58 -1
  42. package/package.json +1 -1
  43. package/public/locales/cs/sdoc-editor.json +6 -1
  44. package/public/locales/de/sdoc-editor.json +6 -1
  45. package/public/locales/en/sdoc-editor.json +3 -1
  46. package/public/locales/es/sdoc-editor.json +6 -1
  47. package/public/locales/fr/sdoc-editor.json +6 -1
  48. package/public/locales/it/sdoc-editor.json +6 -1
  49. package/public/locales/ru/sdoc-editor.json +6 -1
  50. package/public/locales/zh_CN/sdoc-editor.json +3 -1
  51. package/public/media/sdoc-editor-font/iconfont.eot +0 -0
  52. package/public/media/sdoc-editor-font/iconfont.svg +4 -0
  53. package/public/media/sdoc-editor-font/iconfont.ttf +0 -0
  54. package/public/media/sdoc-editor-font/iconfont.woff +0 -0
  55. package/public/media/sdoc-editor-font/iconfont.woff2 +0 -0
  56. package/public/media/sdoc-editor-font.css +14 -6
  57. /package/dist/basic-sdk/comment/{comment → components}/comment-delete-shadow.js +0 -0
  58. /package/dist/basic-sdk/comment/{comment → components}/comment-item-resolved-reply.js +0 -0
  59. /package/dist/basic-sdk/comment/{comment → components}/comment-list.css +0 -0
  60. /package/dist/basic-sdk/comment/{comment → components}/comment-list.js +0 -0
  61. /package/dist/basic-sdk/comment/{comment → components}/editor-comment.js +0 -0
  62. /package/dist/basic-sdk/comment/{comment → components}/elements-comment-count/element-comment-count.js +0 -0
  63. /package/dist/basic-sdk/comment/{comment → components}/elements-comment-count/index.css +0 -0
  64. /package/dist/basic-sdk/comment/{comment → components}/elements-comment-count/index.js +0 -0
  65. /package/dist/basic-sdk/comment/{comment → components}/global-comment.js +0 -0
  66. /package/dist/basic-sdk/comment/{comment → components}/index.js +0 -0
@@ -11,8 +11,6 @@ var SeafileAPI = /*#__PURE__*/function () {
11
11
  };
12
12
  this.deleteSdocOtherRevision = function (docUuid, revisionId) {
13
13
  var url = 'api/v2.1/seadoc/delete-revision/' + docUuid + '/' + revisionId + '/';
14
- // let formData = new FormData();
15
- // formData.append('revision_id', revisionId);
16
14
  return _this.req.delete(url);
17
15
  };
18
16
  this.req = axios.create({
@@ -153,6 +151,42 @@ var SeafileAPI = /*#__PURE__*/function () {
153
151
  var url = 'api/v2.1/seadoc/query-copy-move-progress/' + docUuid + '/?&doc_uuid=' + docUuid + '&task_id=' + taskId;
154
152
  return this.req.get(url);
155
153
  }
154
+
155
+ // participants
156
+ }, {
157
+ key: "listParticipants",
158
+ value: function listParticipants(docUuid) {
159
+ var url = 'api/v2.1/seadoc/participants/' + docUuid + '/';
160
+ return this.req.get(url);
161
+ }
162
+ }, {
163
+ key: "addParticipants",
164
+ value: function addParticipants(docUuid, emails) {
165
+ var url = 'api/v2.1/seadoc/participants/' + docUuid + '/';
166
+ var params = {
167
+ emails: emails
168
+ };
169
+ return this._sendPostRequest(url, params);
170
+ }
171
+ }, {
172
+ key: "deleteParticipants",
173
+ value: function deleteParticipants(docUuid, email) {
174
+ var url = 'api/v2.1/seadoc/participant/' + docUuid + '/';
175
+ var params = {
176
+ email: email
177
+ };
178
+ return this.req.delete(url, {
179
+ data: params
180
+ });
181
+ }
182
+
183
+ // related-users
184
+ }, {
185
+ key: "listRelatedUsers",
186
+ value: function listRelatedUsers(docUuid) {
187
+ var url = 'api/v2.1/seadoc/related-users/' + docUuid + '/';
188
+ return this.req.get(url);
189
+ }
156
190
  }]);
157
191
  return SeafileAPI;
158
192
  }();
@@ -1,35 +1,3 @@
1
- .sdoc-editor-page-header .doc-info {
2
- display: flex;
3
- align-items: center;
4
- }
5
-
6
- .sdoc-editor-page-header .doc-info .doc-name {
7
- font-size: 18px;
8
- font-weight: 700;
9
- color: #212529;
10
- }
11
-
12
- .sdoc-editor-page-header .doc-info .doc-icon {
13
- margin-left: 0.5rem;
14
- color: #999;
15
- cursor: pointer;
16
- font-size: 14px;
17
- line-height: 1;
18
- }
19
-
20
- .sdoc-editor-page-header .doc-info .doc-icon:hover {
21
- margin-left: 0.5rem;
22
- color: #333;
23
- }
24
-
25
- .sdoc-editor-page-header .doc-info .sdoc-link {
26
- font-size: 14px;
27
- }
28
-
29
- .sdoc-editor-page-header .doc-state {
30
- font-size: 0.8125rem;
31
- }
32
-
33
1
  /* reset common css */
34
2
  .sdoc-editor-page-wrapper .dropdown-item,
35
3
  .sdoc-context-menu .dropdown-item {
@@ -0,0 +1,83 @@
1
+ .global-comments-popover .comments-panel-body__header .comments-participants-container {
2
+ width: fit-content;
3
+ max-width: 100%;
4
+ height: 42px;
5
+ padding-top: 6px;
6
+ display: flex;
7
+ align-items: center;
8
+ position: relative;
9
+ }
10
+
11
+ .global-comments-popover .comments-panel-body__header .comments-participants-editor-target {
12
+ position: absolute;
13
+ left: -1px;
14
+ top: 0;
15
+ z-index: -1;
16
+ height: 100%;
17
+ width: 1px;
18
+ background-color: transparent;
19
+ }
20
+
21
+ .global-comments-popover .comments-panel-body__header .comment-participant-avatar {
22
+ border-radius: 50%;
23
+ vertical-align: middle;
24
+ margin-right: -0.5rem;
25
+ }
26
+
27
+ .global-comments-popover .comments-panel-body__header .comment-participant-avatar img {
28
+ width: 28px;
29
+ height: 28px;
30
+ border: 2px solid #fff;
31
+ line-height: 2rem;
32
+ border-radius: 50%;
33
+ display: inline-block;
34
+ background: #ced4da no-repeat center/cover;
35
+ position: relative;
36
+ text-align: center;
37
+ color: #868e96;
38
+ font-weight: 600;
39
+ vertical-align: bottom;
40
+ font-size: .875rem;
41
+ user-select: none;
42
+ }
43
+
44
+ .global-comments-popover .comments-panel-body__header .add-comments-participants {
45
+ position: relative;
46
+ bottom: -3px;
47
+ cursor: pointer;
48
+ margin-right: -0.5rem;
49
+ height: 20px;
50
+ width: 20px;
51
+ background-color: #fff;
52
+ border: 1px solid #fff;
53
+ border-radius: 50%;
54
+ display: flex;
55
+ align-items: center;
56
+ justify-content: center;
57
+ }
58
+
59
+ .global-comments-popover .add-comments-participants .sdocfont {
60
+ font-size: 16px;
61
+ color: #ff8000;
62
+ border-radius: 50%;
63
+ }
64
+
65
+ .global-comments-popover .comment-participants-more {
66
+ position: absolute;
67
+ top: 0;
68
+ left: 0;
69
+ width: 28px;
70
+ height: 28px;
71
+ border-radius: 50%;
72
+ display: flex;
73
+ align-items: center;
74
+ justify-content: center;
75
+ overflow: hidden;
76
+ background-color: rgba(0, 0, 0, .6);
77
+ border: 2px solid #fff;
78
+ }
79
+
80
+ .global-comments-popover .comment-participants-more .sdocfont {
81
+ color: #fff;
82
+ font-size: 12px;
83
+ }
@@ -0,0 +1,56 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
3
+ import { useTranslation } from 'react-i18next';
4
+ import { useParticipantsContext } from '../../hooks/use-participants';
5
+ import ParticipantAvatar from './participant-avatar';
6
+ import Tooltip from '../../../../components/tooltip';
7
+ import CommentParticipantsEditor from '../comment-participants-editor';
8
+ import './index.css';
9
+ var CommentAllParticipants = function CommentAllParticipants() {
10
+ var popoverRef = useRef();
11
+ var _useParticipantsConte = useParticipantsContext(),
12
+ participants = _useParticipantsConte.participants;
13
+ var _useTranslation = useTranslation(),
14
+ t = _useTranslation.t;
15
+ var addParticipantId = 'sdoc-add-participants';
16
+ var commentsParticipantsId = 'sdoc-comments-participants';
17
+ var _useState = useState(false),
18
+ _useState2 = _slicedToArray(_useState, 2),
19
+ isDidMount = _useState2[0],
20
+ setDidMount = _useState2[1];
21
+ useEffect(function () {
22
+ setDidMount(true);
23
+ }, []);
24
+ var toggle = useCallback(function () {
25
+ popoverRef.current && popoverRef.current.toggle();
26
+
27
+ // eslint-disable-next-line react-hooks/exhaustive-deps
28
+ }, [popoverRef.current]);
29
+ var participantsCount = participants.length;
30
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
31
+ className: "comments-participants-container"
32
+ }, /*#__PURE__*/React.createElement("div", {
33
+ className: "comments-participants-editor-target",
34
+ id: commentsParticipantsId
35
+ }), participants.slice(0, 14).map(function (participant, index) {
36
+ var username = participant.username;
37
+ return /*#__PURE__*/React.createElement(ParticipantAvatar, {
38
+ key: username,
39
+ participant: participant,
40
+ index: index,
41
+ showMore: participantsCount > 13 && index === 13
42
+ });
43
+ }), /*#__PURE__*/React.createElement("div", {
44
+ className: "add-comments-participants",
45
+ id: addParticipantId,
46
+ onClick: toggle
47
+ }, /*#__PURE__*/React.createElement("i", {
48
+ className: "sdocfont sdoc-add"
49
+ })), isDidMount && /*#__PURE__*/React.createElement(Tooltip, {
50
+ target: addParticipantId
51
+ }, t('Add_participants'))), isDidMount && /*#__PURE__*/React.createElement(CommentParticipantsEditor, {
52
+ target: commentsParticipantsId,
53
+ ref: popoverRef
54
+ }));
55
+ };
56
+ export default CommentAllParticipants;
@@ -0,0 +1,35 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import React, { useState, useEffect } from 'react';
3
+ import classnames from 'classnames';
4
+ import Tooltip from '../../../../components/tooltip';
5
+ var ParticipantAvatar = function ParticipantAvatar(_ref) {
6
+ var participant = _ref.participant,
7
+ index = _ref.index,
8
+ showMore = _ref.showMore;
9
+ var _useState = useState(false),
10
+ _useState2 = _slicedToArray(_useState, 2),
11
+ showTooltip = _useState2[0],
12
+ setShowTooltip = _useState2[1];
13
+ useEffect(function () {
14
+ setShowTooltip(true);
15
+ }, []);
16
+ var name = participant.name,
17
+ avatar_url = participant.avatar_url;
18
+ var id = "comment-participant-avatar-".concat(index, "-").concat(Math.floor(Math.random() * 1000));
19
+ return /*#__PURE__*/React.createElement("div", {
20
+ className: classnames('comment-participant-avatar', {
21
+ 'position-relative': showMore
22
+ }),
23
+ id: id
24
+ }, /*#__PURE__*/React.createElement("img", {
25
+ src: avatar_url,
26
+ alt: ""
27
+ }), showTooltip && /*#__PURE__*/React.createElement(Tooltip, {
28
+ target: id
29
+ }, name), showMore && /*#__PURE__*/React.createElement("div", {
30
+ className: "comment-participants-more"
31
+ }, /*#__PURE__*/React.createElement("i", {
32
+ className: "sdocfont sdoc-more"
33
+ })));
34
+ };
35
+ export default ParticipantAvatar;
@@ -6,6 +6,8 @@ import { useScrollContext } from '../../hooks/use-scroll-context';
6
6
  import context from '../../../context';
7
7
  import EventBus from '../../utils/event-bus';
8
8
  import { INTERNAL_EVENT } from '../../constants';
9
+ import { useParticipantsContext } from '../hooks/use-participants';
10
+ import CommentInput from './comment-input';
9
11
  var getSubmitTip = function getSubmitTip(type, content) {
10
12
  if (content) return 'Save';
11
13
  return type === 'comment' ? 'Comment' : 'Reply';
@@ -19,25 +21,13 @@ var CommentEditor = function CommentEditor(_ref) {
19
21
  updateContent = _ref.updateContent,
20
22
  setIsEditing = _ref.setIsEditing,
21
23
  hiddenComment = _ref.hiddenComment;
22
- var commentRef = useRef();
24
+ var commentInputRef = useRef();
23
25
  var commentWrapperRef = useRef();
24
26
  var _useTranslation = useTranslation(),
25
27
  t = _useTranslation.t;
26
28
  var scrollRef = useScrollContext();
27
-
28
- // onMount: comment content
29
- useEffect(function () {
30
- if (!content) return;
31
- commentRef.current.textContent = content;
32
- // eslint-disable-next-line react-hooks/exhaustive-deps
33
- }, []);
34
-
35
- // onMount: set input focus
36
- useEffect(function () {
37
- if (type !== 'comment') return;
38
- commentRef.current && commentRef.current.focus();
39
- // eslint-disable-next-line react-hooks/exhaustive-deps
40
- }, []);
29
+ var _useParticipantsConte = useParticipantsContext(),
30
+ addParticipants = _useParticipantsConte.addParticipants;
41
31
 
42
32
  // onMount: set scrollLeft
43
33
  useEffect(function () {
@@ -70,29 +60,20 @@ var CommentEditor = function CommentEditor(_ref) {
70
60
  }, [content, insertContent, updateContent]);
71
61
  var onSubmit = useCallback(function (event) {
72
62
  event && event.stopPropagation();
73
- var value = commentRef.current.textContent;
63
+ var value = commentInputRef.current.getValue();
74
64
  updateValue(value);
75
- commentRef.current.textContent = '';
76
- }, [updateValue]);
65
+ var userInfo = context.getUserInfo();
66
+ addParticipants(userInfo.username);
67
+ commentInputRef.current.setValue('');
68
+ }, [updateValue, addParticipants, commentInputRef]);
77
69
  var onCancel = useCallback(function (event) {
78
70
  event.stopPropagation();
79
- commentRef.current.textContent = '';
71
+ commentInputRef.current.setValue('');
80
72
  setIsEditing && setIsEditing(false);
81
73
  hiddenComment && hiddenComment(false);
82
74
 
83
75
  // eslint-disable-next-line react-hooks/exhaustive-deps
84
76
  }, [setIsEditing]);
85
- var onKeyDown = useCallback(function (event) {
86
- // enter
87
- if (event.keyCode === 13) {
88
- event.preventDefault();
89
- onSubmit();
90
- }
91
- if (event.keyCode === 27) {
92
- event.preventDefault();
93
- onCancel();
94
- }
95
- }, [onCancel, onSubmit]);
96
77
  var submitTip = useMemo(function () {
97
78
  return getSubmitTip(type, content);
98
79
  }, [content, type]);
@@ -111,12 +92,13 @@ var CommentEditor = function CommentEditor(_ref) {
111
92
  width: "100%"
112
93
  })), /*#__PURE__*/React.createElement("div", {
113
94
  className: "comment-editor-user-name"
114
- }, userInfo.name)), /*#__PURE__*/React.createElement("div", {
115
- ref: commentRef,
116
- contentEditable: "true",
117
- className: "comment-editor",
118
- placeholder: t(placeholder),
119
- onKeyDown: onKeyDown
95
+ }, userInfo.name)), /*#__PURE__*/React.createElement(CommentInput, {
96
+ ref: commentInputRef,
97
+ type: type,
98
+ placeholder: placeholder,
99
+ content: content,
100
+ onCancel: onCancel,
101
+ onSubmit: onSubmit
120
102
  }), /*#__PURE__*/React.createElement("div", {
121
103
  className: "comment-operations"
122
104
  }, /*#__PURE__*/React.createElement(Button, {
@@ -0,0 +1,47 @@
1
+ import React, { useCallback, useEffect, useRef } from 'react';
2
+ import { eventStopPropagation } from '../../../utils/mouse-event';
3
+ var CommentParticipantItem = function CommentParticipantItem(_ref) {
4
+ var participant = _ref.participant,
5
+ setScrollTop = _ref.setScrollTop,
6
+ onSelectParticipant = _ref.onSelectParticipant,
7
+ participantIndex = _ref.participantIndex,
8
+ activeParticipantIndex = _ref.activeParticipantIndex;
9
+ var ref = useRef(null);
10
+ var oldValueRef = useRef({});
11
+ useEffect(function () {
12
+ oldValueRef.current.participantIndex = participantIndex;
13
+ oldValueRef.current.activeParticipantIndex = activeParticipantIndex;
14
+ // eslint-disable-next-line react-hooks/exhaustive-deps
15
+ }, []);
16
+ useEffect(function () {
17
+ if (activeParticipantIndex === participantIndex && activeParticipantIndex !== oldValueRef.current.activeParticipantIndex) {
18
+ var offsetHeight = ref.current.offsetHeight;
19
+ var offsetTop = ref.current.offsetTop;
20
+ if (activeParticipantIndex > oldValueRef.current.activeParticipantIndex) {
21
+ setScrollTop(offsetTop, offsetHeight, 'down');
22
+ } else {
23
+ setScrollTop(offsetTop, offsetHeight, 'up');
24
+ }
25
+ }
26
+ oldValueRef.current.activeParticipantIndex = activeParticipantIndex;
27
+ }, [setScrollTop, participantIndex, activeParticipantIndex, ref, oldValueRef]);
28
+ var selectParticipant = useCallback(function (event) {
29
+ eventStopPropagation(event);
30
+ onSelectParticipant(participant);
31
+ }, [participant, onSelectParticipant]);
32
+ var active = participantIndex === activeParticipantIndex;
33
+ return /*#__PURE__*/React.createElement("div", {
34
+ className: "comment-participant-item ".concat(active ? 'active' : ''),
35
+ ref: ref,
36
+ onClick: selectParticipant
37
+ }, /*#__PURE__*/React.createElement("div", {
38
+ className: "comment-participant-container"
39
+ }, /*#__PURE__*/React.createElement("img", {
40
+ className: "comment-participant-avatar",
41
+ alt: participant.name,
42
+ src: participant.avatar_url
43
+ }), /*#__PURE__*/React.createElement("div", {
44
+ className: "comment-participant-name"
45
+ }, participant.name)));
46
+ };
47
+ export default CommentParticipantItem;
@@ -0,0 +1,45 @@
1
+ .sdoc-comment-caret-list {
2
+ background: #fff;
3
+ position: absolute;
4
+ padding: 10px 0;
5
+ max-height: 200px;
6
+ overflow: auto;
7
+ min-width: 150px;
8
+ /* higher than row expand */
9
+ z-index: 1049;
10
+ border-radius: 5px;
11
+ border: 1px solid #ededed;
12
+ max-width: 200px;
13
+ }
14
+
15
+ .sdoc-comment-caret-list .comment-participant-item {
16
+ padding: 5px 0;
17
+ }
18
+
19
+ .sdoc-comment-caret-list .comment-participant-item.active,
20
+ .sdoc-comment-caret-list .comment-participant-item:hover {
21
+ background: #f5f5f5;
22
+ cursor: pointer;
23
+ }
24
+
25
+ .sdoc-comment-caret-list .comment-participant-item .comment-participant-container {
26
+ display: flex;
27
+ align-items: center;
28
+ padding: 0 8px;
29
+ }
30
+
31
+ .sdoc-comment-caret-list .comment-participant-item .comment-participant-avatar {
32
+ width: 16px;
33
+ height: 16px;
34
+ border-radius: 50%;
35
+ vertical-align: middle;
36
+ }
37
+
38
+ .sdoc-comment-caret-list .comment-participant-item .comment-participant-name {
39
+ margin-left: 4px;
40
+ font-size: 14px;
41
+ flex: 1;
42
+ overflow: hidden;
43
+ text-overflow: ellipsis;
44
+ white-space: nowrap;
45
+ }