@seafile/sdoc-editor 1.0.206-test0.0.4 → 1.0.206-test0.0.5

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.
@@ -32,6 +32,7 @@ const InsertElementDialog = _ref => {
32
32
  const [insertPosition, setInsertPosition] = (0, _react.useState)(_constants2.INSERT_POSITION.CURRENT);
33
33
  const [slateNode, setSlateNode] = (0, _react.useState)(null);
34
34
  const [insertLinkCallback, setInsertLinkCallback] = (0, _react.useState)(null);
35
+ const [insertVideoCallback, setInsertVideoCallback] = (0, _react.useState)(null);
35
36
  const [validEditor, setValidEditor] = (0, _react.useState)(editor);
36
37
  const [linkTitle, setLinkTitle] = (0, _react.useState)('');
37
38
  const [handleSubmit, setHandleSubmit] = (0, _react.useState)(() => void 0);
@@ -90,6 +91,7 @@ const InsertElementDialog = _ref => {
90
91
  slateNode,
91
92
  insertFileLinkCallback,
92
93
  insertSdocFileLinkCallback,
94
+ insertVideo,
93
95
  editor: paramEditor,
94
96
  linkTitle,
95
97
  // link shortcut wrapping link
@@ -103,6 +105,9 @@ const InsertElementDialog = _ref => {
103
105
  insertSdocFileLinkCallback,
104
106
  insertFileLinkCallback
105
107
  });
108
+ setInsertVideoCallback({
109
+ insertVideo
110
+ });
106
111
  setLinkTitle(linkTitle);
107
112
  setHandleSubmit(handleSubmit);
108
113
  // Apply for comment editor, as it has a different editor instance
@@ -124,6 +129,7 @@ const InsertElementDialog = _ref => {
124
129
  setElement('');
125
130
  setDialogType('');
126
131
  setInsertLinkCallback(null);
132
+ setInsertVideoCallback(null);
127
133
  setValidEditor(null);
128
134
  setLinkTitle('');
129
135
  }, []);
@@ -169,6 +175,16 @@ const InsertElementDialog = _ref => {
169
175
  };
170
176
  return /*#__PURE__*/_react.default.createElement(_index.default, fileLinkProps);
171
177
  }
178
+ case _constants2.ELEMENT_TYPE.VIDEO:
179
+ {
180
+ const videoProps = {
181
+ editor: validEditor,
182
+ dialogType,
183
+ insertVideoCallback,
184
+ closeDialog
185
+ };
186
+ return /*#__PURE__*/_react.default.createElement(_index.default, videoProps);
187
+ }
172
188
  case _constants2.LOCAL_IMAGE:
