@seafile/sdoc-editor 1.0.44 → 1.0.46
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 +0 -41
- package/dist/basic-sdk/constants/index.js +0 -1
- package/dist/basic-sdk/outline/style.css +1 -1
- package/dist/components/doc-info/index.js +1 -2
- package/dist/components/doc-operations/collaborators-operation/index.js +1 -1
- package/dist/components/doc-operations/index.js +1 -2
- package/dist/components/doc-operations/revision-operations/more-revision-operations/index.css +3 -3
- package/dist/components/doc-operations/revision-operations/revisions/index.css +1 -1
- package/dist/components/doc-operations/style.css +12 -4
- package/dist/context.js +0 -31
- package/dist/pages/sdoc-wiki-editor.js +0 -4
- package/package.json +1 -1
- package/public/media/sdoc-editor-font/iconfont.eot +0 -0
- package/public/media/sdoc-editor-font/iconfont.svg +4 -4
- 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 +6 -6
- package/dist/components/doc-operations/tag-operation/constans.js +0 -2
- package/dist/components/doc-operations/tag-operation/file-tag-quick-view/index.css +0 -14
- package/dist/components/doc-operations/tag-operation/file-tag-quick-view/index.js +0 -58
- package/dist/components/doc-operations/tag-operation/index.js +0 -11
- package/dist/components/doc-operations/tag-operation/tag-popover/index.css +0 -72
- package/dist/components/doc-operations/tag-operation/tag-popover/index.js +0 -181
- package/dist/components/doc-operations/tag-operation/utils.js +0 -4
package/dist/api/seafile-api.js
CHANGED
|
@@ -151,47 +151,6 @@ class SeafileAPI {
|
|
|
151
151
|
return this.req.get(url);
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
// Operate file tags
|
|
155
|
-
getFileTagList(docUuid) {
|
|
156
|
-
const url = "/api/v2.1/seadoc/file-tags/".concat(docUuid, "/");
|
|
157
|
-
return this.req.get(url);
|
|
158
|
-
}
|
|
159
|
-
addFileTag(docUuid, repoTagID) {
|
|
160
|
-
const form = new FormData();
|
|
161
|
-
form.append('repo_tag_id', repoTagID);
|
|
162
|
-
const url = "/api/v2.1/seadoc/file-tags/".concat(docUuid, "/");
|
|
163
|
-
return this._sendPostRequest(url, form);
|
|
164
|
-
}
|
|
165
|
-
removeFileTag(docUuid, fileTagID) {
|
|
166
|
-
const url = "/api/v2.1/seadoc/file-tags/".concat(docUuid, "/").concat(fileTagID, "/");
|
|
167
|
-
return this.req.delete(url);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// Operate repository tags
|
|
171
|
-
getRepoTagList(docUuid) {
|
|
172
|
-
const url = "/api/v2.1/seadoc/repo-tags/".concat(docUuid, "/");
|
|
173
|
-
return this.req.get(url);
|
|
174
|
-
}
|
|
175
|
-
createRepoTag(docUuid, repoTagName, color) {
|
|
176
|
-
const url = "/api/v2.1/seadoc/repo-tags/".concat(docUuid, "/");
|
|
177
|
-
const form = new FormData();
|
|
178
|
-
form.append('name', repoTagName);
|
|
179
|
-
form.append('color', color);
|
|
180
|
-
return this._sendPostRequest(url, form);
|
|
181
|
-
}
|
|
182
|
-
removeRepoTag(docUuid, repoTagId) {
|
|
183
|
-
const url = "/api/v2.1/seadoc/repo-tags/".concat(docUuid, "/").concat(repoTagId, "/");
|
|
184
|
-
return this.req.delete(url);
|
|
185
|
-
}
|
|
186
|
-
updateRepoTag(docUuid, repoTagId, repoTagName, color) {
|
|
187
|
-
const url = "/api/v2.1/seadoc/repo-tags/".concat(docUuid, "/").concat(repoTagId, "/");
|
|
188
|
-
const params = {
|
|
189
|
-
name: repoTagName,
|
|
190
|
-
color
|
|
191
|
-
};
|
|
192
|
-
return this.req.put(url, params);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
154
|
// notification
|
|
196
155
|
listUnseenNotifications(docUuid) {
|
|
197
156
|
const url = "/api/v2.1/seadoc/notifications/".concat(docUuid, "/");
|
|
@@ -11,7 +11,6 @@ export const INTERNAL_EVENT = {
|
|
|
11
11
|
OUTLINE_STATE_CHANGED: 'outline_state_changed',
|
|
12
12
|
RELOAD_IMAGE: 'reload_image',
|
|
13
13
|
ARTICLE_CLICK: 'hidden_comment',
|
|
14
|
-
UPDATE_TAG_VIEW: 'update_tag_view',
|
|
15
14
|
COMMENT_LIST_CLICK: 'comment_list_click',
|
|
16
15
|
UNSEEN_NOTIFICATIONS_COUNT: 'unseen_notifications_count',
|
|
17
16
|
CLOSE_CALLOUT_COLOR_PICKER: 'close_callout_color_picker',
|
|
@@ -7,7 +7,6 @@ import { EXTERNAL_EVENT } from '../../constants';
|
|
|
7
7
|
import { DateUtils } from '../../utils';
|
|
8
8
|
import DraftDropdown from '../draft-dropdown';
|
|
9
9
|
import RevisionAvatar from '../../assets/images/revision-avatar.png';
|
|
10
|
-
import FileTagQuickView from '../doc-operations/tag-operation/file-tag-quick-view';
|
|
11
10
|
import freezedImg from '../../basic-sdk/assets/images/sdoc-freezed.png';
|
|
12
11
|
import './index.css';
|
|
13
12
|
const DocInfo = _ref => {
|
|
@@ -62,7 +61,7 @@ const DocInfo = _ref => {
|
|
|
62
61
|
alt: t('Document_frozen'),
|
|
63
62
|
title: t('Document_frozen'),
|
|
64
63
|
width: "16px"
|
|
65
|
-
})),
|
|
64
|
+
})), /*#__PURE__*/React.createElement(TipMessage, {
|
|
66
65
|
isEditMode: isEditMode
|
|
67
66
|
}));
|
|
68
67
|
if (!isSdocRevision) {
|
|
@@ -66,7 +66,7 @@ class CollaboratorsOperation extends React.PureComponent {
|
|
|
66
66
|
collaborators
|
|
67
67
|
} = this.state;
|
|
68
68
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
69
|
-
className: "op-item",
|
|
69
|
+
className: "op-item collaborators-op-item",
|
|
70
70
|
id: "collaborators"
|
|
71
71
|
}, /*#__PURE__*/React.createElement("i", {
|
|
72
72
|
className: "sdocfont sdoc-user mr-1"
|
|
@@ -6,7 +6,6 @@ import CollaboratorsOperation from './collaborators-operation';
|
|
|
6
6
|
import MoreOperations from './more-operations';
|
|
7
7
|
import CommentsOperation from './comments-operation';
|
|
8
8
|
import ShareOperation from './share-operation';
|
|
9
|
-
import TagOperation from './tag-operation';
|
|
10
9
|
import { isMobile } from '../../utils';
|
|
11
10
|
import './style.css';
|
|
12
11
|
const DocOperations = _ref => {
|
|
@@ -33,6 +32,6 @@ const DocOperations = _ref => {
|
|
|
33
32
|
handleViewChangesToggle: handleViewChangesToggle,
|
|
34
33
|
handleRevisionMerged: handleRevisionMerged,
|
|
35
34
|
handleRevisionPublished: handleRevisionPublished
|
|
36
|
-
}), !isPublished && /*#__PURE__*/React.createElement(
|
|
35
|
+
}), !isPublished && /*#__PURE__*/React.createElement(CommentsOperation, null), !isSdocRevision && /*#__PURE__*/React.createElement(ShareOperation, null), !isPublished && /*#__PURE__*/React.createElement(CollaboratorsOperation, null), !isSdocRevision && /*#__PURE__*/React.createElement(MoreOperations, null));
|
|
37
36
|
};
|
|
38
37
|
export default withTranslation('sdoc-editor')(DocOperations);
|
package/dist/components/doc-operations/revision-operations/more-revision-operations/index.css
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
.sdoc-more-revision-operations-dropdown .sdoc-more-revision-operations-toggle {
|
|
2
2
|
width: 66px;
|
|
3
|
-
height:
|
|
4
|
-
border-radius:
|
|
3
|
+
height: 28px;
|
|
4
|
+
border-radius: 14px;
|
|
5
5
|
background-color: #F0F0F0;
|
|
6
6
|
display: flex;
|
|
7
7
|
align-items: center;
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
.sdoc-more-revision-operations-dropdown .sdoc-more-revision-operations-toggle:hover {
|
|
13
13
|
cursor: pointer;
|
|
14
|
-
color: #
|
|
14
|
+
background-color: #E4E4E4;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
.sdoc-more-revision-operations-dropdown .sdoc-more-revision-operations-toggle .sdoc-revise {
|
|
@@ -4,21 +4,29 @@
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
.doc-ops .op-item {
|
|
7
|
-
margin-left:
|
|
7
|
+
margin-left: 10px;
|
|
8
8
|
display: flex;
|
|
9
9
|
align-items: center;
|
|
10
|
+
justify-content: center;
|
|
10
11
|
position: relative;
|
|
11
12
|
cursor: pointer;
|
|
13
|
+
width: 28px;
|
|
14
|
+
height: 28px;
|
|
15
|
+
border-radius: 3px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.doc-ops .collaborators-op-item {
|
|
19
|
+
margin-left: 14px;
|
|
12
20
|
}
|
|
13
21
|
|
|
14
22
|
.doc-ops .op-item .sdocfont {
|
|
15
|
-
font-size:
|
|
23
|
+
font-size: 16px;
|
|
16
24
|
color: #666;
|
|
17
25
|
cursor: pointer;
|
|
18
26
|
}
|
|
19
27
|
|
|
20
|
-
.doc-ops .op-item
|
|
21
|
-
color: #
|
|
28
|
+
.doc-ops .op-item:hover {
|
|
29
|
+
background-color: #EFEFEF;
|
|
22
30
|
cursor: pointer;
|
|
23
31
|
}
|
|
24
32
|
|
package/dist/context.js
CHANGED
|
@@ -225,37 +225,6 @@ class Context {
|
|
|
225
225
|
const docUuid = this.getSetting('docUuid');
|
|
226
226
|
return this.api.listRelatedUsers(docUuid);
|
|
227
227
|
}
|
|
228
|
-
// File tags
|
|
229
|
-
getFileTagList() {
|
|
230
|
-
const docUuid = this.getDocUuid();
|
|
231
|
-
return this.api.getFileTagList(docUuid);
|
|
232
|
-
}
|
|
233
|
-
addFileTag(repoTagID) {
|
|
234
|
-
const docUuid = this.getDocUuid();
|
|
235
|
-
return this.api.addFileTag(docUuid, repoTagID);
|
|
236
|
-
}
|
|
237
|
-
removeFileTag(fileTagID) {
|
|
238
|
-
const docUuid = this.getDocUuid();
|
|
239
|
-
return this.api.removeFileTag(docUuid, fileTagID);
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
// Repo tags
|
|
243
|
-
getRepoTagList() {
|
|
244
|
-
const docUuid = this.getDocUuid();
|
|
245
|
-
return this.api.getRepoTagList(docUuid);
|
|
246
|
-
}
|
|
247
|
-
createRepoTag(repoTagName, color) {
|
|
248
|
-
const docUuid = this.getDocUuid();
|
|
249
|
-
return this.api.createRepoTag(docUuid, repoTagName, color);
|
|
250
|
-
}
|
|
251
|
-
removeRepoTag(fileTagID) {
|
|
252
|
-
const docUuid = this.getDocUuid();
|
|
253
|
-
return this.api.removeRepoTag(docUuid, fileTagID);
|
|
254
|
-
}
|
|
255
|
-
updateRepoTag(repoTagId, repoTagName, color) {
|
|
256
|
-
const docUuid = this.getDocUuid();
|
|
257
|
-
return this.api.updateRepoTag(docUuid, repoTagId, repoTagName, color);
|
|
258
|
-
}
|
|
259
228
|
|
|
260
229
|
// notification
|
|
261
230
|
listUnseenNotifications() {
|
|
@@ -17,10 +17,6 @@ const SdocWikiEditor = _ref => {
|
|
|
17
17
|
scrollRef
|
|
18
18
|
} = _ref;
|
|
19
19
|
context.initApi();
|
|
20
|
-
|
|
21
|
-
// Wiki editor need filter initialized title node
|
|
22
|
-
const [firstNode, ...restNodes] = document.children;
|
|
23
|
-
if (firstNode.type === TITLE) document.children = restNodes;
|
|
24
20
|
const validEditor = useMemo(() => {
|
|
25
21
|
const defaultEditor = createWikiEditor();
|
|
26
22
|
// getEditorConfig cashe the config, so we need to update the uuid,for wiki editor
|
package/package.json
CHANGED
|
Binary file
|
|
@@ -212,11 +212,11 @@
|
|
|
212
212
|
|
|
213
213
|
<glyph glyph-name="sdoc-more-options" unicode="" d="M518.4 624C464 624 416 672 416 729.6S464 832 518.4 832s102.4-48 102.4-102.4-44.8-105.6-102.4-105.6z m0-342.4c-54.4 0-102.4 44.8-102.4 102.4s48 102.4 102.4 102.4 102.4-48 102.4-102.4-44.8-102.4-102.4-102.4z m0-345.6c-54.4 0-102.4 48-102.4 102.4s48 102.4 102.4 102.4 102.4-48 102.4-102.4S576-64 518.4-64z" horiz-adv-x="1024" />
|
|
214
214
|
|
|
215
|
-
<glyph glyph-name="sdoc-comments" unicode="" d="
|
|
215
|
+
<glyph glyph-name="sdoc-comments" unicode="" d="M928 864c35.2 0 64-28.8 64-64v-672c0-35.2-28.8-64-64-64h-166.4l-16-121.6c-3.2-16-12.8-28.8-25.6-35.2-6.4-3.2-9.6-3.2-16-3.2-9.6 0-19.2 3.2-28.8 9.6L505.6 64H96c-35.2 0-64 28.8-64 64V800c0 35.2 28.8 64 64 64h832z m-64-96H160c-19.2 0-32-12.8-32-32v-544c0-19.2 12.8-32 32-32h361.6c9.6 0 22.4-3.2 28.8-9.6l124.8-102.4 9.6 76.8c3.2 22.4 22.4 38.4 41.6 35.2H864c19.2 0 32 12.8 32 32V736c0 19.2-12.8 32-32 32z m-112-352c9.6 0 16-6.4 16-16v-64c0-9.6-6.4-16-16-16h-480c-9.6 0-16 6.4-16 16v64c0 9.6 6.4 16 16 16h480z m0 224c9.6 0 16-6.4 16-16v-64c0-9.6-6.4-16-16-16h-480c-9.6 0-16 6.4-16 16v64c0 9.6 6.4 16 16 16h480z" horiz-adv-x="1024" />
|
|
216
216
|
|
|
217
217
|
<glyph glyph-name="sdoc-right-slide" unicode="" d="M806.4 438.4L336 812.8c-54.4 44.8-144 9.6-144-54.4v-748.8c0-64 86.4-99.2 144-54.4l470.4 374.4c35.2 28.8 35.2 80 0 108.8z" horiz-adv-x="1024" />
|
|
218
218
|
|
|
219
|
-
<glyph glyph-name="sdoc-revise" unicode="" d="
|
|
219
|
+
<glyph glyph-name="sdoc-revise" unicode="" d="M752 0c25.6 0 48-22.4 48-48s-22.4-48-48-48h-320c-25.6 0-48 22.4-48 48s22.4 48 48 48h320z m44.8 841.6L928 710.4c32-32 32-83.2 0-112L336 0l-265.6-19.2 16 262.4L681.6 841.6c28.8 28.8 86.4 28.8 115.2 0z m-204.8-227.2L182.4 201.6l-6.4-115.2 118.4 9.6L704 505.6l-112 108.8z m147.2 147.2l-80-80 108.8-108.8 80 80-108.8 108.8z" horiz-adv-x="1024" />
|
|
220
220
|
|
|
221
221
|
<glyph glyph-name="sdoc-starred" unicode="" d="M995.2 412.8c54.4 54.4 25.6 153.6-51.2 163.2l-192 28.8c-28.8 3.2-57.6 25.6-70.4 54.4l-86.4 182.4C579.2 876.8 544 896 512 896s-67.2-19.2-83.2-54.4l-86.4-182.4c-12.8-28.8-38.4-48-70.4-51.2l-192-28.8C3.2 566.4-25.6 470.4 28.8 416l140.8-140.8c22.4-22.4 32-54.4 25.6-86.4l-32-201.6c-9.6-64 38.4-112 92.8-112 12.8 0 28.8 3.2 41.6 12.8l172.8 96c12.8 6.4 28.8 9.6 41.6 9.6 16 0 28.8-3.2 41.6-9.6l172.8-96c12.8-6.4 28.8-12.8 41.6-12.8 54.4 0 102.4 51.2 92.8 112l-32 201.6c-6.4 32 3.2 64 25.6 86.4l140.8 137.6z" horiz-adv-x="1024" />
|
|
222
222
|
|
|
@@ -240,11 +240,11 @@
|
|
|
240
240
|
|
|
241
241
|
<glyph glyph-name="sdoc-menu" unicode="" d="M64 137.6h896V0H64v137.6zM64 768h896v-137.6H64V768z m0-313.6h896v-137.6H64v137.6z" horiz-adv-x="1024" />
|
|
242
242
|
|
|
243
|
-
<glyph glyph-name="sdoc-share" unicode="" d="
|
|
243
|
+
<glyph glyph-name="sdoc-share" unicode="" d="M800 832c-70.4 0-128-54.4-128-128s57.6-128 128-128 128 54.4 128 128-57.6 128-128 128zM224 512c-70.4 0-128-54.4-128-128s57.6-128 128-128 128 54.4 128 128-57.6 128-128 128z m576-320c-70.4 0-128-54.4-128-128s57.6-128 128-128 128 54.4 128 128-60.8 128-128 128zM374.4 531.2l217.6 134.4L640 582.4 422.4 448l-48 83.2z m32-192l246.4-147.2-48-83.2-246.4 147.2 48 83.2z" horiz-adv-x="1024" />
|
|
244
244
|
|
|
245
245
|
<glyph glyph-name="sdoc-table-of-content" unicode="" d="M64 800h512c35.2 0 64-28.8 64-64s-28.8-64-64-64H64C28.8 672 0 700.8 0 736s28.8 64 64 64z m934.4-444.8l-12.8-12.8-172.8-172.8c-25.6-25.6-64-25.6-89.6 0-25.6 25.6-25.6 64 0 89.6l134.4 134.4-134.4 134.4c-25.6 25.6-25.6 64 0 89.6 25.6 25.6 64 25.6 89.6 0l172.8-172.8 9.6-9.6c12.8-12.8 19.2-25.6 19.2-41.6v-3.2c0-12.8-9.6-28.8-16-35.2zM64 448h800c35.2 0 64-28.8 64-64s-28.8-64-64-64H64c-35.2 0-64 28.8-64 64s28.8 64 64 64z m0-352h512c35.2 0 64-28.8 64-64s-28.8-64-64-64H64c-35.2 0-64 28.8-64 64s28.8 64 64 64z" horiz-adv-x="1024" />
|
|
246
246
|
|
|
247
|
-
<glyph glyph-name="sdoc-user" unicode="" d="
|
|
247
|
+
<glyph glyph-name="sdoc-user" unicode="" d="M825.6 0H195.2c-32 0-60.8 32-44.8 64 60.8 140.8 198.4 224 361.6 224s304-80 361.6-224c12.8-32-12.8-64-48-64M316.8 576c0 105.6 86.4 192 195.2 192s195.2-86.4 195.2-192-86.4-192-195.2-192-195.2 86.4-195.2 192m672-556.8c-35.2 163.2-147.2 278.4-294.4 332.8 76.8 60.8 121.6 160 105.6 268.8-19.2 124.8-124.8 227.2-256 240C368 883.2 214.4 745.6 214.4 576c0-89.6 41.6-169.6 112-224-144-54.4-256-169.6-291.2-332.8-12.8-60.8 35.2-115.2 96-115.2h761.6c64 0 112 54.4 96 115.2" horiz-adv-x="1024" />
|
|
248
248
|
|
|
249
249
|
</font>
|
|
250
250
|
</defs>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
@font-face {
|
|
2
2
|
font-family: "sdocfont"; /* Project id 4097705 */
|
|
3
|
-
src: url('./sdoc-editor-font/iconfont.eot?t=
|
|
4
|
-
src: url('./sdoc-editor-font/iconfont.eot?t=
|
|
5
|
-
url('./sdoc-editor-font/iconfont.woff2?t=
|
|
6
|
-
url('./sdoc-editor-font/iconfont.woff?t=
|
|
7
|
-
url('./sdoc-editor-font/iconfont.ttf?t=
|
|
8
|
-
url('./sdoc-editor-font/iconfont.svg?t=
|
|
3
|
+
src: url('./sdoc-editor-font/iconfont.eot?t=1722915152576'); /* IE9 */
|
|
4
|
+
src: url('./sdoc-editor-font/iconfont.eot?t=1722915152576#iefix') format('embedded-opentype'), /* IE6-IE8 */
|
|
5
|
+
url('./sdoc-editor-font/iconfont.woff2?t=1722915152576') format('woff2'),
|
|
6
|
+
url('./sdoc-editor-font/iconfont.woff?t=1722915152576') format('woff'),
|
|
7
|
+
url('./sdoc-editor-font/iconfont.ttf?t=1722915152576') format('truetype'),
|
|
8
|
+
url('./sdoc-editor-font/iconfont.svg?t=1722915152576#sdocfont') format('svg');
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
.sdocfont {
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
.sdoc-file-tag-quick-review-container {
|
|
2
|
-
display: flex;
|
|
3
|
-
margin-left: 0.5rem;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
.sdoc-file-tag-quick-review-container .sdoc-review-circle {
|
|
7
|
-
display: inline-block;
|
|
8
|
-
height: 1rem;
|
|
9
|
-
width: 1rem;
|
|
10
|
-
margin-right: -0.5rem;
|
|
11
|
-
border: 0.125rem solid #fff;
|
|
12
|
-
border-radius: 50%;
|
|
13
|
-
cursor: pointer;
|
|
14
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import React, { useCallback, useEffect, useState, Fragment } from 'react';
|
|
2
|
-
import context from '../../../../context';
|
|
3
|
-
import Tooltip from '../../../tooltip';
|
|
4
|
-
import { EventBus } from '../../../../basic-sdk';
|
|
5
|
-
import { INTERNAL_EVENT } from '../../../../basic-sdk/constants';
|
|
6
|
-
import './index.css';
|
|
7
|
-
const FileTagQuickView = () => {
|
|
8
|
-
const [fileTagList, setFileTagList] = useState([]);
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
getTagList();
|
|
11
|
-
const eventBus = EventBus.getInstance();
|
|
12
|
-
const unsubscribe = eventBus.subscribe(INTERNAL_EVENT.UPDATE_TAG_VIEW, getTagList);
|
|
13
|
-
return () => {
|
|
14
|
-
unsubscribe();
|
|
15
|
-
};
|
|
16
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
17
|
-
}, []);
|
|
18
|
-
const getTagList = useCallback(async () => {
|
|
19
|
-
try {
|
|
20
|
-
const {
|
|
21
|
-
data: {
|
|
22
|
-
file_tags
|
|
23
|
-
}
|
|
24
|
-
} = await context.getFileTagList();
|
|
25
|
-
setFileTagList(file_tags);
|
|
26
|
-
} catch (error) {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
}, []);
|
|
30
|
-
|
|
31
|
-
// Render nothing if there is no tag
|
|
32
|
-
if (fileTagList.length === 0) return null;
|
|
33
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
34
|
-
className: "sdoc-file-tag-quick-review-container"
|
|
35
|
-
}, fileTagList.map((tag, index) => {
|
|
36
|
-
const {
|
|
37
|
-
file_tag_id,
|
|
38
|
-
tag_color,
|
|
39
|
-
tag_name
|
|
40
|
-
} = tag;
|
|
41
|
-
// Id cannot start with number
|
|
42
|
-
const tagId = "tag".concat(file_tag_id);
|
|
43
|
-
const tagZindex = fileTagList.length - index;
|
|
44
|
-
return /*#__PURE__*/React.createElement(Fragment, {
|
|
45
|
-
key: tagId
|
|
46
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
47
|
-
id: tagId,
|
|
48
|
-
style: {
|
|
49
|
-
backgroundColor: tag_color,
|
|
50
|
-
zIndex: tagZindex
|
|
51
|
-
},
|
|
52
|
-
className: "sdoc-review-circle"
|
|
53
|
-
}), /*#__PURE__*/React.createElement(Tooltip, {
|
|
54
|
-
target: tagId
|
|
55
|
-
}, tag_name));
|
|
56
|
-
}));
|
|
57
|
-
};
|
|
58
|
-
export default FileTagQuickView;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import TagPopover from './tag-popover';
|
|
3
|
-
const TagOperation = () => {
|
|
4
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
5
|
-
className: "op-item tag-operation-icon",
|
|
6
|
-
id: "tag-operation-icon-container"
|
|
7
|
-
}, /*#__PURE__*/React.createElement("i", {
|
|
8
|
-
className: "sdocfont sdoc-tag"
|
|
9
|
-
})), /*#__PURE__*/React.createElement(TagPopover, null));
|
|
10
|
-
};
|
|
11
|
-
export default TagOperation;
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
.sdoc-tag-popover {
|
|
2
|
-
padding-bottom: 0;
|
|
3
|
-
width: 230px;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
.sdoc-popover-container .sdoc-tag-search-input {
|
|
7
|
-
margin-bottom: 10px;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
.sdoc-popover-container .sdoc-tag-list-container {
|
|
11
|
-
max-height: 180px;
|
|
12
|
-
overflow-y: auto;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.sdoc-tag-item {
|
|
16
|
-
display: flex;
|
|
17
|
-
justify-content: space-between;
|
|
18
|
-
align-items: center;
|
|
19
|
-
padding: 3px 10px;
|
|
20
|
-
width: 100%;
|
|
21
|
-
height: 30px;
|
|
22
|
-
cursor: pointer;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.sdoc-tag-item:hover {
|
|
26
|
-
background-color: #eee;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.sdoc-tag-item .sdoc-tag-badge-container {
|
|
30
|
-
display: flex;
|
|
31
|
-
align-items: center;
|
|
32
|
-
width: 100%;
|
|
33
|
-
height: 100%;
|
|
34
|
-
overflow: hidden;
|
|
35
|
-
text-overflow: ellipsis;
|
|
36
|
-
white-space: nowrap;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.sdoc-tag-item .sdoc-tag-badge {
|
|
40
|
-
margin-right: 10px;
|
|
41
|
-
text-overflow: ellipsis;
|
|
42
|
-
overflow: hidden;
|
|
43
|
-
font-size: 13px;
|
|
44
|
-
font-weight: normal;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.sdoc-tag-item .sdoc-tag-added-mark {
|
|
48
|
-
width: 18px;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.sdoc-create-tag {
|
|
52
|
-
padding: 8px 10px;
|
|
53
|
-
border-top: 1px solid #eee;
|
|
54
|
-
border-bottom: none;
|
|
55
|
-
overflow: hidden;
|
|
56
|
-
font-size: 14px;
|
|
57
|
-
white-space: nowrap;
|
|
58
|
-
font-weight: normal;
|
|
59
|
-
text-overflow: ellipsis;
|
|
60
|
-
background-color: #fff;
|
|
61
|
-
cursor: pointer;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
.sdoc-create-tag:hover {
|
|
65
|
-
background-color: #f5f5f5;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
.sdoc-create-tag .add-icon {
|
|
69
|
-
margin-right: 6px;
|
|
70
|
-
font-size: 13px;
|
|
71
|
-
font-weight: 600;
|
|
72
|
-
}
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
-
import { Badge, Input, PopoverBody, PopoverHeader, UncontrolledPopover } from 'reactstrap';
|
|
3
|
-
import { useTranslation } from 'react-i18next';
|
|
4
|
-
import context from '../../../../context';
|
|
5
|
-
import { getErrorMsg } from '../../../../utils';
|
|
6
|
-
import toaster from '../../../toast';
|
|
7
|
-
import { generateTagColor, removeForwardSpace } from '../utils';
|
|
8
|
-
import { EventBus } from '../../../../basic-sdk';
|
|
9
|
-
import { INTERNAL_EVENT } from '../../../../basic-sdk/constants';
|
|
10
|
-
import './index.css';
|
|
11
|
-
const TagPopover = () => {
|
|
12
|
-
const [searchContent, setSearchContent] = useState('');
|
|
13
|
-
const [tagList, setTagList] = useState([]);
|
|
14
|
-
const tagListRef = useRef([]);
|
|
15
|
-
const {
|
|
16
|
-
t
|
|
17
|
-
} = useTranslation();
|
|
18
|
-
|
|
19
|
-
// Update tag view when tag is added or removed
|
|
20
|
-
const updateTagView = useCallback(() => {
|
|
21
|
-
const eventBus = EventBus.getInstance();
|
|
22
|
-
eventBus.dispatch(INTERNAL_EVENT.UPDATE_TAG_VIEW);
|
|
23
|
-
}, []);
|
|
24
|
-
const isShowCreateTag = useMemo(() => {
|
|
25
|
-
const isInputTag = !!searchContent.length;
|
|
26
|
-
const isMathExistTag = tagList.some(item => item.tag_name === searchContent);
|
|
27
|
-
return isInputTag && !isMathExistTag;
|
|
28
|
-
}, [searchContent, tagList]);
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
getTagList();
|
|
31
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
32
|
-
}, []);
|
|
33
|
-
const getFileTagList = useCallback(async () => {
|
|
34
|
-
try {
|
|
35
|
-
const {
|
|
36
|
-
data: {
|
|
37
|
-
file_tags
|
|
38
|
-
}
|
|
39
|
-
} = await context.getFileTagList();
|
|
40
|
-
return file_tags;
|
|
41
|
-
} catch (error) {
|
|
42
|
-
const errorMessage = getErrorMsg(error);
|
|
43
|
-
toaster.danger(t(errorMessage));
|
|
44
|
-
}
|
|
45
|
-
}, [t]);
|
|
46
|
-
|
|
47
|
-
// Get tag list and set fil_tag_id property when tag is attached on file
|
|
48
|
-
const getTagList = useCallback(async () => {
|
|
49
|
-
try {
|
|
50
|
-
const {
|
|
51
|
-
data: {
|
|
52
|
-
repo_tags
|
|
53
|
-
}
|
|
54
|
-
} = await context.getRepoTagList();
|
|
55
|
-
const fileTagList = await getFileTagList();
|
|
56
|
-
// Add file_tag_id property to tag,to mark which tag is added on file
|
|
57
|
-
repo_tags.forEach(item => {
|
|
58
|
-
var _matchFileTag$file_ta;
|
|
59
|
-
const matchFileTag = fileTagList.find(fileTag => fileTag.repo_tag_id === item.repo_tag_id);
|
|
60
|
-
item.file_tag_id = (_matchFileTag$file_ta = matchFileTag === null || matchFileTag === void 0 ? void 0 : matchFileTag.file_tag_id) !== null && _matchFileTag$file_ta !== void 0 ? _matchFileTag$file_ta : null;
|
|
61
|
-
});
|
|
62
|
-
setTagList(repo_tags);
|
|
63
|
-
tagListRef.current = repo_tags;
|
|
64
|
-
} catch (error) {
|
|
65
|
-
const errorMessage = getErrorMsg(error);
|
|
66
|
-
toaster.danger(t(errorMessage));
|
|
67
|
-
}
|
|
68
|
-
}, [getFileTagList, t]);
|
|
69
|
-
|
|
70
|
-
// Create tag and add tag on file,then update tag list and clean search content
|
|
71
|
-
// Note: Here we remove the spaces at the beginning and end of the string
|
|
72
|
-
const handleCreateTag = useCallback(async () => {
|
|
73
|
-
try {
|
|
74
|
-
const tagColor = generateTagColor();
|
|
75
|
-
const {
|
|
76
|
-
data: {
|
|
77
|
-
repo_tag
|
|
78
|
-
}
|
|
79
|
-
} = await context.createRepoTag(searchContent.trim(), tagColor);
|
|
80
|
-
await context.addFileTag(repo_tag.repo_tag_id);
|
|
81
|
-
getTagList();
|
|
82
|
-
setSearchContent('');
|
|
83
|
-
updateTagView();
|
|
84
|
-
} catch (error) {
|
|
85
|
-
const errorMessage = getErrorMsg(error);
|
|
86
|
-
toaster.danger(t(errorMessage));
|
|
87
|
-
}
|
|
88
|
-
}, [getTagList, searchContent, updateTagView, t]);
|
|
89
|
-
const matchTag = useCallback(matchText => {
|
|
90
|
-
if (matchText.length) {
|
|
91
|
-
const filterTagList = tagListRef.current.filter(_ref => {
|
|
92
|
-
let {
|
|
93
|
-
tag_name
|
|
94
|
-
} = _ref;
|
|
95
|
-
return tag_name.indexOf(matchText) !== -1;
|
|
96
|
-
});
|
|
97
|
-
setTagList(filterTagList);
|
|
98
|
-
} else {
|
|
99
|
-
setTagList(tagListRef.current);
|
|
100
|
-
}
|
|
101
|
-
}, []);
|
|
102
|
-
|
|
103
|
-
// Handle input change and match tag showing in popover
|
|
104
|
-
// Note: The input value is not allowed to start with a space,but it can contain spaces in the middle or at the end
|
|
105
|
-
const handleInputChange = useCallback(e => {
|
|
106
|
-
const text = e.target.value ??= '';
|
|
107
|
-
const inputText = removeForwardSpace(text).slice(0, 100);
|
|
108
|
-
matchTag(inputText);
|
|
109
|
-
setSearchContent(inputText);
|
|
110
|
-
}, [matchTag]);
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* @param {string} repoTagID
|
|
114
|
-
* @param {number | null} file_tag_id
|
|
115
|
-
*/
|
|
116
|
-
const handleClickTag = useCallback(async (repoTagID, file_tag_id) => {
|
|
117
|
-
try {
|
|
118
|
-
file_tag_id !== null ? await context.removeFileTag(file_tag_id) : await context.addFileTag(repoTagID);
|
|
119
|
-
getTagList();
|
|
120
|
-
updateTagView();
|
|
121
|
-
} catch (error) {
|
|
122
|
-
const errorMessage = getErrorMsg(error);
|
|
123
|
-
toaster.danger(t(errorMessage));
|
|
124
|
-
}
|
|
125
|
-
}, [getTagList, updateTagView, t]);
|
|
126
|
-
return /*#__PURE__*/React.createElement(UncontrolledPopover, {
|
|
127
|
-
target: "tag-operation-icon-container",
|
|
128
|
-
placement: "bottom",
|
|
129
|
-
popperClassName: "sdoc-menu-popover sdoc-dropdown-menu sdoc-tag-popover",
|
|
130
|
-
trigger: "legacy",
|
|
131
|
-
hideArrow: true,
|
|
132
|
-
fade: false,
|
|
133
|
-
security: "fixed"
|
|
134
|
-
}, /*#__PURE__*/React.createElement(PopoverBody, {
|
|
135
|
-
className: "sdoc-popover-container"
|
|
136
|
-
}, /*#__PURE__*/React.createElement(Input, {
|
|
137
|
-
value: searchContent,
|
|
138
|
-
onChange: handleInputChange,
|
|
139
|
-
placeholder: t('Find_an_option'),
|
|
140
|
-
maxLength: 100,
|
|
141
|
-
className: "sdoc-tag-search-input",
|
|
142
|
-
bsSize: "sm",
|
|
143
|
-
autoFocus: true
|
|
144
|
-
}), /*#__PURE__*/React.createElement("div", {
|
|
145
|
-
className: "sdoc-tag-list-container"
|
|
146
|
-
}, tagList.length ? tagList.map(item => /*#__PURE__*/React.createElement(TagItem, Object.assign({
|
|
147
|
-
key: item.repo_tag_id,
|
|
148
|
-
handleClickTag: handleClickTag
|
|
149
|
-
}, item))) : /*#__PURE__*/React.createElement("span", null, t('No_options_available')))), isShowCreateTag && /*#__PURE__*/React.createElement(PopoverHeader, {
|
|
150
|
-
className: "sdoc-create-tag",
|
|
151
|
-
onClick: handleCreateTag
|
|
152
|
-
}, /*#__PURE__*/React.createElement("i", {
|
|
153
|
-
className: "sdocfont sdoc-append add-icon"
|
|
154
|
-
}), "".concat(t('Add_option'), " '").concat(searchContent, "'")));
|
|
155
|
-
};
|
|
156
|
-
export default TagPopover;
|
|
157
|
-
const TagItem = _ref2 => {
|
|
158
|
-
let {
|
|
159
|
-
repo_tag_id,
|
|
160
|
-
tag_color,
|
|
161
|
-
tag_name,
|
|
162
|
-
handleClickTag,
|
|
163
|
-
file_tag_id
|
|
164
|
-
} = _ref2;
|
|
165
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
166
|
-
className: "sdoc-tag-item",
|
|
167
|
-
onClick: () => handleClickTag(repo_tag_id, file_tag_id)
|
|
168
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
169
|
-
className: "sdoc-tag-badge-container"
|
|
170
|
-
}, /*#__PURE__*/React.createElement(Badge, {
|
|
171
|
-
style: {
|
|
172
|
-
backgroundColor: tag_color
|
|
173
|
-
},
|
|
174
|
-
className: "sdoc-tag-badge",
|
|
175
|
-
pill: true
|
|
176
|
-
}, tag_name)), /*#__PURE__*/React.createElement("div", {
|
|
177
|
-
className: "sdoc-tag-added-mark"
|
|
178
|
-
}, file_tag_id !== null && /*#__PURE__*/React.createElement("i", {
|
|
179
|
-
className: "sdocfont sdoc-check-mark"
|
|
180
|
-
})));
|
|
181
|
-
};
|