@seafile/sdoc-editor 1.0.172-alpha-4 → 1.0.173

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.
@@ -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
- 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;
145
+ searchSdocFiles(docUuid, query, page, per_page) {
146
+ const url = 'api/v2.1/seadoc/search-filename/' + docUuid + '/?query=' + query + '&page=' + page + '&per_page=' + per_page;
147
147
  return this.req.get(url);
148
148
  }
149
149
 
@@ -215,15 +215,12 @@ const FileLinkInsertDialog = _ref => {
215
215
  insertSdocFileLink: _helpers.insertSdocFileLink,
216
216
  editor
217
217
  };
218
- console.log(1, createName, external_props);
219
- // debugger;
220
218
  eventBus.dispatch(_constants.EXTERNAL_EVENT.CREATE_SDOC_FILE, {
221
219
  newFileName: createName,
222
220
  ...external_props
223
221
  });
224
222
  }, [editor, element, newFileName]);
225
223
  const createFileTipDefault = (0, _react.useMemo)(() => {
226
- console.log(444);
227
224
  return 'Create_a_new_sdoc_file';
228
225
  }, []);
229
226
  const createFileName = (0, _react.useMemo)(() => {
@@ -18,71 +18,3 @@
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,7 +8,6 @@ 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"));
12
11
  var _reactI18next = require("react-i18next");
13
12
  var _context = _interopRequireDefault(require("../../../../context"));
14
13
  var _localFiles = _interopRequireDefault(require("./local-files"));
@@ -28,9 +27,6 @@ const SelectSdocFileDialog = _ref => {
28
27
  t
29
28
  } = (0, _reactI18next.useTranslation)();
30
29
  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);
34
30
  const onSelectedFile = (0, _react.useCallback)(fileInfo => {
35
31
  setCurrentSelectedFile(fileInfo);
36
32
  }, []);
@@ -74,36 +70,6 @@ const SelectSdocFileDialog = _ref => {
74
70
  closeDialog();
75
71
  // eslint-disable-next-line react-hooks/exhaustive-deps
76
72
  }, [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]);
107
73
  return /*#__PURE__*/_react.default.createElement(_reactstrap.Modal, {
108
74
  toggle: closeDialog,
109
75
  isOpen: true,
@@ -113,42 +79,15 @@ const SelectSdocFileDialog = _ref => {
113
79
  className: "sdoc-file-select-dialog",
114
80
  contentClassName: "sdoc-file-select-modal"
115
81
  }, /*#__PURE__*/_react.default.createElement(_reactstrap.ModalHeader, {
116
- className: "modal-header-container",
117
82
  toggle: closeDialog
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, {
83
+ }, t(modalTitle)), /*#__PURE__*/_react.default.createElement(_reactstrap.ModalBody, {
143
84
  className: "p-0"
144
85
  }, /*#__PURE__*/_react.default.createElement("div", {
145
86
  className: "sdoc-file-select-container"
146
87
  }, /*#__PURE__*/_react.default.createElement(_localFiles.default, {
147
88
  fileType: _constants.FILE_TYPE[dialogType],
148
89
  onSelectedFile: onSelectedFile,
149
- toggle: closeDialog,
150
- searchContent: searchContent,
151
- isOpenSearch: isOpenSearch
90
+ toggle: closeDialog
152
91
  }), /*#__PURE__*/_react.default.createElement("div", {
153
92
  className: "sdoc-file-select-footer"
154
93
  }, /*#__PURE__*/_react.default.createElement(_reactstrap.Button, {
@@ -20,9 +20,7 @@ const LocalFiles = _ref => {
20
20
  onSelectedFile,
21
21
  toggle,
22
22
  fileType,
23
- t,
24
- searchContent,
25
- isOpenSearch
23
+ t
26
24
  } = _ref;
27
25
  const folderRef = (0, _react.useRef)(null);
28
26
  const [expandedFolder, setExpandedFolder] = (0, _react.useState)(new Set([]));
@@ -66,15 +64,10 @@ const LocalFiles = _ref => {
66
64
  // eslint-disable-next-line react-hooks/exhaustive-deps
67
65
  }, []);
68
66
  (0, _react.useEffect)(() => {
69
- if (searchContent.trim() && isOpenSearch) {
70
- getSearchFiles(searchContent, fileType);
71
- }
72
- if (!isOpenSearch || !searchContent.trim()) {
73
- const rootPath = '/';
74
- getTreeData(rootPath);
75
- }
67
+ const rootPath = '/';
68
+ getTreeData(rootPath);
76
69
  // eslint-disable-next-line react-hooks/exhaustive-deps
77
- }, [isOpenSearch, searchContent, isOpenSearch]);
70
+ }, []);
78
71
  const onToggle = (0, _react.useCallback)(async (e, item, treeData) => {
79
72
  e.stopPropagation();
80
73
  if (expandedFolder.has(item.indexId)) {
@@ -95,16 +88,6 @@ const LocalFiles = _ref => {
95
88
  onSelectedFile(file);
96
89
  // eslint-disable-next-line react-hooks/exhaustive-deps
97
90
  }, []);
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
- }, []);
108
91
  const renderFileTree = (0, _react.useCallback)(data => {
109
92
  if (!Array.isArray(data) || data.length === 0) return null;
110
93
  return data.map(item => {
@@ -21,7 +21,7 @@ const isMenuDisabled = (editor, readonly) => {
21
21
  type
22
22
  } = elem;
23
23
  if (editor.isVoid(elem)) return true;
24
- if ([_constants.CODE_BLOCK, _constants.CODE_LINE, _constants.LINK, ..._constants.HEADERS].includes(type)) return true;
24
+ if ([_constants.CODE_BLOCK, _constants.CODE_LINE, _constants.LINK, _constants.TITLE, _constants.SUBTITLE, ..._constants.HEADERS].includes(type)) return true;
25
25
  return false;
26
26
  });
27
27
  if (notMatch) return true; // disabled
@@ -22,7 +22,7 @@ const isMenuDisabled = (editor, readonly) => {
22
22
  type
23
23
  } = elem;
24
24
  if (editor.isVoid(elem)) return true;
25
- if ([_constants.CODE_BLOCK, _constants.CODE_LINE, _constants.LINK, ..._constants.HEADERS].includes(type)) return true;
25
+ if ([_constants.CODE_BLOCK, _constants.CODE_LINE, _constants.LINK, _constants.TITLE, _constants.SUBTITLE, ..._constants.HEADERS].includes(type)) return true;
26
26
  return false;
27
27
  });
28
28
  if (notMatch) return true; // disabled
package/dist/context.js CHANGED
@@ -199,10 +199,6 @@ class Context {
199
199
  const docUuid = this.getSetting('docUuid');
200
200
  return this.api.getSdocFiles(docUuid, p, type);
201
201
  }
202
- getSearchFilesByFilename(query, page, per_page, search_type) {
203
- const docUuid = this.getSetting('docUuid');
204
- return this.api.searchFilesByFilename(docUuid, query, page, per_page, search_type);
205
- }
206
202
  getSdocLocalFileId(p) {
207
203
  const docUuid = this.getSetting('docUuid');
208
204
  return this.api.getSdocFileId(docUuid, p);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "1.0.172-alpha-4",
3
+ "version": "1.0.173",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",