173
189
  {
174
190
  return /*#__PURE__*/_react.default.createElement("input", {
@@ -21,9 +21,9 @@ const SelectSdocFileDialog = _ref => {
21
21
  editor,
22
22
  dialogType,
23
23
  closeDialog,
24
- insertLinkCallback
24
+ insertLinkCallback,
25
+ insertVideoCallback
25
26
  } = _ref;
26
- const modalTitle = dialogType === _constants.ELEMENT_TYPE.FILE_LINK ? 'Select_file' : 'Select_sdoc_document';
27
27
  const {
28
28
  t
29
29
  } = (0, _reactI18next.useTranslation)('sdoc-editor');
@@ -31,6 +31,20 @@ const SelectSdocFileDialog = _ref => {
31
31
  const [temSearchContent, setTemSearchContent] = (0, _react.useState)('');
32
32
  const [searchContent, setSearchContent] = (0, _react.useState)('');
33
33
  const [isOpenSearch, setIsOpenSearch] = (0, _react.useState)(false);
34
+ let modalTitle;
35
+ switch (dialogType) {
36
+ case _constants.ELEMENT_TYPE.FILE_LINK:
37
+ modalTitle = 'Select_file';
38
+ break;
39
+ case _constants.ELEMENT_TYPE.SDOC_LINK:
40
+ modalTitle = 'Select_sdoc_document';
41
+ break;
42
+ case _constants.ELEMENT_TYPE.VIDEO:
43
+ modalTitle = 'Select_video';
44
+ break;
45
+ default:
46
+ break;
47
+ }
34
48
  const onSelectedFile = (0, _react.useCallback)(fileInfo => {
35
49
  setCurrentSelectedFile(fileInfo);
36
50
  }, []);
@@ -38,13 +52,24 @@ const SelectSdocFileDialog = _ref => {
38
52
  const {
39
53
  insertFileLinkCallback,
40
54
  insertSdocFileLinkCallback
41
- } = insertLinkCallback;
42
- if (dialogType === _constants.ELEMENT_TYPE.FILE_LINK) {
43
- insertFileLinkCallback && insertFileLinkCallback(editor, fileInfo.name, fileInfo.file_uuid);
44
- } else {
45
- insertSdocFileLinkCallback && insertSdocFileLinkCallback(editor, fileInfo.name, fileInfo.file_uuid);
55
+ } = insertLinkCallback || {};
56
+ const {
57
+ insertVideo
58
+ } = insertVideoCallback || {};
59
+ switch (dialogType) {
60
+ case _constants.ELEMENT_TYPE.FILE_LINK:
61
+ insertFileLinkCallback && insertFileLinkCallback(editor, fileInfo.name, fileInfo.file_uuid);
62
+ break;
63
+ case _constants.ELEMENT_TYPE.SDOC_LINK:
64
+ insertSdocFileLinkCallback && insertSdocFileLinkCallback(editor, fileInfo.name, fileInfo.file_uuid);
65
+ break;
66
+ case _constants.ELEMENT_TYPE.VIDEO:
67
+ // insertVideo && insertVideo(editor, fileInfo.name, fileInfo.path);
68
+ break;
69
+ default:
70
+ break;
46
71
  }
47
- }, [insertLinkCallback, dialogType, editor]);
72
+ }, [insertLinkCallback, insertVideoCallback, dialogType, editor]);
48
73
  const onSubmit = (0, _react.useCallback)(() => {
49
74
  if (!currentSelectedFile) return;
50
75
  const {
@@ -53,6 +78,15 @@ const SelectSdocFileDialog = _ref => {
53
78
  let fileInfo = {
54
79
  ...currentSelectedFile
55
80
  };
81
+
82
+ // Insert video element in sdoc
83
+ if (dialogType === _constants.ELEMENT_TYPE.VIDEO) {
84
+ console.log(1, fileInfo);
85
+ insertFile(fileInfo);
86
+ closeDialog();
87
+ return;
88
+ }
89
+
56
90
  // File has no id
57
91
  if (!file_uuid || file_uuid === '') {
58
92
  _context.default.getSdocLocalFileId(currentSelectedFile.path).then(res => {
@@ -18,6 +18,7 @@ const VideoMenu = _ref => {
18
18
  let {
19
19
  editor,
20
20
  readonly,
21
+ toggle,
21
22
  eventBus
22
23
  } = _ref;
23
24
  const disabled = (0, _helpers.isInsertVideoMenuDisabled)(editor, readonly);
@@ -40,6 +41,14 @@ const VideoMenu = _ref => {
40
41
  ...external_props
41
42
  });
42
43
  }, [editor, eventBus]);
44
+ const openSelectVideoFileDialog = (0, _react.useCallback)(() => {
45
+ eventBus.dispatch(_constants2.INTERNAL_EVENT.INSERT_ELEMENT, {
46
+ type: _constants.ELEMENT_TYPE.VIDEO,
47
+ insertVideo: _helpers.insertVideo
48
+ });
49
+ toggle && toggle();
50
+ // eslint-disable-next-line react-hooks/exhaustive-deps
51
+ }, [toggle, eventBus]);
43
52
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
44
53
  disabled: disabled,
45
54
  menuConfig: menuConfig,
@@ -63,7 +72,7 @@ const VideoMenu = _ref => {
63
72
  onClick: addVideoLink
64
73
  }, t('Add_video_link')), /*#__PURE__*/_react.default.createElement("div", {
65
74
  className: "sdoc-dropdown-menu-item",
66
- onClick: openLocalVideoDialog
75
+ onClick: openSelectVideoFileDialog
67
76
  }, t('Link_to_Seafile_video_file')))));
68
77
  };
69
78
  var _default = exports.default = VideoMenu;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "1.0.206-test0.0.4",
3
+ "version": "1.0.206-test0.0.5",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",