@seafile/comment-editor 0.0.1-alpha.1 → 0.0.1-alpha.10
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/basic-sdk/assets/css/layout.css +1 -45
- package/dist/basic-sdk/comment/utils.js +39 -0
- package/dist/basic-sdk/context.js +2 -1
- package/dist/basic-sdk/editor/comment-editor.css +138 -0
- package/dist/basic-sdk/{comment/components → editor}/comment-editor.js +34 -26
- package/dist/basic-sdk/extension/plugins/image/helpers.js +1 -1
- package/dist/basic-sdk/extension/plugins/image/use-copy-image.js +1 -1
- package/dist/basic-sdk/extension/plugins/image/use-upload-image.js +2 -1
- package/dist/basic-sdk/extension/plugins/text-style/menu/index.js +1 -2
- package/dist/basic-sdk/hooks/use-comment.js +17 -178
- package/dist/basic-sdk/index.js +3 -10
- package/dist/index.js +0 -12
- package/dist/pages/seafile-comment-editor.js +25 -14
- package/package.json +1 -1
- package/dist/assets/css/plugin-editor.css +0 -7
- package/dist/assets/css/simple-viewer.css +0 -6
- package/dist/basic-sdk/comment/components/comment-all-participants/index.css +0 -83
- package/dist/basic-sdk/comment/components/comment-all-participants/index.js +0 -67
- package/dist/basic-sdk/comment/components/comment-all-participants/participant-avatar.js +0 -43
- package/dist/basic-sdk/comment/components/comment-context-menu/index.css +0 -16
- package/dist/basic-sdk/comment/components/comment-context-menu/index.js +0 -43
- package/dist/basic-sdk/comment/components/comment-context-menu/menu-item.js +0 -57
- package/dist/basic-sdk/comment/components/comment-delete-popover.js +0 -80
- package/dist/basic-sdk/comment/components/comment-item-collapse-wrapper.js +0 -160
- package/dist/basic-sdk/comment/components/comment-item-content.js +0 -154
- package/dist/basic-sdk/comment/components/comment-item-reply.js +0 -124
- package/dist/basic-sdk/comment/components/comment-item-resolved-reply.js +0 -38
- package/dist/basic-sdk/comment/components/comment-item-wrapper.js +0 -364
- package/dist/basic-sdk/comment/components/comment-list.css +0 -422
- package/dist/basic-sdk/comment/components/comment-list.js +0 -216
- package/dist/basic-sdk/comment/components/comment-operation/index.css +0 -26
- package/dist/basic-sdk/comment/components/comment-operation/index.js +0 -31
- package/dist/basic-sdk/comment/components/comment-participants-editor/index.css +0 -132
- package/dist/basic-sdk/comment/components/comment-participants-editor/index.js +0 -69
- package/dist/basic-sdk/comment/components/comment-participants-editor/searched-collaborators.js +0 -62
- package/dist/basic-sdk/comment/components/comment-participants-editor/selected-participants.js +0 -48
- package/dist/basic-sdk/comment/components/editor-comment.js +0 -183
- package/dist/basic-sdk/comment/components/elements-comment-count/element-comment-count.js +0 -64
- package/dist/basic-sdk/comment/components/elements-comment-count/index.css +0 -29
- package/dist/basic-sdk/comment/components/elements-comment-count/index.js +0 -49
- package/dist/basic-sdk/comment/components/global-comment/global-comment-body-header.js +0 -88
- package/dist/basic-sdk/comment/components/global-comment/global-comment-header.js +0 -89
- package/dist/basic-sdk/comment/components/global-comment/index.css +0 -328
- package/dist/basic-sdk/comment/components/global-comment/index.js +0 -217
- package/dist/basic-sdk/comment/components/index.js +0 -21
- package/dist/basic-sdk/comment/components/style.css +0 -40
- package/dist/basic-sdk/comment/helper.js +0 -184
- package/dist/basic-sdk/comment/hooks/comment-hooks/use-comment-context.js +0 -20
- package/dist/basic-sdk/comment/hooks/comment-hooks/use-comment-list.js +0 -45
- package/dist/basic-sdk/comment/hooks/comment-hooks/use-comment-mount.js +0 -57
- package/dist/basic-sdk/comment/hooks/notification-hooks/index.js +0 -25
- package/dist/basic-sdk/comment/hooks/notification-hooks/use-notification-context.js +0 -20
- package/dist/basic-sdk/comment/hooks/notification-hooks/use-notification-mount.js +0 -70
- package/dist/basic-sdk/comment/hooks/use-participants.js +0 -26
- package/dist/basic-sdk/comment/index.js +0 -21
- package/dist/basic-sdk/comment/reducer/comment-reducer.js +0 -353
- package/dist/basic-sdk/comment/reducer/notification-reducer.js +0 -89
- package/dist/basic-sdk/comment/utils/get-event-transfer.js +0 -77
- package/dist/basic-sdk/comment/utils/index.js +0 -281
- package/dist/basic-sdk/comment/utils/notification-utils.js +0 -62
- package/dist/basic-sdk/layout/comment-layout/index.css +0 -15
- package/dist/basic-sdk/layout/comment-layout/index.js +0 -75
- package/dist/basic-sdk/layout/comment-layout/resize-width/index.css +0 -38
- package/dist/basic-sdk/layout/comment-layout/resize-width/index.js +0 -132
- package/dist/basic-sdk/layout/editor-container.js +0 -32
- package/dist/basic-sdk/layout/index.js +0 -13
- package/dist/basic-sdk/socket/helpers.js +0 -299
- package/dist/basic-sdk/socket/index.js +0 -20
- package/dist/basic-sdk/socket/socket-client.js +0 -211
- package/dist/basic-sdk/socket/socket-manager.js +0 -386
- package/dist/basic-sdk/socket/with-socket-io.js +0 -73
- /package/dist/basic-sdk/comment/{constants/index.js → constants.js} +0 -0
|
@@ -113,48 +113,4 @@
|
|
|
113
113
|
margin: 0 auto;
|
|
114
114
|
padding-top: 20px;
|
|
115
115
|
padding-bottom: 20px;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/* article style --> ./sdoc-editor-article.css */
|
|
119
|
-
|
|
120
|
-
.sdoc-editor-container .seafile-block-container {
|
|
121
|
-
position: relative;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
.sdoc-editor-container .seafile-block-container .comment-count {
|
|
125
|
-
position: absolute;
|
|
126
|
-
right: -55px;
|
|
127
|
-
top: 0px;
|
|
128
|
-
border-radius: 4px;
|
|
129
|
-
width: 15px;
|
|
130
|
-
height: 15px;
|
|
131
|
-
line-height: 18px;
|
|
132
|
-
pointer-events: none;
|
|
133
|
-
display: flex;
|
|
134
|
-
align-items: center;
|
|
135
|
-
justify-content: center;
|
|
136
|
-
color: #fff;
|
|
137
|
-
background: rgba(0, 0, 0, .3);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
.sdoc-editor-container .seafile-block-container .comment-count__btn {
|
|
141
|
-
font-size: 12px;
|
|
142
|
-
transform: scale(.75);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
.comment-editor-toolbar {
|
|
146
|
-
display: flex;
|
|
147
|
-
justify-content: space-between;
|
|
148
|
-
align-items: center;
|
|
149
|
-
height: 32px;
|
|
150
|
-
user-select: none;
|
|
151
|
-
border-top: 1px solid #e5e6e8;
|
|
152
|
-
z-index: 102;
|
|
153
|
-
margin: 0 8px;
|
|
154
|
-
margin-top: 5px;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
.comment-editor-menu-group {
|
|
158
|
-
border-right: none;
|
|
159
|
-
padding-left: 0 !important;
|
|
160
|
-
}
|
|
116
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.searchCollaborators = void 0;
|
|
7
|
+
var _helper = require("../extension/plugins/mention/helper");
|
|
8
|
+
const searchCollaborators = (collaborators, searchValue, editor) => {
|
|
9
|
+
const validSearchValue = searchValue ? searchValue.trim().toLowerCase() : '';
|
|
10
|
+
const validCollaborators = Array.isArray(collaborators) && collaborators.length > 0 ? collaborators : [];
|
|
11
|
+
if (!validSearchValue) return validCollaborators;
|
|
12
|
+
|
|
13
|
+
// The current character is '@' and the previous character is a null character
|
|
14
|
+
const beforeStr = (0, _helper.getPreCharacters)(editor);
|
|
15
|
+
const isEmptyStr = beforeStr.slice(-2, -1).trim().length === 0;
|
|
16
|
+
if (beforeStr.slice(-1) === '@' && isEmptyStr) {
|
|
17
|
+
return validCollaborators;
|
|
18
|
+
}
|
|
19
|
+
return validCollaborators.filter(collaborator => {
|
|
20
|
+
const {
|
|
21
|
+
name,
|
|
22
|
+
name_pinyin = ''
|
|
23
|
+
} = collaborator;
|
|
24
|
+
if (name.toString().toLowerCase().indexOf(validSearchValue) > -1) return true;
|
|
25
|
+
if (!name_pinyin) return false;
|
|
26
|
+
const validNamePinyin = name_pinyin.toString().toLowerCase();
|
|
27
|
+
const validSearchPinyinValue = validSearchValue.replace(/ |'/g, '');
|
|
28
|
+
|
|
29
|
+
// complete: For example, seatable can be retrieved when searching for sea.
|
|
30
|
+
if (validNamePinyin.indexOf(validSearchPinyinValue) > -1) return true;
|
|
31
|
+
if (validNamePinyin.replace(/'/g, '').indexOf(validSearchPinyinValue) > -1) return true;
|
|
32
|
+
const validNamePinyinList = validNamePinyin.split('\'');
|
|
33
|
+
// acronym: For example, sea table can be retrieved when searching for st.
|
|
34
|
+
const namePinyinAcronym = validNamePinyinList.map(item => item && item.trim() ? item.trim().slice(0, 1) : '');
|
|
35
|
+
if (namePinyinAcronym.join('').indexOf(validSearchPinyinValue) > -1) return true;
|
|
36
|
+
return false;
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
exports.searchCollaborators = searchCollaborators;
|
|
@@ -55,8 +55,9 @@ class Context {
|
|
|
55
55
|
this.api = null;
|
|
56
56
|
this.config = null;
|
|
57
57
|
}
|
|
58
|
-
init() {
|
|
58
|
+
init(api) {
|
|
59
59
|
this.initSettings(); // lazy init context class
|
|
60
|
+
this.api = api;
|
|
60
61
|
// const server = this.getSetting('serviceUrl');
|
|
61
62
|
// const token = this.getSetting('accessToken');
|
|
62
63
|
// this.api = new SeafileAPI(server, token);
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
.comment-editor-wrapper {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
justify-content: center;
|
|
5
|
+
cursor: text;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.comment-editor-wrapper .comment-editor-container {
|
|
9
|
+
flex: 1;
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
min-height: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.comment-editor-wrapper .comment-editor-content {
|
|
16
|
+
border: 1px solid #ececec;
|
|
17
|
+
border-radius: 3px;
|
|
18
|
+
transition: border-color .3s ease;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.comment-editor-wrapper .comment-editor-content:focus-within {
|
|
22
|
+
border-color: #ff8e03;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/* comment-editor */
|
|
26
|
+
.comment-editor-wrapper .comment-editor-content .article.comment-editor {
|
|
27
|
+
width: 100%;
|
|
28
|
+
padding: 8px;
|
|
29
|
+
padding-bottom: 0;
|
|
30
|
+
min-height: 60px;
|
|
31
|
+
max-height: 130px;
|
|
32
|
+
box-shadow: none;
|
|
33
|
+
overflow-y: auto;
|
|
34
|
+
overflow-x: hidden;
|
|
35
|
+
border: none;
|
|
36
|
+
background-color: transparent;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.comment-editor-wrapper .comment-editor-content .article.comment-editor :first-child {
|
|
40
|
+
margin-top: 0 !important;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.comment-editor-wrapper .comment-editor:empty:before {
|
|
44
|
+
content: attr(placeholder);
|
|
45
|
+
opacity: .6;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.comment-editor-wrapper .comment-editor:focus-visible {
|
|
49
|
+
outline: none;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.comment-editor-wrapper .comment-editor:focus {
|
|
53
|
+
border: 1px solid rgba(0, 0, 0, .12);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.comment-editor-wrapper .comment-editor-user-info {
|
|
57
|
+
display: flex;
|
|
58
|
+
align-items: center;
|
|
59
|
+
margin-bottom: 10px;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.comment-editor-wrapper .comment-editor-user-info .comment-editor-user-img {
|
|
63
|
+
height: 30px;
|
|
64
|
+
width: 30px;
|
|
65
|
+
border-radius: 50%;
|
|
66
|
+
overflow: hidden;
|
|
67
|
+
margin-right: 8px;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.comment-editor-wrapper .comment-editor-user-info .comment-editor-user-name {
|
|
71
|
+
flex: 1;
|
|
72
|
+
overflow: hidden;
|
|
73
|
+
text-overflow: ellipsis;
|
|
74
|
+
white-space: nowrap;
|
|
75
|
+
user-select: none;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.comment-editor-wrapper .comment-operations {
|
|
79
|
+
display: flex;
|
|
80
|
+
justify-content: flex-end;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/* comment-editor-toolbar */
|
|
84
|
+
.comment-editor-wrapper .comment-editor-toolbar {
|
|
85
|
+
display: flex;
|
|
86
|
+
justify-content: space-between;
|
|
87
|
+
align-items: center;
|
|
88
|
+
height: 32px;
|
|
89
|
+
user-select: none;
|
|
90
|
+
z-index: 102;
|
|
91
|
+
margin: 0 8px;
|
|
92
|
+
margin-top: 5px;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.comment-editor-wrapper .comment-editor-toolbar .comment-editor-menu-group {
|
|
96
|
+
border-right: none !important;
|
|
97
|
+
padding-left: 0 !important;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.comment-editor-wrapper .comment-editor-toolbar .menu-group {
|
|
101
|
+
height: 100%;
|
|
102
|
+
padding: 6px 0 6px 8px;
|
|
103
|
+
font-size: 0.75rem;
|
|
104
|
+
border-right: 1px solid #e5e6e8;
|
|
105
|
+
border-radius: 0 !important;
|
|
106
|
+
color: #444;
|
|
107
|
+
display: flex;
|
|
108
|
+
align-items: center;
|
|
109
|
+
justify-content: center;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.comment-editor-wrapper .comment-editor-toolbar .menu-group .menu-group-item {
|
|
113
|
+
width: 24px;
|
|
114
|
+
height: 24px;
|
|
115
|
+
line-height: 24px;
|
|
116
|
+
margin-right: 8px;
|
|
117
|
+
border: none !important;
|
|
118
|
+
color: #444;
|
|
119
|
+
background-color: transparent;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.comment-editor-wrapper .comment-editor-toolbar .menu-group .menu-group-item:disabled {
|
|
123
|
+
color: #BDBDBD;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.comment-editor-wrapper .comment-editor-toolbar .menu-group .menu-group-item:hover {
|
|
127
|
+
background-color: #F2F2F2;
|
|
128
|
+
border-radius: 2px;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.comment-editor-wrapper .comment-editor-toolbar .menu-group .menu-group-item[data-active='true'] {
|
|
132
|
+
color: #eb8205;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.comment-editor-wrapper .comment-editor-toolbar .menu-group .menu-group-item .sdocfont,
|
|
136
|
+
.sdoc-menu-with-dropdown .sdoc-menu-with-dropdown-icon .sdocfont {
|
|
137
|
+
font-size: 12px;
|
|
138
|
+
}
|
|
@@ -13,23 +13,24 @@ var _slateReact = require("@seafile/slate-react");
|
|
|
13
13
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
14
14
|
var _isHotkey = _interopRequireDefault(require("is-hotkey"));
|
|
15
15
|
var _scrollIntoViewIfNeeded = _interopRequireDefault(require("scroll-into-view-if-needed"));
|
|
16
|
-
var _constants = require("
|
|
17
|
-
var _context = _interopRequireDefault(require("
|
|
18
|
-
var _useCursors = require("
|
|
19
|
-
var _decorates = require("
|
|
20
|
-
var _extension = require("
|
|
21
|
-
var
|
|
22
|
-
var
|
|
23
|
-
var
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
var _nodeId = _interopRequireDefault(require("
|
|
29
|
-
var _mdToSlate = _interopRequireDefault(require("
|
|
30
|
-
var _slateToMd = _interopRequireDefault(require("
|
|
31
|
-
var _eventBus = _interopRequireDefault(require("
|
|
32
|
-
var _eventHandler = _interopRequireDefault(require("
|
|
16
|
+
var _constants = require("../constants");
|
|
17
|
+
var _context = _interopRequireDefault(require("../context"));
|
|
18
|
+
var _useCursors = require("../cursor/use-cursors");
|
|
19
|
+
var _decorates = require("../decorates");
|
|
20
|
+
var _extension = require("../extension");
|
|
21
|
+
var _insertElementDialog = _interopRequireDefault(require("../extension/commons/insert-element-dialog"));
|
|
22
|
+
var _constants2 = require("../extension/constants");
|
|
23
|
+
var _core = require("../extension/core");
|
|
24
|
+
var _renderCommentEditorElement = _interopRequireDefault(require("../extension/render/render-comment-editor-element"));
|
|
25
|
+
var _commentEditorToolbar = _interopRequireDefault(require("../extension/toolbar/comment-editor-toolbar"));
|
|
26
|
+
var _useComment = require("../hooks/use-comment");
|
|
27
|
+
var _useScrollContext = require("../hooks/use-scroll-context");
|
|
28
|
+
var _nodeId = _interopRequireDefault(require("../node-id"));
|
|
29
|
+
var _mdToSlate = _interopRequireDefault(require("../slate-convert/md-to-slate"));
|
|
30
|
+
var _slateToMd = _interopRequireDefault(require("../slate-convert/slate-to-md"));
|
|
31
|
+
var _eventBus = _interopRequireDefault(require("../utils/event-bus"));
|
|
32
|
+
var _eventHandler = _interopRequireDefault(require("../utils/event-handler"));
|
|
33
|
+
require("./comment-editor.css");
|
|
33
34
|
const getSubmitTip = (type, content) => {
|
|
34
35
|
if (content) return 'Save';
|
|
35
36
|
return type === 'comment' ? 'Comment' : 'Reply';
|
|
@@ -37,29 +38,28 @@ const getSubmitTip = (type, content) => {
|
|
|
37
38
|
const DEFAULT_PLACEHOLDER = 'Enter_comment_shift_enter_for_new_line_Enter_to_send';
|
|
38
39
|
const CommentEditor = _ref => {
|
|
39
40
|
let {
|
|
40
|
-
type,
|
|
41
|
-
className,
|
|
42
41
|
content,
|
|
43
42
|
commentContent,
|
|
44
43
|
placeholder = DEFAULT_PLACEHOLDER,
|
|
45
44
|
insertContent,
|
|
46
45
|
updateContent,
|
|
46
|
+
onContentChange,
|
|
47
47
|
setIsEditing,
|
|
48
48
|
hiddenComment,
|
|
49
49
|
hiddenUserInfo,
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
closeComment
|
|
50
|
+
closeComment,
|
|
51
|
+
addParticipants
|
|
53
52
|
} = _ref;
|
|
54
53
|
const commentWrapperRef = (0, _react.useRef)();
|
|
55
54
|
const {
|
|
56
55
|
t
|
|
57
56
|
} = (0, _reactI18next.useTranslation)('sdoc-editor');
|
|
58
57
|
const {
|
|
59
|
-
|
|
58
|
+
className,
|
|
59
|
+
userInfo,
|
|
60
|
+
type
|
|
60
61
|
} = (0, _useComment.useComment)();
|
|
61
62
|
const submitTip = (0, _react.useMemo)(() => getSubmitTip(type, content), [content, type]);
|
|
62
|
-
const userInfo = _context.default.getUserInfo();
|
|
63
63
|
const document = (0, _react.useMemo)(() => {
|
|
64
64
|
const cursor = {};
|
|
65
65
|
let elements = null;
|
|
@@ -112,6 +112,8 @@ const CommentEditor = _ref => {
|
|
|
112
112
|
if (!_slateReact.ReactEditor.isFocused(editor)) return;
|
|
113
113
|
onSubmit(event);
|
|
114
114
|
}, [editor, onSubmit]);
|
|
115
|
+
|
|
116
|
+
// addEventListener
|
|
115
117
|
(0, _react.useEffect)(() => {
|
|
116
118
|
const eventBus = _eventBus.default.getInstance();
|
|
117
119
|
const unsubscribePostComment = eventBus.subscribe(_constants.INTERNAL_EVENT.COMMENT_EDITOR_POST_COMMENT, onSubmitByEnterKey);
|
|
@@ -148,6 +150,8 @@ const CommentEditor = _ref => {
|
|
|
148
150
|
}
|
|
149
151
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
150
152
|
}, [setIsEditing]);
|
|
153
|
+
|
|
154
|
+
// set editor children
|
|
151
155
|
(0, _react.useEffect)(() => {
|
|
152
156
|
let children = (0, _mdToSlate.default)(content);
|
|
153
157
|
if (commentContent) {
|
|
@@ -239,7 +243,9 @@ const CommentEditor = _ref => {
|
|
|
239
243
|
width: "100%"
|
|
240
244
|
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
241
245
|
className: "comment-editor-user-name"
|
|
242
|
-
}, userInfo.name)), /*#__PURE__*/_react.default.createElement(
|
|
246
|
+
}, userInfo.name)), /*#__PURE__*/_react.default.createElement("div", {
|
|
247
|
+
className: "comment-editor-container"
|
|
248
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
243
249
|
className: "comment-editor-content"
|
|
244
250
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
245
251
|
ref: commentEditorContainerRef,
|
|
@@ -276,6 +282,8 @@ const CommentEditor = _ref => {
|
|
|
276
282
|
onSubmit: onSubmit,
|
|
277
283
|
submitBtnText: t(submitTip),
|
|
278
284
|
onCancel: onCancel
|
|
279
|
-
})))
|
|
285
|
+
}))), /*#__PURE__*/_react.default.createElement(_insertElementDialog.default, {
|
|
286
|
+
editor: editor
|
|
287
|
+
}));
|
|
280
288
|
};
|
|
281
289
|
var _default = exports.default = CommentEditor;
|
|
@@ -291,7 +291,7 @@ const handleBase64Image = (editor, path, imgData) => {
|
|
|
291
291
|
const file = new File([blob], `${_slugid.default.nice()}.jpg`, {
|
|
292
292
|
type: unit8Array.mime
|
|
293
293
|
});
|
|
294
|
-
_context.default.uploadLocalImage([file]).then(res => {
|
|
294
|
+
_context.default.api.uploadLocalImage([file]).then(res => {
|
|
295
295
|
const _data = {
|
|
296
296
|
...imgData,
|
|
297
297
|
src: res[0]
|
|
@@ -51,7 +51,7 @@ const useCopyImage = _ref => {
|
|
|
51
51
|
const file = new File([blob], 'downloaded_image.png', {
|
|
52
52
|
type: blob.type
|
|
53
53
|
});
|
|
54
|
-
const imageUrl = await _context.default.uploadLocalImage([file]);
|
|
54
|
+
const imageUrl = await _context.default.api.uploadLocalImage([file]);
|
|
55
55
|
if (imageUrl && imageUrl[0]) {
|
|
56
56
|
updateImageNode(editor, element, imageUrl[0]);
|
|
57
57
|
}
|
|
@@ -42,7 +42,8 @@ const useUploadImage = _ref => {
|
|
|
42
42
|
const uploadCurrentImage = async () => {
|
|
43
43
|
try {
|
|
44
44
|
const fileItem = _imageCache.default.getImage(file_uuid);
|
|
45
|
-
|
|
45
|
+
console.log(111, _context.default.api.uploadLocalImage);
|
|
46
|
+
const imageUrl = await _context.default.api.uploadLocalImage([fileItem]);
|
|
46
47
|
if (imageUrl && imageUrl[0]) {
|
|
47
48
|
updateImageNode(editor, element, imageUrl[0]);
|
|
48
49
|
}
|
|
@@ -9,7 +9,6 @@ exports.default = void 0;
|
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _reactI18next = require("react-i18next");
|
|
11
11
|
var _slate = require("@seafile/slate");
|
|
12
|
-
var _commentContextMenu = _interopRequireDefault(require("../../../../comment/components/comment-context-menu"));
|
|
13
12
|
var _constants = require("../../../../constants");
|
|
14
13
|
var _context = _interopRequireDefault(require("../../../../context"));
|
|
15
14
|
var _useColorContext = require("../../../../hooks/use-color-context");
|
|
@@ -156,7 +155,7 @@ const TextStyleMenuList = _ref => {
|
|
|
156
155
|
tipMessage: t('Reduce_font_size')
|
|
157
156
|
}, /*#__PURE__*/_react.default.createElement("i", {
|
|
158
157
|
className: "sdocfont sdoc-reduce-font-size"
|
|
159
|
-
}))), idPrefix &&
|
|
158
|
+
}))), idPrefix && enableSeafileAI && /*#__PURE__*/_react.default.createElement(_aiMenu.AIContextMenu, {
|
|
160
159
|
isRichEditor: isRichEditor
|
|
161
160
|
}));
|
|
162
161
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
3
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
@@ -8,196 +7,36 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
7
|
exports.useComment = exports.CommentProvider = void 0;
|
|
9
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
9
|
var _reactI18next = require("react-i18next");
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
var _toast = _interopRequireDefault(require("../components/toast"));
|
|
18
|
-
var _constants2 = require("../constants");
|
|
19
|
-
var _model = require("../model");
|
|
20
|
-
var _commonUtils = require("../utils/common-utils");
|
|
21
|
-
var _eventBus = _interopRequireDefault(require("../utils/event-bus"));
|
|
10
|
+
require("../assets/css/layout.css");
|
|
11
|
+
require("../assets/css/default.css");
|
|
12
|
+
require("../assets/css/sdoc-editor-article.css");
|
|
13
|
+
require("../assets/css/sdoc-editor-plugins.css");
|
|
14
|
+
require("../assets/css/sdoc-comment-editor-plugin.css");
|
|
15
|
+
require("../assets/css/dropdown-menu.css");
|
|
22
16
|
const CommentContext = /*#__PURE__*/_react.default.createContext(null);
|
|
23
17
|
const CommentProvider = _ref => {
|
|
24
18
|
let {
|
|
25
|
-
editor,
|
|
26
19
|
children,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
pluginName,
|
|
30
|
-
className
|
|
20
|
+
type,
|
|
21
|
+
userInfo,
|
|
22
|
+
pluginName = '',
|
|
23
|
+
className = '',
|
|
24
|
+
pluginEventBus,
|
|
25
|
+
pluginEvent
|
|
31
26
|
} = _ref;
|
|
32
27
|
const {
|
|
33
28
|
t
|
|
34
29
|
} = (0, _reactI18next.useTranslation)('sdoc-editor');
|
|
35
30
|
const [collaborators, setCollaborators] = (0, _react.useState)([]);
|
|
36
|
-
const [participants, setParticipants] = (0, _react.useState)([]);
|
|
37
|
-
const [commentType, setCommentType] = (0, _react.useState)(_constants.COMMENT_TYPES.ALL);
|
|
38
|
-
const [commentList, setCommentList] = (0, _react.useState)([]);
|
|
39
|
-
const [commentsInfo, dispatch] = (0, _react.useReducer)(_commentReducer.commentReducer, _commentReducer.initCommentsInfo);
|
|
40
|
-
(0, _useCommentMount.useCommentsMount)(dispatch, api);
|
|
41
|
-
const [notificationsInfo, notificationsDispatch] = (0, _react.useReducer)(_notificationReducer.notificationReducer, _notificationReducer.initNotificationsInfo);
|
|
42
|
-
(0, _notificationHooks.useNotificationsMount)(dispatch, api, collaborators);
|
|
43
|
-
(0, _react.useEffect)(() => {
|
|
44
|
-
if (Object.keys(commentsInfo.element_comments_map).length) {
|
|
45
|
-
editor.element_comments_map = commentsInfo.element_comments_map;
|
|
46
|
-
}
|
|
47
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
48
|
-
}, [commentsInfo.element_comments_map]);
|
|
49
|
-
(0, _react.useEffect)(() => {
|
|
50
|
-
editor.notifications_map = {
|
|
51
|
-
...notificationsInfo.notifications_map
|
|
52
|
-
};
|
|
53
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
54
|
-
}, [notificationsInfo]);
|
|
55
|
-
(0, _react.useEffect)(() => {
|
|
56
|
-
const {
|
|
57
|
-
comment_list
|
|
58
|
-
} = commentsInfo;
|
|
59
|
-
if (commentType === _constants.COMMENT_TYPES.ALL) {
|
|
60
|
-
const commentList = comment_list.map(item => {
|
|
61
|
-
item.replies = item.replies.filter(reply => !['True', 'False'].includes(reply.reply));
|
|
62
|
-
return item;
|
|
63
|
-
});
|
|
64
|
-
setCommentList(commentList);
|
|
65
|
-
} else if (commentType === _constants.COMMENT_TYPES.RESOLVED) {
|
|
66
|
-
const commentList = comment_list.filter(item => item.resolved);
|
|
67
|
-
setCommentList(commentList);
|
|
68
|
-
} else if (commentType === _constants.COMMENT_TYPES.UNRESOLVED) {
|
|
69
|
-
const commentList = comment_list.filter(item => !item.resolved);
|
|
70
|
-
setCommentList(commentList);
|
|
71
|
-
} else if (commentType === _constants.COMMENT_TYPES.DOC) {
|
|
72
|
-
const commentList = comment_list.filter(comment => comment.detail.element_id === _constants.DOC_COMMENT_ELEMENT_ID);
|
|
73
|
-
setCommentList(commentList);
|
|
74
|
-
}
|
|
75
|
-
}, [commentType, commentsInfo]);
|
|
76
|
-
|
|
77
|
-
// Participants
|
|
78
|
-
const updateLocalParticipants = (0, _react.useCallback)(function () {
|
|
79
|
-
let added = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
80
|
-
if (!Array.isArray(added) || added.length === 0) return;
|
|
81
|
-
let newParticipants = participants.slice(0);
|
|
82
|
-
added.forEach(participant => {
|
|
83
|
-
const newParticipant = new _model.User(participant);
|
|
84
|
-
if (!newParticipants.find(item => item.username === newParticipant.username)) {
|
|
85
|
-
newParticipants.push(newParticipant);
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
setParticipants(newParticipants);
|
|
89
|
-
}, [participants]);
|
|
90
|
-
const deleteLocalParticipant = (0, _react.useCallback)(email => {
|
|
91
|
-
if (!participants.find(participant => participant.username === email)) return;
|
|
92
|
-
let newParticipants = participants.slice(0);
|
|
93
|
-
newParticipants = newParticipants.filter(participant => participant.username !== email);
|
|
94
|
-
setParticipants(newParticipants);
|
|
95
|
-
}, [participants]);
|
|
96
|
-
const addParticipants = (0, _react.useCallback)(otherEmail => {
|
|
97
|
-
if (participants.find(participant => participant.username === otherEmail)) return;
|
|
98
|
-
api.addParticipants([otherEmail]).then(res => {
|
|
99
|
-
const {
|
|
100
|
-
success
|
|
101
|
-
} = res.data;
|
|
102
|
-
updateLocalParticipants(success);
|
|
103
|
-
}).catch(error => {
|
|
104
|
-
const errorMessage = (0, _commonUtils.getErrorMsg)(error);
|
|
105
|
-
_toast.default.danger(t(errorMessage));
|
|
106
|
-
});
|
|
107
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
108
|
-
}, [updateLocalParticipants, participants]);
|
|
109
|
-
const deleteParticipant = (0, _react.useCallback)(email => {
|
|
110
|
-
if (!participants.find(participant => participant.username === email)) return;
|
|
111
|
-
api.deleteParticipants(email).then(res => {
|
|
112
|
-
let newParticipants = participants.slice(0);
|
|
113
|
-
newParticipants = newParticipants.filter(participant => participant.username !== email);
|
|
114
|
-
setParticipants(newParticipants);
|
|
115
|
-
}).catch(error => {
|
|
116
|
-
const errorMessage = (0, _commonUtils.getErrorMsg)(error);
|
|
117
|
-
_toast.default.danger(t(errorMessage));
|
|
118
|
-
});
|
|
119
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
120
|
-
}, [participants]);
|
|
121
|
-
|
|
122
|
-
// Notifications
|
|
123
|
-
const deleteUnseenNotifications = (0, _react.useCallback)(comment => {
|
|
124
|
-
let unseenCommentIds = [];
|
|
125
|
-
let unseenNotificationKeys = [];
|
|
126
|
-
const commentNotificationKey = (0, _utils.generatorNotificationKey)(comment.id);
|
|
127
|
-
const commentNotification = notificationsInfo.notifications_map[commentNotificationKey];
|
|
128
|
-
if (commentNotification) {
|
|
129
|
-
unseenNotificationKeys.push(commentNotification.key);
|
|
130
|
-
unseenCommentIds.push(commentNotification.id);
|
|
131
|
-
}
|
|
132
|
-
Array.isArray(comment.replies) && comment.replies.forEach(reply => {
|
|
133
|
-
const replyNotificationKey = (0, _utils.generatorNotificationKey)(reply.comment_id, reply.id);
|
|
134
|
-
const replyNotification = notificationsInfo.notifications_map[replyNotificationKey];
|
|
135
|
-
if (replyNotification) {
|
|
136
|
-
unseenNotificationKeys.push(replyNotification.key);
|
|
137
|
-
unseenCommentIds.push(replyNotification.id);
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
api.deleteUnseenNotifications(unseenCommentIds).then(res => {
|
|
141
|
-
notificationsDispatch({
|
|
142
|
-
type: _constants.DOC_NOTIFICATION_REDUCER_TYPE.DEL,
|
|
143
|
-
payload: unseenNotificationKeys
|
|
144
|
-
});
|
|
145
|
-
}).catch(error => {
|
|
146
|
-
//
|
|
147
|
-
});
|
|
148
|
-
}, [api, notificationsInfo.notifications_map]);
|
|
149
|
-
|
|
150
|
-
// Mount
|
|
151
|
-
(0, _react.useEffect)(() => {
|
|
152
|
-
// get participants
|
|
153
|
-
api.listParticipants().then(res => {
|
|
154
|
-
const participants = res.data.participant_list;
|
|
155
|
-
updateLocalParticipants(participants);
|
|
156
|
-
}).catch(error => {
|
|
157
|
-
console.log(error);
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
// get collaborators
|
|
161
|
-
api.listRelatedUsers().then(res => {
|
|
162
|
-
const collaborators = [];
|
|
163
|
-
res.data.related_users.forEach(user => {
|
|
164
|
-
const collaborator = new _model.User(user);
|
|
165
|
-
collaborators.push(collaborator);
|
|
166
|
-
});
|
|
167
|
-
setCollaborators(collaborators);
|
|
168
|
-
}).catch(error => {
|
|
169
|
-
console.log(error);
|
|
170
|
-
});
|
|
171
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
172
|
-
}, []);
|
|
173
|
-
|
|
174
|
-
// Listening
|
|
175
|
-
(0, _react.useEffect)(() => {
|
|
176
|
-
const eventBus = _eventBus.default.getInstance();
|
|
177
|
-
const unsubscribeParticipantAdded = eventBus.subscribe(_constants2.INTERNAL_EVENT.PARTICIPANT_ADDED, updateLocalParticipants);
|
|
178
|
-
const unsubscribeParticipantRemoved = eventBus.subscribe(_constants2.INTERNAL_EVENT.PARTICIPANT_REMOVED, deleteLocalParticipant);
|
|
179
|
-
return () => {
|
|
180
|
-
unsubscribeParticipantAdded();
|
|
181
|
-
unsubscribeParticipantRemoved();
|
|
182
|
-
};
|
|
183
|
-
}, [updateLocalParticipants, deleteLocalParticipant]);
|
|
184
31
|
return /*#__PURE__*/_react.default.createElement(CommentContext.Provider, {
|
|
185
32
|
value: {
|
|
33
|
+
type,
|
|
34
|
+
userInfo,
|
|
186
35
|
pluginName,
|
|
187
36
|
className,
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
commentList,
|
|
192
|
-
dispatch,
|
|
193
|
-
setCommentType,
|
|
194
|
-
onCloseCommentPanel,
|
|
195
|
-
collaborators,
|
|
196
|
-
notificationsInfo,
|
|
197
|
-
deleteUnseenNotifications,
|
|
198
|
-
addParticipants,
|
|
199
|
-
deleteParticipant,
|
|
200
|
-
participants
|
|
37
|
+
pluginEventBus,
|
|
38
|
+
pluginEvent,
|
|
39
|
+
collaborators
|
|
201
40
|
}
|
|
202
41
|
}, children);
|
|
203
42
|
};
|
package/dist/basic-sdk/index.js
CHANGED
|
@@ -4,10 +4,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
Object.defineProperty(exports, "
|
|
7
|
+
Object.defineProperty(exports, "CommentEditor", {
|
|
8
8
|
enumerable: true,
|
|
9
9
|
get: function () {
|
|
10
|
-
return
|
|
10
|
+
return _commentEditor.default;
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
13
|
Object.defineProperty(exports, "CommentProvider", {
|
|
@@ -148,26 +148,19 @@ Object.defineProperty(exports, "withNodeId", {
|
|
|
148
148
|
return _nodeId.default;
|
|
149
149
|
}
|
|
150
150
|
});
|
|
151
|
-
Object.defineProperty(exports, "withSocketIO", {
|
|
152
|
-
enumerable: true,
|
|
153
|
-
get: function () {
|
|
154
|
-
return _socket.withSocketIO;
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
151
|
var _fileLoading = _interopRequireDefault(require("./components/file-loading"));
|
|
158
152
|
var _loading = _interopRequireDefault(require("./components/loading"));
|
|
159
153
|
var _toast = _interopRequireDefault(require("./components/toast"));
|
|
160
154
|
var _tooltip = _interopRequireDefault(require("./components/tooltip"));
|
|
161
155
|
var _constants = require("./constants");
|
|
162
156
|
var _context = _interopRequireDefault(require("./context"));
|
|
157
|
+
var _commentEditor = _interopRequireDefault(require("./editor/comment-editor"));
|
|
163
158
|
var _extension = require("./extension");
|
|
164
159
|
var _dropdownMenuItem = _interopRequireDefault(require("./extension/commons/dropdown-menu-item"));
|
|
165
160
|
var _menuShortcutIndicator = _interopRequireDefault(require("./extension/commons/menu-shortcut-indicator"));
|
|
166
161
|
var _useComment = require("./hooks/use-comment");
|
|
167
|
-
var _commentLayout = _interopRequireDefault(require("./layout/comment-layout"));
|
|
168
162
|
var _nodeId = _interopRequireDefault(require("./node-id"));
|
|
169
163
|
var _slateConvert = require("./slate-convert");
|
|
170
|
-
var _socket = require("./socket");
|
|
171
164
|
var _commonUtils = require("./utils/common-utils");
|
|
172
165
|
var _eventBus = _interopRequireDefault(require("./utils/event-bus"));
|
|
173
166
|
var _localStorageUtils = _interopRequireDefault(require("./utils/local-storage-utils"));
|