@seafile/comment-editor 0.0.1-alpha.4 → 0.0.1-alpha.40
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 +8 -21
- package/dist/basic-sdk/editor/comment-editor.css +138 -0
- package/dist/basic-sdk/{comment/components → editor}/comment-editor.js +42 -43
- 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 +1 -1
- package/dist/basic-sdk/extension/toolbar/comment-editor-toolbar/index.js +13 -9
- package/dist/basic-sdk/hooks/use-comment.js +27 -180
- package/dist/basic-sdk/index.js +3 -10
- package/dist/basic-sdk/socket/helpers.js +14 -1
- package/dist/index.js +0 -12
- package/dist/pages/seafile-comment-editor.js +35 -13
- package/package.json +6 -6
- 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-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-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 -90
- 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 -87
- 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/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;
|
|
@@ -11,12 +11,12 @@ var _sdocServerApi = _interopRequireDefault(require("./api/sdoc-server-api"));
|
|
|
11
11
|
var _seafileApi = _interopRequireDefault(require("./api/seafile-api"));
|
|
12
12
|
class Context {
|
|
13
13
|
constructor() {
|
|
14
|
-
(0, _defineProperty2.default)(this, "initSettings",
|
|
15
|
-
this.settings = window.seafile ? window.seafile : window.seafileConfig;
|
|
14
|
+
(0, _defineProperty2.default)(this, "initSettings", settings => {
|
|
15
|
+
this.settings = settings ? settings : window.seafile ? window.seafile : window.seafileConfig;
|
|
16
16
|
const {
|
|
17
|
-
name,
|
|
18
|
-
username,
|
|
19
|
-
avatarURL
|
|
17
|
+
name = '',
|
|
18
|
+
username = '',
|
|
19
|
+
avatarURL = ''
|
|
20
20
|
} = this.settings;
|
|
21
21
|
const userInfo = {
|
|
22
22
|
name,
|
|
@@ -24,13 +24,6 @@ class Context {
|
|
|
24
24
|
avatar_url: avatarURL
|
|
25
25
|
};
|
|
26
26
|
this.user = userInfo;
|
|
27
|
-
if (this.settings['isSdocRevision']) {
|
|
28
|
-
const repoID = this.getSetting('repoID');
|
|
29
|
-
const siteRoot = this.getSetting('siteRoot');
|
|
30
|
-
const originFilePath = this.getSetting('originFilePath');
|
|
31
|
-
const originFileURL = `${siteRoot}lib/${repoID}/file${originFilePath}`;
|
|
32
|
-
this.settings['originFileURL'] = originFileURL;
|
|
33
|
-
}
|
|
34
27
|
});
|
|
35
28
|
(0, _defineProperty2.default)(this, "uploadLocalImage", imageFiles => {
|
|
36
29
|
const docUuid = this.getSetting('docUuid');
|
|
@@ -55,15 +48,9 @@ class Context {
|
|
|
55
48
|
this.api = null;
|
|
56
49
|
this.config = null;
|
|
57
50
|
}
|
|
58
|
-
init() {
|
|
59
|
-
this.initSettings();
|
|
60
|
-
|
|
61
|
-
// const token = this.getSetting('accessToken');
|
|
62
|
-
// this.api = new SeafileAPI(server, token);
|
|
63
|
-
// const isOpenSocket = this.getSetting('isOpenSocket');
|
|
64
|
-
// if (isOpenSocket) {
|
|
65
|
-
// this.sdocServerApi = new SDocServerApi(this.settings);
|
|
66
|
-
// }
|
|
51
|
+
init(settings, api) {
|
|
52
|
+
this.initSettings(settings);
|
|
53
|
+
this.api = api;
|
|
67
54
|
}
|
|
68
55
|
getSettings() {
|
|
69
56
|
return this.settings;
|
|
@@ -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,23 @@ 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
|
|
18
|
-
var
|
|
19
|
-
var
|
|
20
|
-
var
|
|
21
|
-
var _constants2 = require("
|
|
22
|
-
var _core = require("
|
|
23
|
-
var _renderCommentEditorElement = _interopRequireDefault(require("
|
|
24
|
-
var _commentEditorToolbar = _interopRequireDefault(require("
|
|
25
|
-
var _useComment = require("
|
|
26
|
-
var _useScrollContext = require("
|
|
27
|
-
var
|
|
28
|
-
var
|
|
29
|
-
var
|
|
30
|
-
var
|
|
31
|
-
var
|
|
32
|
-
|
|
16
|
+
var _constants = require("../constants");
|
|
17
|
+
var _useCursors = require("../cursor/use-cursors");
|
|
18
|
+
var _decorates = require("../decorates");
|
|
19
|
+
var _extension = require("../extension");
|
|
20
|
+
var _insertElementDialog = _interopRequireDefault(require("../extension/commons/insert-element-dialog"));
|
|
21
|
+
var _constants2 = require("../extension/constants");
|
|
22
|
+
var _core = require("../extension/core");
|
|
23
|
+
var _renderCommentEditorElement = _interopRequireDefault(require("../extension/render/render-comment-editor-element"));
|
|
24
|
+
var _commentEditorToolbar = _interopRequireDefault(require("../extension/toolbar/comment-editor-toolbar"));
|
|
25
|
+
var _useComment = require("../hooks/use-comment");
|
|
26
|
+
var _useScrollContext = require("../hooks/use-scroll-context");
|
|
27
|
+
var _nodeId = _interopRequireDefault(require("../node-id"));
|
|
28
|
+
var _mdToSlate = _interopRequireDefault(require("../slate-convert/md-to-slate"));
|
|
29
|
+
var _slateToMd = _interopRequireDefault(require("../slate-convert/slate-to-md"));
|
|
30
|
+
var _eventBus = _interopRequireDefault(require("../utils/event-bus"));
|
|
31
|
+
var _eventHandler = _interopRequireDefault(require("../utils/event-handler"));
|
|
32
|
+
require("./comment-editor.css");
|
|
33
33
|
const getSubmitTip = (type, content) => {
|
|
34
34
|
if (content) return 'Save';
|
|
35
35
|
return type === 'comment' ? 'Comment' : 'Reply';
|
|
@@ -37,29 +37,26 @@ const getSubmitTip = (type, content) => {
|
|
|
37
37
|
const DEFAULT_PLACEHOLDER = 'Enter_comment_shift_enter_for_new_line_Enter_to_send';
|
|
38
38
|
const CommentEditor = _ref => {
|
|
39
39
|
let {
|
|
40
|
-
type,
|
|
41
|
-
className,
|
|
42
40
|
content,
|
|
43
|
-
commentContent,
|
|
44
41
|
placeholder = DEFAULT_PLACEHOLDER,
|
|
45
42
|
insertContent,
|
|
46
|
-
|
|
47
|
-
setIsEditing,
|
|
43
|
+
onContentChange,
|
|
48
44
|
hiddenComment,
|
|
49
45
|
hiddenUserInfo,
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
closeComment
|
|
46
|
+
toolMenus = ['text_style', _constants2.BLOCKQUOTE, _constants2.UNORDERED_LIST, _constants2.ORDERED_LIST, _constants2.LINK, _constants2.IMAGE],
|
|
47
|
+
closePanel
|
|
53
48
|
} = _ref;
|
|
54
49
|
const commentWrapperRef = (0, _react.useRef)();
|
|
55
50
|
const {
|
|
56
51
|
t
|
|
57
52
|
} = (0, _reactI18next.useTranslation)('sdoc-editor');
|
|
58
53
|
const {
|
|
54
|
+
className,
|
|
55
|
+
userInfo,
|
|
56
|
+
type,
|
|
59
57
|
addParticipants
|
|
60
58
|
} = (0, _useComment.useComment)();
|
|
61
59
|
const submitTip = (0, _react.useMemo)(() => getSubmitTip(type, content), [content, type]);
|
|
62
|
-
const userInfo = _context.default.getUserInfo();
|
|
63
60
|
const document = (0, _react.useMemo)(() => {
|
|
64
61
|
const cursor = {};
|
|
65
62
|
let elements = null;
|
|
@@ -91,27 +88,25 @@ const CommentEditor = _ref => {
|
|
|
91
88
|
// init eventHandler
|
|
92
89
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
93
90
|
const eventProxy = (0, _react.useMemo)(() => new _eventHandler.default(editor), []);
|
|
94
|
-
const updateValue = (0, _react.useCallback)(value => {
|
|
95
|
-
if (!value || value.trim() === '') return;
|
|
96
|
-
if (!content) return insertContent(value);
|
|
97
|
-
updateContent && updateContent(value);
|
|
98
|
-
}, [content, insertContent, updateContent]);
|
|
99
91
|
const onSubmit = (0, _react.useCallback)(event => {
|
|
100
92
|
event && event.stopPropagation();
|
|
101
93
|
const mdString = (0, _slateToMd.default)(editor.children);
|
|
102
|
-
|
|
103
|
-
addParticipants(userInfo.username);
|
|
94
|
+
if (mdString && mdString.trim()) insertContent(mdString);
|
|
95
|
+
addParticipants && addParticipants(userInfo.username);
|
|
104
96
|
editor.children = [(0, _core.generateEmptyElement)(_constants2.PARAGRAPH, {
|
|
105
97
|
placeholder
|
|
106
98
|
})];
|
|
107
99
|
_slate.Transforms.select(editor, _slate.Editor.start(editor, []));
|
|
108
100
|
onContentChange && onContentChange(null);
|
|
109
|
-
|
|
110
|
-
|
|
101
|
+
closePanel && closePanel();
|
|
102
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
103
|
+
}, [editor, insertContent, addParticipants, placeholder, onContentChange, closePanel]);
|
|
111
104
|
const onSubmitByEnterKey = (0, _react.useCallback)(event => {
|
|
112
105
|
if (!_slateReact.ReactEditor.isFocused(editor)) return;
|
|
113
106
|
onSubmit(event);
|
|
114
107
|
}, [editor, onSubmit]);
|
|
108
|
+
|
|
109
|
+
// addEventListener
|
|
115
110
|
(0, _react.useEffect)(() => {
|
|
116
111
|
const eventBus = _eventBus.default.getInstance();
|
|
117
112
|
const unsubscribePostComment = eventBus.subscribe(_constants.INTERNAL_EVENT.COMMENT_EDITOR_POST_COMMENT, onSubmitByEnterKey);
|
|
@@ -137,7 +132,6 @@ const CommentEditor = _ref => {
|
|
|
137
132
|
const isPreventCancel = isClickOnListContainer || isClickOnCommentEditorContainer || isClickResizeContainer || isSdocContentWrapper;
|
|
138
133
|
if (isPreventCancel) return;
|
|
139
134
|
}
|
|
140
|
-
setIsEditing && setIsEditing(false);
|
|
141
135
|
hiddenComment && hiddenComment(false);
|
|
142
136
|
if (onContentChange) {
|
|
143
137
|
if (editor.children.find(n => _slate.Node.string(n).trim())) {
|
|
@@ -147,15 +141,14 @@ const CommentEditor = _ref => {
|
|
|
147
141
|
}
|
|
148
142
|
}
|
|
149
143
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
150
|
-
}, [
|
|
144
|
+
}, []);
|
|
145
|
+
|
|
146
|
+
// set editor children
|
|
151
147
|
(0, _react.useEffect)(() => {
|
|
152
148
|
let children = (0, _mdToSlate.default)(content);
|
|
153
|
-
if (commentContent) {
|
|
154
|
-
children = (0, _mdToSlate.default)(commentContent);
|
|
155
|
-
}
|
|
156
149
|
editor.children = children;
|
|
157
150
|
_slate.Transforms.select(editor, _slate.Editor.end(editor, []));
|
|
158
|
-
}, [editor, content
|
|
151
|
+
}, [editor, content]);
|
|
159
152
|
|
|
160
153
|
// useMount: focus editor
|
|
161
154
|
(0, _react.useEffect)(() => {
|
|
@@ -225,6 +218,7 @@ const CommentEditor = _ref => {
|
|
|
225
218
|
}
|
|
226
219
|
eventProxy.onKeyDown(event);
|
|
227
220
|
}, [eventProxy, editor]);
|
|
221
|
+
console.log('toolMenus', toolMenus);
|
|
228
222
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
229
223
|
className: (0, _classnames.default)('comment-editor-wrapper', className),
|
|
230
224
|
ref: commentWrapperRef
|
|
@@ -239,7 +233,9 @@ const CommentEditor = _ref => {
|
|
|
239
233
|
width: "100%"
|
|
240
234
|
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
241
235
|
className: "comment-editor-user-name"
|
|
242
|
-
}, userInfo.name)), /*#__PURE__*/_react.default.createElement(
|
|
236
|
+
}, userInfo.name)), /*#__PURE__*/_react.default.createElement("div", {
|
|
237
|
+
className: "comment-editor-container"
|
|
238
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
243
239
|
className: "comment-editor-content"
|
|
244
240
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
245
241
|
ref: commentEditorContainerRef,
|
|
@@ -273,9 +269,12 @@ const CommentEditor = _ref => {
|
|
|
273
269
|
onBeforeInput: eventProxy.onBeforeInput
|
|
274
270
|
})))), /*#__PURE__*/_react.default.createElement(_commentEditorToolbar.default, {
|
|
275
271
|
editor: editor,
|
|
272
|
+
toolMenus: toolMenus,
|
|
276
273
|
onSubmit: onSubmit,
|
|
277
274
|
submitBtnText: t(submitTip),
|
|
278
275
|
onCancel: onCancel
|
|
279
|
-
}))))
|
|
276
|
+
}))), toolMenus.includes(_constants2.IMAGE) && /*#__PURE__*/_react.default.createElement(_insertElementDialog.default, {
|
|
277
|
+
editor: editor
|
|
278
|
+
}));
|
|
280
279
|
};
|
|
281
280
|
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,7 @@ const useUploadImage = _ref => {
|
|
|
42
42
|
const uploadCurrentImage = async () => {
|
|
43
43
|
try {
|
|
44
44
|
const fileItem = _imageCache.default.getImage(file_uuid);
|
|
45
|
-
const imageUrl = await _context.default.uploadLocalImage([fileItem]);
|
|
45
|
+
const imageUrl = await _context.default.api.uploadLocalImage([fileItem]);
|
|
46
46
|
if (imageUrl && imageUrl[0]) {
|
|
47
47
|
updateImageNode(editor, element, imageUrl[0]);
|
|
48
48
|
}
|
|
@@ -22,33 +22,37 @@ const CommentEditorToolbar = _ref => {
|
|
|
22
22
|
readonly = false,
|
|
23
23
|
onSubmit,
|
|
24
24
|
submitBtnText,
|
|
25
|
-
onCancel
|
|
25
|
+
onCancel,
|
|
26
|
+
toolMenus
|
|
26
27
|
} = _ref;
|
|
27
28
|
(0, _useSelectionUpdate.default)();
|
|
28
29
|
const eventBus = _eventBus.default.getInstance();
|
|
29
30
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
30
|
-
className: "comment-editor-toolbar"
|
|
31
|
-
|
|
31
|
+
className: "comment-editor-toolbar",
|
|
32
|
+
style: {
|
|
33
|
+
justifyContent: toolMenus.length === 0 ? 'end' : ''
|
|
34
|
+
}
|
|
35
|
+
}, toolMenus.length !== 0 && /*#__PURE__*/_react.default.createElement(_commons.MenuGroup, {
|
|
32
36
|
className: "menu-group comment-editor-menu-group"
|
|
33
|
-
}, /*#__PURE__*/_react.default.createElement(_comemntEditorMenu.default, {
|
|
37
|
+
}, toolMenus.includes('text_style') && /*#__PURE__*/_react.default.createElement(_comemntEditorMenu.default, {
|
|
34
38
|
editor: editor,
|
|
35
39
|
readonly: readonly
|
|
36
|
-
}), /*#__PURE__*/_react.default.createElement(_menu.default, {
|
|
40
|
+
}), toolMenus.includes(_constants.BLOCKQUOTE) && /*#__PURE__*/_react.default.createElement(_menu.default, {
|
|
37
41
|
editor: editor,
|
|
38
42
|
readonly: readonly
|
|
39
|
-
}), /*#__PURE__*/_react.default.createElement(_menu4.default, {
|
|
43
|
+
}), toolMenus.includes(_constants.UNORDERED_LIST) && /*#__PURE__*/_react.default.createElement(_menu4.default, {
|
|
40
44
|
editor: editor,
|
|
41
45
|
type: _constants.UNORDERED_LIST,
|
|
42
46
|
readonly: readonly
|
|
43
|
-
}), /*#__PURE__*/_react.default.createElement(_menu4.default, {
|
|
47
|
+
}), toolMenus.includes(_constants.ORDERED_LIST) && /*#__PURE__*/_react.default.createElement(_menu4.default, {
|
|
44
48
|
editor: editor,
|
|
45
49
|
type: _constants.ORDERED_LIST,
|
|
46
50
|
readonly: readonly
|
|
47
|
-
}), /*#__PURE__*/_react.default.createElement(_menu3.default, {
|
|
51
|
+
}), toolMenus.includes(_constants.LINK) && /*#__PURE__*/_react.default.createElement(_menu3.default, {
|
|
48
52
|
editor: editor,
|
|
49
53
|
readonly: readonly,
|
|
50
54
|
eventBus: eventBus
|
|
51
|
-
}), /*#__PURE__*/_react.default.createElement(_menu2.default, {
|
|
55
|
+
}), toolMenus.includes(_constants.IMAGE) && /*#__PURE__*/_react.default.createElement(_menu2.default, {
|
|
52
56
|
editor: editor,
|
|
53
57
|
readonly: readonly,
|
|
54
58
|
eventBus: eventBus
|