@apify/docs-theme 1.0.189 → 1.0.190
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/package.json +2 -1
- package/src/theme/SearchBar/index.js +17 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apify/docs-theme",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.190",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"files": [
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"docusaurus-gtm-plugin": "^0.0.2",
|
|
30
30
|
"postcss-preset-env": "^10.1.3",
|
|
31
31
|
"prism-react-renderer": "^2.4.1",
|
|
32
|
+
"react-hotkeys-hook": "^5.1.0",
|
|
32
33
|
"remark-parse": "^11.0.0",
|
|
33
34
|
"remark-stringify": "^11.0.0",
|
|
34
35
|
"unified": "^11.0.5",
|
|
@@ -4,8 +4,8 @@ import RouterLink from '@docusaurus/Link';
|
|
|
4
4
|
// import { useHistory, useLocation } from '@docusaurus/router';
|
|
5
5
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
6
6
|
import clsx from 'clsx';
|
|
7
|
-
// import React, { useCallback } from 'react';
|
|
8
7
|
import React, { useEffect, useState } from 'react';
|
|
8
|
+
import { useHotkeys } from 'react-hotkeys-hook';
|
|
9
9
|
|
|
10
10
|
// import { ApifySearch } from '@apify/docs-search-modal';
|
|
11
11
|
import { ControlKeyIcon, SearchIcon } from '@apify/docs-search-modal/dist/utils/icons';
|
|
@@ -82,6 +82,7 @@ export function Link(props) {
|
|
|
82
82
|
|
|
83
83
|
export default function SearchBar({ onClick }) {
|
|
84
84
|
const [variant, setVariant] = useState(null);
|
|
85
|
+
const [opened, setOpened] = useState(false);
|
|
85
86
|
const { siteConfig } = useDocusaurusContext();
|
|
86
87
|
const { inkeepApiKey } = siteConfig.customFields;
|
|
87
88
|
|
|
@@ -98,9 +99,18 @@ export default function SearchBar({ onClick }) {
|
|
|
98
99
|
}, []);
|
|
99
100
|
|
|
100
101
|
onClick = () => {
|
|
102
|
+
if (opened) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
setOpened(true);
|
|
107
|
+
|
|
101
108
|
if (variant === 'kapa') {
|
|
102
109
|
if (window.Kapa && typeof window.Kapa.open === 'function') {
|
|
103
110
|
window.Kapa.open();
|
|
111
|
+
window.Kapa('onModalClose', () => {
|
|
112
|
+
setOpened(false);
|
|
113
|
+
});
|
|
104
114
|
} else {
|
|
105
115
|
console.error('Kapa.ai widget is not available.');
|
|
106
116
|
}
|
|
@@ -178,11 +188,13 @@ export default function SearchBar({ onClick }) {
|
|
|
178
188
|
},
|
|
179
189
|
],
|
|
180
190
|
},
|
|
191
|
+
defaultView: 'chat',
|
|
181
192
|
};
|
|
182
193
|
const modal = window.Inkeep.ModalSearchAndChat(config);
|
|
183
194
|
|
|
184
195
|
function handleOpenChange(newOpen) {
|
|
185
196
|
modal.update({ modalSettings: { isOpen: newOpen } });
|
|
197
|
+
setOpened(newOpen);
|
|
186
198
|
}
|
|
187
199
|
|
|
188
200
|
modal.update({ modalSettings: { isOpen: true } });
|
|
@@ -200,6 +212,10 @@ export default function SearchBar({ onClick }) {
|
|
|
200
212
|
}
|
|
201
213
|
}, []);
|
|
202
214
|
|
|
215
|
+
useHotkeys('mod+k, /', () => {
|
|
216
|
+
onClick();
|
|
217
|
+
}, { preventDefault: true });
|
|
218
|
+
|
|
203
219
|
return (
|
|
204
220
|
<BrowserOnly>
|
|
205
221
|
{() => (
|