@seafile/sdoc-editor 1.0.180 → 1.0.181

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.
@@ -35,5 +35,7 @@ function AIContextMenu(_ref) {
35
35
  'ariaLabel': 'Ask_AI',
36
36
  'type': 'sdoc-ask-ai'
37
37
  };
38
- return /*#__PURE__*/_react.default.createElement(_menuItem.default, aiProps);
38
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
39
+ className: "sdoc-context-menu-divider"
40
+ }), /*#__PURE__*/_react.default.createElement(_menuItem.default, aiProps));
39
41
  }
@@ -1,3 +1,11 @@
1
1
  .menu-group-item.sdoc-ask-ai-menu-container {
2
2
  width: 80px;
3
+ color: #212529;
4
+ font-size: 14px;
5
+ }
6
+
7
+ .sdoc-context-menu-divider {
8
+ border-left: 1px solid #e5e5e5;
9
+ width: 1px;
10
+ height: 24px;
3
11
  }
@@ -38,22 +38,23 @@ function AIModule(_ref) {
38
38
  const scrollRef = (0, _react.useRef)(null);
39
39
  const [isShowAIPopover, setIsShowAIPopover] = (0, _react.useState)(false);
40
40
  const [opType, setOpType] = (0, _react.useState)('');
41
+ const [selectedValue, setSelectedValue] = (0, _react.useState)('');
41
42
  const [searchValue, setSearchValue] = (0, _react.useState)('');
42
43
  const [isGenerating, setIsGenerating] = (0, _react.useState)(false);
43
44
  const [searchResult, setSearchResult] = (0, _react.useState)(null);
44
45
  const [currentLang, setCurrentLang] = (0, _react.useState)('en');
45
46
  const [isShowTipDialog, setIsShowTipDialog] = (0, _react.useState)(false);
46
47
  const toggleAskAI = (0, _react.useCallback)(() => {
47
- const content = window.getSelection().toString();
48
- if (content) {
49
- setSearchValue(content);
50
- }
51
48
  scrollRef.current = document.querySelector('.sdoc-scroll-container');
52
49
  const {
53
50
  scrollTop,
54
51
  scrollHeight
55
52
  } = scrollRef.current;
56
53
  if (!element) {
54
+ const content = window.getSelection().toString();
55
+ if (content) {
56
+ setSelectedValue(content);
57
+ }
57
58
  const domSelection = window.getSelection();
58
59
  const domRange = domSelection.getRangeAt(0);
59
60
  const rect = domRange.getBoundingClientRect();
@@ -86,6 +87,10 @@ function AIModule(_ref) {
86
87
  }
87
88
  const slateDom = _slateReact.ReactEditor.toDOMNode(editor, element);
88
89
  const slateRect = slateDom.getBoundingClientRect();
90
+ const content = _slate.Node.string(element);
91
+ if (content) {
92
+ setSelectedValue(content);
93
+ }
89
94
  const needPaddingBottomHeight = scrollTop + slateRect.bottom + _constants.AI_MIN_HEIGHT - scrollHeight;
90
95
  if (needPaddingBottomHeight > 0) {
91
96
  const articleDom = document.querySelector('.sdoc-editor__article');
@@ -176,7 +181,7 @@ function AIModule(_ref) {
176
181
  setIsGenerating(true);
177
182
  setTimeout(() => {
178
183
  setIsGenerating(false);
179
- setSearchResult('1 + 1 等于2.');
184
+ setSearchResult('[Feature is under development...]Thank you, the world becomes more beautiful because of you!');
180
185
  });
181
186
  }, [searchValue]);
182
187
  const onKeyDown = (0, _react.useCallback)(event => {
@@ -223,7 +228,8 @@ function AIModule(_ref) {
223
228
  }, 2000);
224
229
  }, []);
225
230
  const onTranslateClick = (0, _react.useCallback)(lang => {
226
- if (!searchValue) {
231
+ const translateValue = searchValue ? searchValue : selectedValue;
232
+ if (!translateValue) {
227
233
  _toast.default.warning(t('The_translation_content_cannot_be_empty'));
228
234
  return;
229
235
  }
@@ -231,7 +237,7 @@ function AIModule(_ref) {
231
237
  const translateLang = lang ? lang : currentLang;
232
238
  setCurrentLang(translateLang);
233
239
  setIsGenerating(true);
234
- _context.default.aiTranslate(searchValue, translateLang).then(res => {
240
+ _context.default.aiTranslate(translateValue, translateLang).then(res => {
235
241
  const {
236
242
  translation
237
243
  } = res.data;
@@ -241,7 +247,7 @@ function AIModule(_ref) {
241
247
  setIsGenerating(false);
242
248
  _toast.default.danger('Translation_error_message');
243
249
  });
244
- }, [currentLang, searchValue, t]);
250
+ }, [currentLang, searchValue, selectedValue, t]);
245
251
  const focusToEndPath = (0, _react.useCallback)(path => {
246
252
  setTimeout(() => {
247
253
  const endOfLastNodePoint = _slate.Editor.end(editor, path);
@@ -10,7 +10,7 @@
10
10
  background-color: #fff;
11
11
  border: 1px solid #eee;
12
12
  border-radius: 10px;
13
- box-shadow: 0 2px 10px rgba(255, 255, 255, 0.1);
13
+ box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
14
14
  }
15
15
 
16
16
  .sdoc-ai-content .sdoc-ai-search {
@@ -58,7 +58,7 @@
58
58
  padding: 8px 0;
59
59
  border: 1px solid #eee;
60
60
  border-radius: 10px;
61
- box-shadow: 0 2px 10px rgba(255, 255, 255, 0.1);
61
+ box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
62
62
  background-color: #fff;
63
63
  }
64
64
 
@@ -123,7 +123,11 @@ const TextStyleMenuList = _ref => {
123
123
  let list = getTextStyleList(_constants.TEXT_STYLE);
124
124
  const dropdownList = getTextStyleList(_constants.TEXT_STYLE_MORE);
125
125
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, list.map((itemProps, index) => {
126
- if (itemProps.type === _constants.LINK && editor.editorType !== _constants2.WIKI_EDITOR) return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
126
+ if (itemProps.type === _constants.LINK && editor.editorType !== _constants2.WIKI_EDITOR) {
127
+ return /*#__PURE__*/_react.default.createElement(_react.Fragment, {
128
+ key: index
129
+ });
130
+ }
127
131
  const Component = itemProps.isColor ? _commons.ColorMenu : _commons.MenuItem;
128
132
  return /*#__PURE__*/_react.default.createElement(Component, Object.assign({
129
133
  key: index
@@ -32,6 +32,8 @@ const isInsertVideoMenuDisabled = (editor, readonly) => {
32
32
  if (type === _constants.LIST_ITEM) return true;
33
33
  if (type === _constants.CHECK_LIST_ITEM) return true;
34
34
  if (type === _constants.MULTI_COLUMN) return true;
35
+ if (type === _constants.BLOCKQUOTE) return true;
36
+ if (type === _constants.CALL_OUT) return true;
35
37
  if (_slate.Editor.isVoid(editor, n)) return true;
36
38
  return false;
37
39
  },
@@ -9,3 +9,7 @@
9
9
  border-radius: 3px;
10
10
  box-shadow: rgba(15, 15, 15, 0.05) 0px 0px 0px 0px, rgba(15, 15, 15, 0.1) 0px 3px 6px, rgba(15, 15, 15, 0.2) 0px 9px 24px;
11
11
  }
12
+
13
+ .sdoc-context-toolbar .menu-group {
14
+ border-right: none;
15
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "1.0.180",
3
+ "version": "1.0.181",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",
@@ -603,5 +603,5 @@
603
603
  "Discard": "丢弃",
604
604
  "English": "英语",
605
605
  "Chinese": "中文",
606
- "Ask_AI": " AI 提问"
606
+ "Ask_AI": "询问 AI"
607
607
  }