@seafile/sdoc-editor 1.0.170 → 1.0.172-alpha-3
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 +2 -2
- package/dist/basic-sdk/extension/commons/file-insert-dialog/index.js +50 -48
- package/dist/basic-sdk/extension/commons/file-insert-dialog/style.css +20 -8
- package/dist/basic-sdk/extension/commons/insert-element-dialog/index.js +15 -6
- package/dist/basic-sdk/extension/commons/select-file-dialog/index.css +68 -0
- package/dist/basic-sdk/extension/commons/select-file-dialog/index.js +63 -2
- package/dist/basic-sdk/extension/commons/select-file-dialog/local-files/index.js +21 -4
- package/dist/basic-sdk/extension/commons/wiki-file-insert-dialog/index.js +274 -0
- package/dist/basic-sdk/extension/commons/wiki-file-insert-dialog/style.css +116 -0
- package/dist/basic-sdk/extension/plugins/file-link/helpers.js +1 -1
- package/dist/basic-sdk/extension/plugins/header/helpers.js +17 -1
- package/dist/basic-sdk/extension/plugins/quick-insert/helper.js +13 -2
- package/dist/basic-sdk/extension/plugins/quick-insert/render-elem.js +4 -3
- package/dist/basic-sdk/extension/plugins/sdoc-link/helpers.js +26 -1
- package/dist/basic-sdk/extension/plugins/sdoc-link/render/render-elem.js +10 -2
- package/dist/basic-sdk/extension/plugins/wiki-link/helpers.js +11 -9
- package/dist/context.js +4 -0
- package/dist/utils/index.js +20 -2
- package/package.json +1 -1
- package/public/locales/cs/sdoc-editor.json +4 -1
- package/public/locales/de/sdoc-editor.json +4 -1
- package/public/locales/en/sdoc-editor.json +4 -1
- package/public/locales/es/sdoc-editor.json +4 -1
- package/public/locales/es_AR/sdoc-editor.json +4 -1
- package/public/locales/es_MX/sdoc-editor.json +4 -1
- package/public/locales/fr/sdoc-editor.json +4 -1
- package/public/locales/it/sdoc-editor.json +4 -1
- package/public/locales/ru/sdoc-editor.json +4 -1
- package/public/locales/zh_CN/sdoc-editor.json +5 -2
package/dist/api/seafile-api.js
CHANGED
|
@@ -142,8 +142,8 @@ class SeafileAPI {
|
|
|
142
142
|
const url = 'api/v2.1/seadoc/query-copy-move-progress/' + docUuid + '/?&doc_uuid=' + docUuid + '&task_id=' + taskId;
|
|
143
143
|
return this.req.get(url);
|
|
144
144
|
}
|
|
145
|
-
|
|
146
|
-
const url = 'api/v2.1/seadoc/search-filename/' + docUuid + '/?query=' + query + '&page=' + page + '&per_page=' + per_page;
|
|
145
|
+
searchFilesByFilename(docUuid, query, page, per_page, search_type) {
|
|
146
|
+
const url = 'api/v2.1/seadoc/search-filename/' + docUuid + '/?query=' + query + '&page=' + page + '&per_page=' + per_page + '&search_type=' + search_type;
|
|
147
147
|
return this.req.get(url);
|
|
148
148
|
}
|
|
149
149
|
|
|
@@ -19,7 +19,6 @@ var _constants2 = require("../../../constants");
|
|
|
19
19
|
var _constants3 = require("../../constants");
|
|
20
20
|
var _toast = _interopRequireDefault(require("../../../../components/toast"));
|
|
21
21
|
var _helpers = require("../../plugins/sdoc-link/helpers");
|
|
22
|
-
var _helpers2 = require("../../plugins/wiki-link/helpers");
|
|
23
22
|
require("./style.css");
|
|
24
23
|
const FileLinkInsertDialog = _ref => {
|
|
25
24
|
let {
|
|
@@ -27,6 +26,11 @@ const FileLinkInsertDialog = _ref => {
|
|
|
27
26
|
element,
|
|
28
27
|
closeDialog
|
|
29
28
|
} = _ref;
|
|
29
|
+
const {
|
|
30
|
+
t
|
|
31
|
+
} = (0, _reactI18next.useTranslation)();
|
|
32
|
+
const eventBus = _eventBus.default.getInstance();
|
|
33
|
+
const fileLinkInsertRef = (0, _react.useRef)(null);
|
|
30
34
|
const historyFileWrapperRef = (0, _react.useRef)(document.querySelector('.sdoc-history-files-wrapper'));
|
|
31
35
|
const [files, setFiles] = (0, _react.useState)([]);
|
|
32
36
|
const [position, setPosition] = (0, _react.useState)({
|
|
@@ -34,18 +38,14 @@ const FileLinkInsertDialog = _ref => {
|
|
|
34
38
|
left: 0
|
|
35
39
|
});
|
|
36
40
|
const [newFileName, setNewFileName] = (0, _react.useState)('');
|
|
37
|
-
const {
|
|
38
|
-
t
|
|
39
|
-
} = (0, _reactI18next.useTranslation)();
|
|
40
41
|
const [header, setHeader] = (0, _react.useState)(t('Recent_visited'));
|
|
41
|
-
const eventBus = _eventBus.default.getInstance();
|
|
42
42
|
const deleteInputAndInsertText = (0, _react.useCallback)(function () {
|
|
43
43
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
44
44
|
args[_key] = arguments[_key];
|
|
45
45
|
}
|
|
46
46
|
return (0, _helpers.insertTextWhenRemoveFileNameCollector)(editor, element, ...args);
|
|
47
47
|
}, [editor, element]);
|
|
48
|
-
const getPosition = (0, _react.useCallback)(
|
|
48
|
+
const getPosition = (0, _react.useCallback)(e => {
|
|
49
49
|
const {
|
|
50
50
|
selection
|
|
51
51
|
} = editor;
|
|
@@ -60,6 +60,7 @@ const FileLinkInsertDialog = _ref => {
|
|
|
60
60
|
} = domNode.getBoundingClientRect();
|
|
61
61
|
let popoverTop = top + topGap;
|
|
62
62
|
let popoverLeft = left + leftGap;
|
|
63
|
+
|
|
63
64
|
// Insert gap between the popover and the selected node
|
|
64
65
|
// file item height 32px, header height 32px, add button height 32px, margin-top 8px, max-height 306px
|
|
65
66
|
const popoverHeight = Math.min(files.length * 32 + 32 * 3 + 8, 300);
|
|
@@ -71,17 +72,6 @@ const FileLinkInsertDialog = _ref => {
|
|
|
71
72
|
const counterTopGap = 8;
|
|
72
73
|
popoverTop = top - popoverHeight - counterTopGap;
|
|
73
74
|
}
|
|
74
|
-
if (editor.editorType === _constants2.WIKI_EDITOR) {
|
|
75
|
-
const wikiEditorContainer = document.querySelector('.sdoc-editor-container');
|
|
76
|
-
if (wikiEditorContainer) {
|
|
77
|
-
const {
|
|
78
|
-
left,
|
|
79
|
-
top
|
|
80
|
-
} = wikiEditorContainer.getBoundingClientRect();
|
|
81
|
-
popoverLeft -= left;
|
|
82
|
-
popoverTop -= top;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
75
|
setPosition({
|
|
86
76
|
top: popoverTop,
|
|
87
77
|
left: popoverLeft
|
|
@@ -93,20 +83,30 @@ const FileLinkInsertDialog = _ref => {
|
|
|
93
83
|
var _historyFileWrapperRe, _historyFileWrapperRe2;
|
|
94
84
|
const isClickInside = (_historyFileWrapperRe = historyFileWrapperRef.current) === null || _historyFileWrapperRe === void 0 ? void 0 : (_historyFileWrapperRe2 = _historyFileWrapperRe.contains) === null || _historyFileWrapperRe2 === void 0 ? void 0 : _historyFileWrapperRe2.call(_historyFileWrapperRe, e.target);
|
|
95
85
|
if (isClickInside) return;
|
|
86
|
+
|
|
87
|
+
// Click on the insertion position without closing
|
|
88
|
+
const insertCollectorEl = document.querySelector('.sdoc-file-name-insert-collector');
|
|
89
|
+
if (insertCollectorEl && insertCollectorEl.className === e.target.className) return;
|
|
96
90
|
deleteInputAndInsertText();
|
|
97
91
|
closeDialog();
|
|
98
92
|
}, [closeDialog, deleteInputAndInsertText]);
|
|
99
93
|
const onScroll = (0, _react.useCallback)(e => {
|
|
100
|
-
getPosition();
|
|
94
|
+
getPosition(e);
|
|
101
95
|
}, [getPosition]);
|
|
102
|
-
const getHistoryFiles = (0, _react.useCallback)(
|
|
103
|
-
const getItemKey =
|
|
104
|
-
|
|
96
|
+
const getHistoryFiles = (0, _react.useCallback)(isCalculatedByFiles => {
|
|
97
|
+
const getItemKey = 'sdoc-recent-files';
|
|
98
|
+
let files = _utils.LocalStorage.getItem(getItemKey) || [];
|
|
99
|
+
if (isCalculatedByFiles) {
|
|
100
|
+
const newFiles = (0, _utils.getMaximumCapacity)(files);
|
|
101
|
+
files = newFiles;
|
|
102
|
+
}
|
|
105
103
|
setFiles(files);
|
|
106
|
-
}, [
|
|
104
|
+
}, []);
|
|
107
105
|
(0, _react.useEffect)(() => {
|
|
106
|
+
fileLinkInsertRef.current['isFirstMount'] = true;
|
|
108
107
|
getHistoryFiles();
|
|
109
|
-
|
|
108
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
109
|
+
}, []);
|
|
110
110
|
const onKeydown = (0, _react.useCallback)(e => {
|
|
111
111
|
const {
|
|
112
112
|
key
|
|
@@ -182,23 +182,22 @@ const FileLinkInsertDialog = _ref => {
|
|
|
182
182
|
}, []);
|
|
183
183
|
(0, _react.useEffect)(() => {
|
|
184
184
|
if (!(element !== null && element !== void 0 && element.children)) return;
|
|
185
|
+
// No search on first load
|
|
186
|
+
if (fileLinkInsertRef.current['isFirstMount']) {
|
|
187
|
+
fileLinkInsertRef.current['isFirstMount'] = false;
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
185
190
|
const searchText = _slate.Node.string(element);
|
|
186
191
|
onSearch(searchText);
|
|
187
192
|
}, [element, onSearch]);
|
|
188
193
|
const onSelect = (0, _react.useCallback)(fileInfo => {
|
|
189
194
|
const {
|
|
190
195
|
doc_uuid,
|
|
191
|
-
name
|
|
192
|
-
wikiRepoId,
|
|
193
|
-
pageId
|
|
196
|
+
name
|
|
194
197
|
} = fileInfo;
|
|
195
198
|
(0, _helpers.removeTempInput)(editor, element);
|
|
196
199
|
closeDialog();
|
|
197
|
-
|
|
198
|
-
(0, _helpers2.insertWikiPageLink)(editor, name, wikiRepoId, pageId);
|
|
199
|
-
} else {
|
|
200
|
-
(0, _helpers.insertSdocFileLink)(editor, name, doc_uuid);
|
|
201
|
-
}
|
|
200
|
+
(0, _helpers.insertSdocFileLink)(editor, name, doc_uuid);
|
|
202
201
|
}, [closeDialog, editor, element]);
|
|
203
202
|
const onShowMore = (0, _react.useCallback)(() => {
|
|
204
203
|
eventBus.dispatch(_constants2.INTERNAL_EVENT.INSERT_ELEMENT, {
|
|
@@ -211,26 +210,27 @@ const FileLinkInsertDialog = _ref => {
|
|
|
211
210
|
e.stopPropagation();
|
|
212
211
|
(0, _helpers.removeTempInput)(editor, element);
|
|
213
212
|
const eventBus = _eventBus.default.getInstance();
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
newFileName: newFileName.trim(),
|
|
213
|
+
const createName = newFileName.trim() || t('Create_a_new_sdoc_file');
|
|
214
|
+
const external_props = {
|
|
215
|
+
insertSdocFileLink: _helpers.insertSdocFileLink,
|
|
216
|
+
editor
|
|
217
|
+
};
|
|
218
|
+
console.log(1, createName, external_props);
|
|
219
|
+
// debugger;
|
|
220
|
+
eventBus.dispatch(_constants.EXTERNAL_EVENT.CREATE_SDOC_FILE, {
|
|
221
|
+
newFileName: createName,
|
|
224
222
|
...external_props
|
|
225
223
|
});
|
|
226
224
|
}, [editor, element, newFileName]);
|
|
227
225
|
const createFileTipDefault = (0, _react.useMemo)(() => {
|
|
228
|
-
|
|
229
|
-
|
|
226
|
+
console.log(444);
|
|
227
|
+
return 'Create_a_new_sdoc_file';
|
|
228
|
+
}, []);
|
|
230
229
|
const createFileName = (0, _react.useMemo)(() => {
|
|
231
|
-
return
|
|
232
|
-
}, [
|
|
230
|
+
return `${newFileName}.sdoc`;
|
|
231
|
+
}, [newFileName]);
|
|
233
232
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
233
|
+
ref: fileLinkInsertRef,
|
|
234
234
|
className: "sdoc-history-files-content popover",
|
|
235
235
|
style: {
|
|
236
236
|
...position,
|
|
@@ -249,9 +249,11 @@ const FileLinkInsertDialog = _ref => {
|
|
|
249
249
|
onClick: () => {
|
|
250
250
|
onSelect(item);
|
|
251
251
|
}
|
|
252
|
-
}, /*#__PURE__*/_react.default.createElement("
|
|
253
|
-
className: "sdocfont sdoc-document"
|
|
254
|
-
}), /*#__PURE__*/_react.default.createElement("span",
|
|
252
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
253
|
+
className: "file-item-icon sdocfont sdoc-document"
|
|
254
|
+
}), /*#__PURE__*/_react.default.createElement("span", {
|
|
255
|
+
className: "file-item-name"
|
|
256
|
+
}, item.name));
|
|
255
257
|
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
256
258
|
className: "sdoc-history-files-item",
|
|
257
259
|
onClick: onShowMore
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
position: absolute;
|
|
5
5
|
width: 400px;
|
|
6
|
-
max-
|
|
6
|
+
max-width: 400px;
|
|
7
|
+
max-height: 350px;
|
|
7
8
|
/* The same as hierarchy of comment drawer */
|
|
8
9
|
z-index: 103;
|
|
9
10
|
box-shadow: 0 1px 3px rgba(0, 0, 0, .15), 0 4px 8px 3px rgba(0, 0, 0, .15);
|
|
@@ -35,17 +36,28 @@
|
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
.sdoc-history-files-content .sdoc-history-files .sdoc-history-files-item {
|
|
38
|
-
padding:
|
|
39
|
+
padding: 6px 16px;
|
|
39
40
|
height: 32px;
|
|
40
|
-
line-height: 32px;
|
|
41
|
-
text-overflow: ellipsis;
|
|
42
41
|
font-size: 14px;
|
|
43
|
-
|
|
42
|
+
display: flex;
|
|
43
|
+
align-items: flex-start;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
.sdoc-history-files-content .sdoc-history-files .sdoc-history-files-item
|
|
47
|
-
font-size:
|
|
48
|
-
margin-right:
|
|
46
|
+
.sdoc-history-files-content .sdoc-history-files .sdoc-history-files-item .file-item-icon {
|
|
47
|
+
font-size: 16px;
|
|
48
|
+
margin-right: 8px;
|
|
49
|
+
color: #ff9800;
|
|
50
|
+
width: 20px;
|
|
51
|
+
height: 20px;
|
|
52
|
+
display: flex;
|
|
53
|
+
justify-content: center;
|
|
54
|
+
align-items: center;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.sdoc-history-files-content .sdoc-history-files .sdoc-history-files-item .file-item-name {
|
|
58
|
+
white-space: nowrap;
|
|
59
|
+
text-overflow: ellipsis;
|
|
60
|
+
overflow: hidden;
|
|
49
61
|
}
|
|
50
62
|
|
|
51
63
|
.sdoc-history-files-content .sdoc-history-files .sdoc-history-files-item:hover {
|
|
@@ -17,9 +17,11 @@ var _constants2 = require("../../constants");
|
|
|
17
17
|
var _helpers = require("../../plugins/image/helpers");
|
|
18
18
|
var _helpers2 = require("../../plugins/video/helpers");
|
|
19
19
|
var _context = _interopRequireDefault(require("../../../../context.js"));
|
|
20
|
-
var _index2 = _interopRequireDefault(require("../file-insert-dialog/index.js"));
|
|
21
|
-
var _index3 = _interopRequireDefault(require("
|
|
22
|
-
var _index4 = require("
|
|
20
|
+
var _index2 = _interopRequireDefault(require("../wiki-file-insert-dialog/index.js"));
|
|
21
|
+
var _index3 = _interopRequireDefault(require("../file-insert-dialog/index.js"));
|
|
22
|
+
var _index4 = _interopRequireDefault(require("../../../../components/toast/index.js"));
|
|
23
|
+
var _index5 = require("../../plugins/video/constants/index.js");
|
|
24
|
+
var _constants3 = require("../../../../basic-sdk/constants");
|
|
23
25
|
const InsertElementDialog = _ref => {
|
|
24
26
|
let {
|
|
25
27
|
editor
|
|
@@ -49,7 +51,7 @@ const InsertElementDialog = _ref => {
|
|
|
49
51
|
}, [validEditor, uploadLocalImageInputRef, insertPosition, slateNode]);
|
|
50
52
|
const handleDisplayAlert = (0, _react.useCallback)(() => {
|
|
51
53
|
setTimeout(() => {
|
|
52
|
-
|
|
54
|
+
_index4.default.warning(`${t('The_current_version_does_not_support_>5MB_video_file')}`, {
|
|
53
55
|
duration: 3
|
|
54
56
|
});
|
|
55
57
|
}, 0);
|
|
@@ -57,7 +59,7 @@ const InsertElementDialog = _ref => {
|
|
|
57
59
|
const onVideoFileChanged = (0, _react.useCallback)(event => {
|
|
58
60
|
const files = event.target.files;
|
|
59
61
|
// Show warning for 3s and no further insertion if video file is more than 5MB
|
|
60
|
-
if (files[0].size >
|
|
62
|
+
if (files[0].size > _index5.VIDEO_MAX_SIZE_5MB) {
|
|
61
63
|
handleDisplayAlert();
|
|
62
64
|
event.target.value = null;
|
|
63
65
|
return;
|
|
@@ -194,7 +196,14 @@ const InsertElementDialog = _ref => {
|
|
|
194
196
|
}
|
|
195
197
|
case _constants2.ELEMENT_TYPE.FILE_LINK_INSET_INPUT_TEMP:
|
|
196
198
|
{
|
|
197
|
-
|
|
199
|
+
if (editor.editorType === _constants3.WIKI_EDITOR) {
|
|
200
|
+
return /*#__PURE__*/_react.default.createElement(_index2.default, {
|
|
201
|
+
element: slateNode,
|
|
202
|
+
editor: editor,
|
|
203
|
+
closeDialog: closeDialog
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
return /*#__PURE__*/_react.default.createElement(_index3.default, {
|
|
198
207
|
element: slateNode,
|
|
199
208
|
editor: editor,
|
|
200
209
|
closeDialog: closeDialog
|
|
@@ -18,3 +18,71 @@
|
|
|
18
18
|
background-color: #FF8000;
|
|
19
19
|
border-color: #FF8000;
|
|
20
20
|
}
|
|
21
|
+
|
|
22
|
+
.modal-header-container {
|
|
23
|
+
display: flex;
|
|
24
|
+
position: relative;
|
|
25
|
+
justify-content: space-between;
|
|
26
|
+
align-items: center;
|
|
27
|
+
width: 100%;
|
|
28
|
+
height: 60px;
|
|
29
|
+
padding: 10px;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.modal-title-container {
|
|
33
|
+
flex: 1;
|
|
34
|
+
text-align: center;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.search-container {
|
|
38
|
+
display: flex;
|
|
39
|
+
align-items: center;
|
|
40
|
+
position: absolute;
|
|
41
|
+
right: 40px;
|
|
42
|
+
top: 55%;
|
|
43
|
+
transform: translateY(-50%);
|
|
44
|
+
gap: 8px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.sdoc-files-search-popover{
|
|
48
|
+
font-size: 14px;
|
|
49
|
+
padding: 1.5px 5px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.sdoc-files-search-popover:hover{
|
|
53
|
+
background-color: #F2F2F2;
|
|
54
|
+
border-radius: 2px;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.sdoc-files-search-popover-container {
|
|
58
|
+
display: flex;
|
|
59
|
+
justify-content: center;
|
|
60
|
+
align-items: center;
|
|
61
|
+
width: 200px;
|
|
62
|
+
margin-right: 10px;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.sdoc-search-wrapper{
|
|
66
|
+
position: relative;
|
|
67
|
+
display: flex;
|
|
68
|
+
align-items: center;
|
|
69
|
+
width: 100%;
|
|
70
|
+
height: 40px;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.sdoc-search-input{
|
|
74
|
+
flex: 1;
|
|
75
|
+
padding: 0 25px;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.sdoc-files-search-popover-container .sdoc-search{
|
|
79
|
+
position: absolute;
|
|
80
|
+
left: 6px;
|
|
81
|
+
font-size: 14px;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.sdoc-files-search-popover-container .sdoc-close{
|
|
85
|
+
position: absolute;
|
|
86
|
+
right: 10px;
|
|
87
|
+
font-size: 10px;
|
|
88
|
+
}
|
|
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _reactstrap = require("reactstrap");
|
|
11
|
+
var _isHotkey = _interopRequireDefault(require("is-hotkey"));
|
|
11
12
|
var _reactI18next = require("react-i18next");
|
|
12
13
|
var _context = _interopRequireDefault(require("../../../../context"));
|
|
13
14
|
var _localFiles = _interopRequireDefault(require("./local-files"));
|
|
@@ -27,6 +28,9 @@ const SelectSdocFileDialog = _ref => {
|
|
|
27
28
|
t
|
|
28
29
|
} = (0, _reactI18next.useTranslation)();
|
|
29
30
|
const [currentSelectedFile, setCurrentSelectedFile] = (0, _react.useState)(null);
|
|
31
|
+
const [temSearchContent, setTemSearchContent] = (0, _react.useState)('');
|
|
32
|
+
const [searchContent, setSearchContent] = (0, _react.useState)('');
|
|
33
|
+
const [isOpenSearch, setIsOpenSearch] = (0, _react.useState)(false);
|
|
30
34
|
const onSelectedFile = (0, _react.useCallback)(fileInfo => {
|
|
31
35
|
setCurrentSelectedFile(fileInfo);
|
|
32
36
|
}, []);
|
|
@@ -70,6 +74,36 @@ const SelectSdocFileDialog = _ref => {
|
|
|
70
74
|
closeDialog();
|
|
71
75
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
72
76
|
}, [currentSelectedFile]);
|
|
77
|
+
const toggleSearch = (0, _react.useCallback)(() => {
|
|
78
|
+
setIsOpenSearch(prev => !prev);
|
|
79
|
+
}, []);
|
|
80
|
+
const handleSearchInputChange = (0, _react.useCallback)(e => {
|
|
81
|
+
const keyword = e.target.value.toLowerCase();
|
|
82
|
+
setTemSearchContent(keyword);
|
|
83
|
+
}, []);
|
|
84
|
+
const executeSearch = (0, _react.useCallback)(() => {
|
|
85
|
+
if (!temSearchContent.trim()) {
|
|
86
|
+
setSearchContent('');
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
setSearchContent(temSearchContent);
|
|
90
|
+
}, [temSearchContent]);
|
|
91
|
+
const handleInputKeyDown = (0, _react.useCallback)(e => {
|
|
92
|
+
if ((0, _isHotkey.default)('enter', e)) {
|
|
93
|
+
e.preventDefault();
|
|
94
|
+
executeSearch();
|
|
95
|
+
}
|
|
96
|
+
if ((0, _isHotkey.default)('escape', e)) {
|
|
97
|
+
e.preventDefault();
|
|
98
|
+
e.stopPropagation();
|
|
99
|
+
setIsOpenSearch(!isOpenSearch);
|
|
100
|
+
}
|
|
101
|
+
}, [executeSearch, isOpenSearch]);
|
|
102
|
+
(0, _react.useEffect)(() => {
|
|
103
|
+
if (!isOpenSearch) {
|
|
104
|
+
setSearchContent('');
|
|
105
|
+
}
|
|
106
|
+
}, [isOpenSearch]);
|
|
73
107
|
return /*#__PURE__*/_react.default.createElement(_reactstrap.Modal, {
|
|
74
108
|
toggle: closeDialog,
|
|
75
109
|
isOpen: true,
|
|
@@ -79,15 +113,42 @@ const SelectSdocFileDialog = _ref => {
|
|
|
79
113
|
className: "sdoc-file-select-dialog",
|
|
80
114
|
contentClassName: "sdoc-file-select-modal"
|
|
81
115
|
}, /*#__PURE__*/_react.default.createElement(_reactstrap.ModalHeader, {
|
|
116
|
+
className: "modal-header-container",
|
|
82
117
|
toggle: closeDialog
|
|
83
|
-
},
|
|
118
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
119
|
+
className: "modal-title-container"
|
|
120
|
+
}, t(modalTitle)), /*#__PURE__*/_react.default.createElement("div", {
|
|
121
|
+
className: "search-container"
|
|
122
|
+
}, !isOpenSearch && /*#__PURE__*/_react.default.createElement("div", {
|
|
123
|
+
className: "sdocfont sdoc-find-replace sdoc-files-search-popover",
|
|
124
|
+
onClick: toggleSearch
|
|
125
|
+
}), isOpenSearch && /*#__PURE__*/_react.default.createElement("div", {
|
|
126
|
+
className: "sdoc-files-search-popover-container"
|
|
127
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
128
|
+
className: "sdoc-search-wrapper"
|
|
129
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
130
|
+
className: "sdocfont sdoc-find-replace sdoc-search",
|
|
131
|
+
onClick: executeSearch
|
|
132
|
+
}), /*#__PURE__*/_react.default.createElement(_reactstrap.Input, {
|
|
133
|
+
autoFocus: true,
|
|
134
|
+
className: "sdoc-search-input",
|
|
135
|
+
onKeyUp: handleInputKeyDown,
|
|
136
|
+
onChange: handleSearchInputChange,
|
|
137
|
+
id: "sdoc-search",
|
|
138
|
+
placeholder: t('Search')
|
|
139
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
140
|
+
className: "sdocfont sdoc-sm-close sdoc-close",
|
|
141
|
+
onClick: toggleSearch
|
|
142
|
+
}))))), /*#__PURE__*/_react.default.createElement(_reactstrap.ModalBody, {
|
|
84
143
|
className: "p-0"
|
|
85
144
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
86
145
|
className: "sdoc-file-select-container"
|
|
87
146
|
}, /*#__PURE__*/_react.default.createElement(_localFiles.default, {
|
|
88
147
|
fileType: _constants.FILE_TYPE[dialogType],
|
|
89
148
|
onSelectedFile: onSelectedFile,
|
|
90
|
-
toggle: closeDialog
|
|
149
|
+
toggle: closeDialog,
|
|
150
|
+
searchContent: searchContent,
|
|
151
|
+
isOpenSearch: isOpenSearch
|
|
91
152
|
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
92
153
|
className: "sdoc-file-select-footer"
|
|
93
154
|
}, /*#__PURE__*/_react.default.createElement(_reactstrap.Button, {
|
|
@@ -20,7 +20,9 @@ const LocalFiles = _ref => {
|
|
|
20
20
|
onSelectedFile,
|
|
21
21
|
toggle,
|
|
22
22
|
fileType,
|
|
23
|
-
t
|
|
23
|
+
t,
|
|
24
|
+
searchContent,
|
|
25
|
+
isOpenSearch
|
|
24
26
|
} = _ref;
|
|
25
27
|
const folderRef = (0, _react.useRef)(null);
|
|
26
28
|
const [expandedFolder, setExpandedFolder] = (0, _react.useState)(new Set([]));
|
|
@@ -64,10 +66,15 @@ const LocalFiles = _ref => {
|
|
|
64
66
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
65
67
|
}, []);
|
|
66
68
|
(0, _react.useEffect)(() => {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
+
if (searchContent.trim() && isOpenSearch) {
|
|
70
|
+
getSearchFiles(searchContent, fileType);
|
|
71
|
+
}
|
|
72
|
+
if (!isOpenSearch || !searchContent.trim()) {
|
|
73
|
+
const rootPath = '/';
|
|
74
|
+
getTreeData(rootPath);
|
|
75
|
+
}
|
|
69
76
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
70
|
-
}, []);
|
|
77
|
+
}, [isOpenSearch, searchContent, isOpenSearch]);
|
|
71
78
|
const onToggle = (0, _react.useCallback)(async (e, item, treeData) => {
|
|
72
79
|
e.stopPropagation();
|
|
73
80
|
if (expandedFolder.has(item.indexId)) {
|
|
@@ -88,6 +95,16 @@ const LocalFiles = _ref => {
|
|
|
88
95
|
onSelectedFile(file);
|
|
89
96
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
90
97
|
}, []);
|
|
98
|
+
const getSearchFiles = (0, _react.useCallback)((searchContent, fileType) => {
|
|
99
|
+
return _context.default.getSearchFilesByFilename(searchContent, '1', '100', fileType).then(res => {
|
|
100
|
+
res.data.results.forEach(item => {
|
|
101
|
+
item.indexId = _slugid.default.nice();
|
|
102
|
+
item.type = 'file';
|
|
103
|
+
item.file_uuid = item.doc_uuid;
|
|
104
|
+
});
|
|
105
|
+
setTreeData(res.data.results);
|
|
106
|
+
});
|
|
107
|
+
}, []);
|
|
91
108
|
const renderFileTree = (0, _react.useCallback)(data => {
|
|
92
109
|
if (!Array.isArray(data) || data.length === 0) return null;
|
|
93
110
|
return data.map(item => {
|