@apify/docs-theme 1.0.225 → 1.0.227
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 +1 -1
- package/src/theme/LLMButtons/index.jsx +121 -3
package/package.json
CHANGED
|
@@ -7,10 +7,13 @@ import {
|
|
|
7
7
|
CheckIcon,
|
|
8
8
|
ChevronDownIcon,
|
|
9
9
|
CopyIcon,
|
|
10
|
+
CursorIcon,
|
|
10
11
|
ExternalLinkIcon,
|
|
11
12
|
LoaderIcon,
|
|
12
13
|
MarkdownIcon,
|
|
14
|
+
McpIcon,
|
|
13
15
|
PerplexityIcon,
|
|
16
|
+
VscodeIcon,
|
|
14
17
|
} from '@apify/ui-icons';
|
|
15
18
|
import { Menu, Text, theme } from '@apify/ui-library';
|
|
16
19
|
|
|
@@ -31,6 +34,29 @@ const DROPDOWN_OPTIONS = [
|
|
|
31
34
|
Icon: MarkdownIcon,
|
|
32
35
|
value: 'viewAsMarkdown',
|
|
33
36
|
},
|
|
37
|
+
{
|
|
38
|
+
label: 'Copy MCP server',
|
|
39
|
+
description: 'Copy MCP Server URL to clipboard',
|
|
40
|
+
showExternalIcon: false,
|
|
41
|
+
Icon: McpIcon,
|
|
42
|
+
value: 'copyMcpServerUrl',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
label: 'Connect to Cursor',
|
|
46
|
+
description: 'Install MCP Server on Cursor',
|
|
47
|
+
showExternalIcon: true,
|
|
48
|
+
// TODO: Replace with CursorIcon - we don't have one yet
|
|
49
|
+
Icon: CursorIcon,
|
|
50
|
+
value: 'connectCursor',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
label: 'Connect to VS Code',
|
|
54
|
+
description: 'Install MCP server on VS Code',
|
|
55
|
+
showExternalIcon: true,
|
|
56
|
+
// TODO: Replace with VS Code Icon - we don't have one yet
|
|
57
|
+
Icon: VscodeIcon,
|
|
58
|
+
value: 'connectVsCode',
|
|
59
|
+
},
|
|
34
60
|
{
|
|
35
61
|
label: 'Open in ChatGPT',
|
|
36
62
|
description: 'Ask questions about this page',
|
|
@@ -54,6 +80,8 @@ const DROPDOWN_OPTIONS = [
|
|
|
54
80
|
},
|
|
55
81
|
];
|
|
56
82
|
|
|
83
|
+
const MCP_SERVER_URL = 'https://mcp.apify.com/?tools=docs';
|
|
84
|
+
|
|
57
85
|
const getPrompt = (currentUrl) => `Read from ${currentUrl} so I can ask questions about it.`;
|
|
58
86
|
const getMarkdownUrl = (currentUrl) => {
|
|
59
87
|
const url = new URL(currentUrl);
|
|
@@ -161,6 +189,87 @@ const onCopyAsMarkdownClick = async ({ setCopyingStatus }) => {
|
|
|
161
189
|
}
|
|
162
190
|
};
|
|
163
191
|
|
|
192
|
+
const onCopyMcpServerUrlClick = async () => {
|
|
193
|
+
if (window.analytics) {
|
|
194
|
+
window.analytics.track('Clicked', {
|
|
195
|
+
app: 'docs',
|
|
196
|
+
button_text: 'Copy MCP server',
|
|
197
|
+
element: 'llm-buttons.copyMcpServer',
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
try {
|
|
202
|
+
await navigator.clipboard.writeText(MCP_SERVER_URL);
|
|
203
|
+
} catch (error) {
|
|
204
|
+
console.error('Failed to copy MCP configuration:', error);
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
const openApifyMcpConfigurator = (integration) => {
|
|
209
|
+
try {
|
|
210
|
+
window.open(`https://mcp.apify.com/?integration=${integration}`, '_blank');
|
|
211
|
+
} catch (error) {
|
|
212
|
+
console.error('Error opening fallback URL:', error);
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
const openMcpIntegration = async (integration) => {
|
|
217
|
+
// Try to open the app directly using URL scheme
|
|
218
|
+
let appUrl;
|
|
219
|
+
if (integration === 'cursor') {
|
|
220
|
+
// Cursor deeplink format:
|
|
221
|
+
// cursor://anysphere.cursor-deeplink/mcp/install?name=$NAME&config=$BASE64_JSON
|
|
222
|
+
const cursorConfig = {
|
|
223
|
+
url: MCP_SERVER_URL,
|
|
224
|
+
};
|
|
225
|
+
const encodedConfig = btoa(JSON.stringify(cursorConfig));
|
|
226
|
+
appUrl = `cursor://anysphere.cursor-deeplink/mcp/install?name=apify&config=${encodeURIComponent(encodedConfig)}`;
|
|
227
|
+
} else if (integration === 'vscode') {
|
|
228
|
+
// VS Code deeplink format: vscode:mcp/install?<url-encoded-json>
|
|
229
|
+
const mcpConfig = {
|
|
230
|
+
name: 'Apify',
|
|
231
|
+
type: 'http',
|
|
232
|
+
url: MCP_SERVER_URL,
|
|
233
|
+
};
|
|
234
|
+
const encodedConfig = encodeURIComponent(JSON.stringify(mcpConfig));
|
|
235
|
+
appUrl = `vscode:mcp/install?${encodedConfig}`;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
if (appUrl) {
|
|
239
|
+
const openedWindow = window.open(appUrl, '_blank');
|
|
240
|
+
|
|
241
|
+
if (openedWindow) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
// Fallback to web configurator if appUrl doesn't exist or window.open failed
|
|
246
|
+
openApifyMcpConfigurator(integration);
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
const onConnectCursorClick = () => {
|
|
250
|
+
if (window.analytics) {
|
|
251
|
+
window.analytics.track('Clicked', {
|
|
252
|
+
app: 'docs',
|
|
253
|
+
button_text: 'Connect to Cursor',
|
|
254
|
+
element: 'llm-buttons.connectCursor',
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
openMcpIntegration('cursor');
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
const onConnectVsCodeClick = () => {
|
|
262
|
+
if (window.analytics) {
|
|
263
|
+
window.analytics.track('Clicked', {
|
|
264
|
+
app: 'docs',
|
|
265
|
+
button_text: 'Connect to VS Code',
|
|
266
|
+
element: 'llm-buttons.connectVsCode',
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
openMcpIntegration('vscode');
|
|
271
|
+
};
|
|
272
|
+
|
|
164
273
|
const onViewAsMarkdownClick = () => {
|
|
165
274
|
if (window.analytics) {
|
|
166
275
|
window.analytics.track('Clicked', {
|
|
@@ -257,6 +366,15 @@ export default function LLMButtons({ isApiReferencePage = false }) {
|
|
|
257
366
|
case 'viewAsMarkdown':
|
|
258
367
|
onViewAsMarkdownClick();
|
|
259
368
|
break;
|
|
369
|
+
case 'copyMcpServerUrl':
|
|
370
|
+
onCopyMcpServerUrlClick();
|
|
371
|
+
break;
|
|
372
|
+
case 'connectCursor':
|
|
373
|
+
onConnectCursorClick();
|
|
374
|
+
break;
|
|
375
|
+
case 'connectVsCode':
|
|
376
|
+
onConnectVsCodeClick();
|
|
377
|
+
break;
|
|
260
378
|
case 'openInChatGPT':
|
|
261
379
|
onOpenInChatGPTClick();
|
|
262
380
|
break;
|
|
@@ -277,9 +395,9 @@ export default function LLMButtons({ isApiReferencePage = false }) {
|
|
|
277
395
|
[styles.llmMenuApiReferencePage]: isApiReferencePage,
|
|
278
396
|
})}
|
|
279
397
|
onMenuOpen={(isOpen) => chevronIconRef.current?.classList.toggle(
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
398
|
+
styles.chevronIconOpen,
|
|
399
|
+
isOpen,
|
|
400
|
+
)
|
|
283
401
|
}
|
|
284
402
|
components={{
|
|
285
403
|
MenuBase: (props) => (
|