@seafile/sdoc-editor 1.0.179 → 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.
- package/dist/basic-sdk/extension/plugins/ai/ai-menu/ai-context-menu.js +3 -1
- package/dist/basic-sdk/extension/plugins/ai/ai-menu/style.css +8 -0
- package/dist/basic-sdk/extension/plugins/ai/ai-module/index.js +14 -8
- package/dist/basic-sdk/extension/plugins/ai/ai-module/style.css +2 -2
- package/dist/basic-sdk/extension/plugins/text-style/menu/index.js +5 -1
- package/dist/basic-sdk/extension/plugins/video/helpers.js +2 -0
- package/dist/basic-sdk/extension/plugins/video/plugin.js +1 -1
- package/dist/basic-sdk/extension/toolbar/context-toolbar/index.css +4 -0
- package/package.json +1 -1
- package/public/locales/zh_CN/sdoc-editor.json +1 -1
|
@@ -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(
|
|
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
|
}
|
|
@@ -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('
|
|
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
|
-
|
|
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(
|
|
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(
|
|
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(
|
|
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)
|
|
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
|
},
|
|
@@ -29,7 +29,7 @@ const withVideo = editor => {
|
|
|
29
29
|
return isVoid(elem);
|
|
30
30
|
};
|
|
31
31
|
newEditor.onHotKeyDown = event => {
|
|
32
|
-
const [videoNode, path] = (0, _core.getSelectedNodeEntryByType)(editor, _constants.VIDEO);
|
|
32
|
+
const [videoNode, path] = (0, _core.getSelectedNodeEntryByType)(editor, _constants.VIDEO) || [];
|
|
33
33
|
if (path) {
|
|
34
34
|
// Insert empty paragraph node after video when clicking 'enter' on selected video
|
|
35
35
|
if ((0, _isHotkey.default)('enter', event)) {
|
package/package.json
CHANGED