@redocly/theme 0.59.0-next.10 → 0.59.0-next.12
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/lib/components/Buttons/ConnectMCPButton.d.ts +8 -0
- package/lib/components/Buttons/ConnectMCPButton.js +145 -0
- package/lib/components/Buttons/variables.d.ts +1 -0
- package/lib/components/Buttons/variables.js +41 -1
- package/lib/components/PageActions/PageActions.js +4 -1
- package/lib/components/PageActions/variables.js +2 -0
- package/lib/components/Segmented/Segmented.d.ts +1 -8
- package/lib/components/Segmented/Segmented.js +3 -1
- package/lib/core/constants/index.d.ts +1 -0
- package/lib/core/constants/index.js +1 -0
- package/lib/core/constants/mcp.d.ts +1 -0
- package/lib/core/constants/mcp.js +5 -0
- package/lib/core/hooks/index.d.ts +2 -0
- package/lib/core/hooks/index.js +2 -0
- package/lib/core/hooks/use-connect-mcp-button.d.ts +13 -0
- package/lib/core/hooks/use-connect-mcp-button.js +50 -0
- package/lib/core/hooks/use-mcp-config.d.ts +9 -0
- package/lib/core/hooks/use-mcp-config.js +27 -0
- package/lib/core/hooks/use-page-actions.d.ts +1 -1
- package/lib/core/hooks/use-page-actions.js +98 -95
- package/lib/core/openapi/index.d.ts +1 -0
- package/lib/core/styles/global.js +1 -0
- package/lib/core/types/index.d.ts +1 -0
- package/lib/core/types/index.js +1 -0
- package/lib/core/types/l10n.d.ts +1 -1
- package/lib/core/types/mcp.d.ts +6 -0
- package/lib/core/types/mcp.js +3 -0
- package/lib/core/types/segmented.d.ts +12 -0
- package/lib/core/types/segmented.js +3 -0
- package/lib/core/utils/index.d.ts +1 -0
- package/lib/core/utils/index.js +1 -0
- package/lib/core/utils/mcp.d.ts +2 -0
- package/lib/core/utils/mcp.js +31 -0
- package/lib/icons/ConnectIcon/ConnectIcon.d.ts +9 -0
- package/lib/icons/ConnectIcon/ConnectIcon.js +17 -0
- package/lib/icons/VSCodeIcon/VSCodeIcon.d.ts +9 -0
- package/lib/icons/VSCodeIcon/VSCodeIcon.js +17 -0
- package/lib/markdoc/components/ConnectMCP/ConnectMCP.d.ts +8 -0
- package/lib/markdoc/components/ConnectMCP/ConnectMCP.js +19 -0
- package/lib/markdoc/components/default.d.ts +1 -0
- package/lib/markdoc/components/default.js +1 -0
- package/lib/markdoc/default.d.ts +6 -0
- package/lib/markdoc/default.js +2 -0
- package/lib/markdoc/tags/connect-mcp.d.ts +2 -0
- package/lib/markdoc/tags/connect-mcp.js +27 -0
- package/package.json +3 -3
- package/src/components/Buttons/ConnectMCPButton.tsx +180 -0
- package/src/components/Buttons/variables.ts +41 -0
- package/src/components/PageActions/PageActions.tsx +5 -1
- package/src/components/PageActions/variables.ts +2 -0
- package/src/components/Segmented/Segmented.tsx +15 -20
- package/src/core/constants/index.ts +1 -0
- package/src/core/constants/mcp.ts +1 -0
- package/src/core/hooks/index.ts +2 -0
- package/src/core/hooks/use-connect-mcp-button.ts +79 -0
- package/src/core/hooks/use-mcp-config.ts +43 -0
- package/src/core/hooks/use-page-actions.ts +148 -126
- package/src/core/openapi/index.ts +1 -0
- package/src/core/styles/global.ts +2 -1
- package/src/core/types/index.ts +1 -0
- package/src/core/types/l10n.ts +9 -0
- package/src/core/types/mcp.ts +8 -0
- package/src/core/types/segmented.ts +14 -0
- package/src/core/utils/index.ts +1 -0
- package/src/core/utils/mcp.ts +34 -0
- package/src/icons/ConnectIcon/ConnectIcon.tsx +27 -0
- package/src/icons/VSCodeIcon/VSCodeIcon.tsx +29 -0
- package/src/markdoc/components/ConnectMCP/ConnectMCP.tsx +28 -0
- package/src/markdoc/components/default.ts +1 -0
- package/src/markdoc/default.ts +2 -0
- package/src/markdoc/tags/connect-mcp.ts +25 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { JSX } from 'react';
|
|
2
|
+
import type { MCPOption } from '../../core/types';
|
|
3
|
+
export type ConnectMCPButtonProps = {
|
|
4
|
+
placement?: 'top' | 'bottom';
|
|
5
|
+
alignment?: 'start' | 'end';
|
|
6
|
+
options?: MCPOption[];
|
|
7
|
+
};
|
|
8
|
+
export declare function ConnectMCPButton({ placement, alignment, options, }: ConnectMCPButtonProps): JSX.Element;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.ConnectMCPButton = ConnectMCPButton;
|
|
40
|
+
const react_1 = __importStar(require("react"));
|
|
41
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
42
|
+
const Dropdown_1 = require("../../components/Dropdown/Dropdown");
|
|
43
|
+
const DropdownMenu_1 = require("../../components/Dropdown/DropdownMenu");
|
|
44
|
+
const DropdownMenuItem_1 = require("../../components/Dropdown/DropdownMenuItem");
|
|
45
|
+
const Button_1 = require("../../components/Button/Button");
|
|
46
|
+
const CursorIcon_1 = require("../../icons/CursorIcon/CursorIcon");
|
|
47
|
+
const VSCodeIcon_1 = require("../../icons/VSCodeIcon/VSCodeIcon");
|
|
48
|
+
const CopyIcon_1 = require("../../icons/CopyIcon/CopyIcon");
|
|
49
|
+
const CheckmarkFilledIcon_1 = require("../../icons/CheckmarkFilledIcon/CheckmarkFilledIcon");
|
|
50
|
+
const ConnectIcon_1 = require("../../icons/ConnectIcon/ConnectIcon");
|
|
51
|
+
const use_connect_mcp_button_1 = require("../../core/hooks/use-connect-mcp-button");
|
|
52
|
+
const hooks_1 = require("../../core/hooks");
|
|
53
|
+
const TriggerButton = react_1.default.memo(({ text }) => {
|
|
54
|
+
return (react_1.default.createElement(StyledButton, { variant: "secondary", icon: react_1.default.createElement(ConnectIcon_1.ConnectIcon, null) }, text));
|
|
55
|
+
});
|
|
56
|
+
const MENU_OPTIONS = [
|
|
57
|
+
{
|
|
58
|
+
key: 'cursor',
|
|
59
|
+
icon: CursorIcon_1.CursorIcon,
|
|
60
|
+
titleTranslationKey: 'page.actions.connectMcp.cursor',
|
|
61
|
+
titleDefault: 'Connect to Cursor',
|
|
62
|
+
descriptionTranslationKey: 'page.actions.connectMcp.cursorDescription',
|
|
63
|
+
descriptionDefault: 'Install MCP server on Cursor',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
key: 'vscode',
|
|
67
|
+
icon: VSCodeIcon_1.VSCodeIcon,
|
|
68
|
+
titleTranslationKey: 'page.actions.connectMcp.vscode',
|
|
69
|
+
titleDefault: 'Connect to VS Code',
|
|
70
|
+
descriptionTranslationKey: 'page.actions.connectMcp.vscodeDescription',
|
|
71
|
+
descriptionDefault: 'Install MCP server on VS Code',
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
key: 'copy',
|
|
75
|
+
icon: CopyIcon_1.CopyIcon,
|
|
76
|
+
titleTranslationKey: 'page.actions.connectMcp.copyConfig',
|
|
77
|
+
titleDefault: 'Copy MCP Configuration',
|
|
78
|
+
descriptionTranslationKey: 'page.actions.connectMcp.copyConfigDescription',
|
|
79
|
+
descriptionDefault: 'Copy MCP JSON Configuration',
|
|
80
|
+
},
|
|
81
|
+
];
|
|
82
|
+
function ConnectMCPButton({ placement = 'bottom', alignment = 'end', options = ['cursor', 'vscode', 'copy'], }) {
|
|
83
|
+
const { useTranslate } = (0, hooks_1.useThemeHooks)();
|
|
84
|
+
const { translate } = useTranslate();
|
|
85
|
+
const { isCopied, triggerButtonText, visibleOptions, handleAction } = (0, use_connect_mcp_button_1.useConnectMCPButton)({
|
|
86
|
+
options,
|
|
87
|
+
});
|
|
88
|
+
const menuOptions = (0, react_1.useMemo)(() => MENU_OPTIONS.filter((option) => visibleOptions.includes(option.key)), [visibleOptions]);
|
|
89
|
+
return (react_1.default.createElement(ConnectMCPButtonWrapper, { "data-component-name": "Buttons/ConnectMCPButton" },
|
|
90
|
+
react_1.default.createElement(Dropdown_1.Dropdown, { trigger: react_1.default.createElement(TriggerButton, { text: triggerButtonText }), triggerEvent: "hover", placement: placement, alignment: alignment, closeOnClick: false },
|
|
91
|
+
react_1.default.createElement(DropdownMenu_1.DropdownMenu, null, menuOptions.map((option) => {
|
|
92
|
+
const Icon = option.icon;
|
|
93
|
+
const showCheckmark = option.key === 'copy' && isCopied;
|
|
94
|
+
return (react_1.default.createElement(DropdownMenuItem_1.DropdownMenuItem, { key: option.key, onAction: () => handleAction(option.key) },
|
|
95
|
+
react_1.default.createElement(MenuItemContent, null,
|
|
96
|
+
react_1.default.createElement(MenuItemIcon, null, showCheckmark ? (react_1.default.createElement(CheckmarkFilledIcon_1.CheckmarkFilledIcon, { color: "var(--color-success-base)" })) : (react_1.default.createElement(Icon, null))),
|
|
97
|
+
react_1.default.createElement(MenuItemText, null,
|
|
98
|
+
react_1.default.createElement(MenuItemTitle, null, translate(option.titleTranslationKey, option.titleDefault)),
|
|
99
|
+
react_1.default.createElement(MenuItemDescription, null, translate(option.descriptionTranslationKey, option.descriptionDefault))))));
|
|
100
|
+
})))));
|
|
101
|
+
}
|
|
102
|
+
const ConnectMCPButtonWrapper = styled_components_1.default.div `
|
|
103
|
+
display: inline-block;
|
|
104
|
+
position: relative;
|
|
105
|
+
`;
|
|
106
|
+
const StyledButton = (0, styled_components_1.default)(Button_1.Button) `
|
|
107
|
+
--button-gap: var(--connect-mcp-button-gap);
|
|
108
|
+
`;
|
|
109
|
+
const MenuItemContent = styled_components_1.default.div `
|
|
110
|
+
display: flex;
|
|
111
|
+
align-items: center;
|
|
112
|
+
gap: var(--connect-mcp-button-menu-item-gap);
|
|
113
|
+
padding: var(--connect-mcp-button-menu-item-padding-block)
|
|
114
|
+
var(--connect-mcp-button-menu-item-padding-inline);
|
|
115
|
+
`;
|
|
116
|
+
const MenuItemIcon = styled_components_1.default.div `
|
|
117
|
+
display: flex;
|
|
118
|
+
align-items: center;
|
|
119
|
+
justify-content: center;
|
|
120
|
+
width: var(--connect-mcp-button-menu-item-icon-size);
|
|
121
|
+
height: var(--connect-mcp-button-menu-item-icon-size);
|
|
122
|
+
flex-shrink: 0;
|
|
123
|
+
border: var(--connect-mcp-button-menu-item-icon-border);
|
|
124
|
+
border-radius: var(--connect-mcp-button-menu-item-icon-border-radius);
|
|
125
|
+
color: var(--connect-mcp-button-menu-item-icon-color);
|
|
126
|
+
`;
|
|
127
|
+
const MenuItemText = styled_components_1.default.div `
|
|
128
|
+
display: flex;
|
|
129
|
+
flex-direction: column;
|
|
130
|
+
gap: var(--connect-mcp-button-menu-item-text-gap);
|
|
131
|
+
flex: 1;
|
|
132
|
+
`;
|
|
133
|
+
const MenuItemTitle = styled_components_1.default.div `
|
|
134
|
+
font-size: var(--connect-mcp-button-menu-item-title-font-size);
|
|
135
|
+
font-weight: var(--connect-mcp-button-menu-item-title-font-weight);
|
|
136
|
+
line-height: var(--connect-mcp-button-menu-item-title-line-height);
|
|
137
|
+
color: var(--connect-mcp-button-menu-item-title-color);
|
|
138
|
+
`;
|
|
139
|
+
const MenuItemDescription = styled_components_1.default.div `
|
|
140
|
+
font-size: var(--connect-mcp-button-menu-item-description-font-size);
|
|
141
|
+
font-weight: var(--connect-mcp-button-menu-item-description-font-weight);
|
|
142
|
+
line-height: var(--connect-mcp-button-menu-item-description-line-height);
|
|
143
|
+
color: var(--connect-mcp-button-menu-item-description-color);
|
|
144
|
+
`;
|
|
145
|
+
//# sourceMappingURL=ConnectMCPButton.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.aiAssistantButton = void 0;
|
|
3
|
+
exports.connectMCPButton = exports.aiAssistantButton = void 0;
|
|
4
4
|
const styled_components_1 = require("styled-components");
|
|
5
5
|
exports.aiAssistantButton = (0, styled_components_1.css) `
|
|
6
6
|
/**
|
|
@@ -48,4 +48,44 @@ exports.aiAssistantButton = (0, styled_components_1.css) `
|
|
|
48
48
|
/* Transition */
|
|
49
49
|
--ai-assistant-button-transition: box-shadow 0.3s ease, transform 0.2s ease;
|
|
50
50
|
`;
|
|
51
|
+
exports.connectMCPButton = (0, styled_components_1.css) `
|
|
52
|
+
/**
|
|
53
|
+
* @tokens Connect MCP Button
|
|
54
|
+
* @presenter Color
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
/* Button gap */
|
|
58
|
+
--connect-mcp-button-gap: var(--spacing-xs);
|
|
59
|
+
|
|
60
|
+
/* Menu item layout */
|
|
61
|
+
--connect-mcp-button-menu-item-gap: var(--spacing-sm);
|
|
62
|
+
--connect-mcp-button-menu-item-padding-block: var(--spacing-xxs);
|
|
63
|
+
--connect-mcp-button-menu-item-padding-inline: 0;
|
|
64
|
+
|
|
65
|
+
/* Menu item icon */
|
|
66
|
+
--connect-mcp-button-menu-item-icon-size: 32px;
|
|
67
|
+
--connect-mcp-button-menu-item-icon-border-color: var(--border-color-secondary);
|
|
68
|
+
--connect-mcp-button-menu-item-icon-border-style: solid;
|
|
69
|
+
--connect-mcp-button-menu-item-icon-border-width: 1px;
|
|
70
|
+
--connect-mcp-button-menu-item-icon-border: var(--connect-mcp-button-menu-item-icon-border-width)
|
|
71
|
+
var(--connect-mcp-button-menu-item-icon-border-style)
|
|
72
|
+
var(--connect-mcp-button-menu-item-icon-border-color);
|
|
73
|
+
--connect-mcp-button-menu-item-icon-border-radius: var(--border-radius);
|
|
74
|
+
--connect-mcp-button-menu-item-icon-color: var(--icon-color-secondary);
|
|
75
|
+
|
|
76
|
+
/* Menu item text */
|
|
77
|
+
--connect-mcp-button-menu-item-text-gap: var(--spacing-xxs);
|
|
78
|
+
|
|
79
|
+
/* Menu item title */
|
|
80
|
+
--connect-mcp-button-menu-item-title-font-size: var(--font-size-base);
|
|
81
|
+
--connect-mcp-button-menu-item-title-font-weight: var(--font-weight-regular);
|
|
82
|
+
--connect-mcp-button-menu-item-title-line-height: var(--line-height-base);
|
|
83
|
+
--connect-mcp-button-menu-item-title-color: var(--text-color-secondary);
|
|
84
|
+
|
|
85
|
+
/* Menu item description */
|
|
86
|
+
--connect-mcp-button-menu-item-description-font-size: var(--font-size-sm);
|
|
87
|
+
--connect-mcp-button-menu-item-description-font-weight: var(--font-weight-regular);
|
|
88
|
+
--connect-mcp-button-menu-item-description-line-height: var(--line-height-sm);
|
|
89
|
+
--connect-mcp-button-menu-item-description-color: var(--text-color-description);
|
|
90
|
+
`;
|
|
51
91
|
//# sourceMappingURL=variables.js.map
|
|
@@ -86,7 +86,7 @@ function PageActions(props) {
|
|
|
86
86
|
react_1.default.createElement(ButtonGroup_1.ButtonGroup, { variant: "outlined", size: "medium" },
|
|
87
87
|
react_1.default.createElement(Button_1.Button, { icon: renderIcon(buttonAction, actionState), to: 'link' in buttonAction ? buttonAction.link : undefined, external: true, onClick: () => handleActionClick(buttonAction) }, buttonAction.buttonText),
|
|
88
88
|
actions.length > 1 ? (react_1.default.createElement(Dropdown_1.Dropdown, { withArrow: true, trigger: react_1.default.createElement(Button_1.Button, null), placement: "bottom", alignment: "end" },
|
|
89
|
-
react_1.default.createElement(
|
|
89
|
+
react_1.default.createElement(StyledDropdownMenu, { items: menuItems }))) : null)));
|
|
90
90
|
}
|
|
91
91
|
function renderIcon(buttonAction, actionState) {
|
|
92
92
|
switch (actionState) {
|
|
@@ -111,4 +111,7 @@ const LinkMenuItem = (0, styled_components_1.default)(Link_1.Link) `
|
|
|
111
111
|
text-decoration: none;
|
|
112
112
|
--link-decoration-hover: none;
|
|
113
113
|
`;
|
|
114
|
+
const StyledDropdownMenu = (0, styled_components_1.default)(DropdownMenu_1.DropdownMenu) `
|
|
115
|
+
--dropdown-menu-max-height: var(--page-actions-dropdown-max-height);
|
|
116
|
+
`;
|
|
114
117
|
//# sourceMappingURL=PageActions.js.map
|
|
@@ -9,6 +9,8 @@ exports.pageActions = (0, styled_components_1.css) `
|
|
|
9
9
|
--page-actions-button-text-color: var(--text-color-secondary);
|
|
10
10
|
--page-actions-button-padding: 5px 14px 5px var(--spacing-sm);
|
|
11
11
|
|
|
12
|
+
--page-actions-dropdown-max-height: fit-content;
|
|
13
|
+
|
|
12
14
|
--page-actions-menu-item-padding: 3px 0;
|
|
13
15
|
--page-actions-menu-item-gap: var(--spacing-xs);
|
|
14
16
|
--page-actions-menu-item-icon-color: var(--icon-color-secondary);
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import type { ForwardedRef, ReactElement } from 'react';
|
|
2
|
-
import type {
|
|
3
|
-
export type SegmentedProps<T> = {
|
|
4
|
-
options: SelectOption<T>[];
|
|
5
|
-
value: T;
|
|
6
|
-
onChange: ({ label, value }: SelectOption<T>) => void;
|
|
7
|
-
className?: string;
|
|
8
|
-
size?: 'regular' | 'small';
|
|
9
|
-
};
|
|
2
|
+
import type { SegmentedProps } from '../../core/types/segmented';
|
|
10
3
|
export declare const Segmented: <T>(props: SegmentedProps<T> & {
|
|
11
4
|
ref?: ForwardedRef<HTMLDivElement>;
|
|
12
5
|
}) => ReactElement;
|
|
@@ -38,7 +38,9 @@ const react_1 = __importStar(require("react"));
|
|
|
38
38
|
const styled_components_1 = __importStar(require("styled-components"));
|
|
39
39
|
const typedMemo_1 = require("../../core/hoc/typedMemo");
|
|
40
40
|
function SegmentedComponent({ options, onChange, value, className = '', size = 'regular' }, ref) {
|
|
41
|
-
return (react_1.default.createElement(SegmentedGroup, { ref: ref, "data-component-name": "Segmented/Segmented", className: `tag-grey ${size} ${className}`, role: "tablist" }, options.map((opt) => (react_1.default.createElement(
|
|
41
|
+
return (react_1.default.createElement(SegmentedGroup, { ref: ref, "data-component-name": "Segmented/Segmented", className: `tag-grey ${size} ${className}`, role: "tablist" }, options.map((opt, index) => (react_1.default.createElement(react_1.default.Fragment, { key: index },
|
|
42
|
+
opt.divider,
|
|
43
|
+
react_1.default.createElement(SegmentedItem, { key: opt.label, role: "tab", title: opt.label, onClick: () => onChange(opt), "$isActive": value == opt.value, "$size": size }, opt.element || opt.label))))));
|
|
42
44
|
}
|
|
43
45
|
exports.Segmented = (0, typedMemo_1.typedMemo)((0, react_1.forwardRef)(SegmentedComponent));
|
|
44
46
|
const SegmentedGroup = styled_components_1.default.div `
|
|
@@ -20,4 +20,5 @@ __exportStar(require("./code-walkthrough"), exports);
|
|
|
20
20
|
__exportStar(require("./search"), exports);
|
|
21
21
|
__exportStar(require("./catalog"), exports);
|
|
22
22
|
__exportStar(require("./breadcrumb"), exports);
|
|
23
|
+
__exportStar(require("./mcp"), exports);
|
|
23
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DEFAULT_MCP_SERVER_NAME = "mcp-server";
|
package/lib/core/hooks/index.js
CHANGED
|
@@ -59,4 +59,6 @@ __exportStar(require("./use-active-page-version"), exports);
|
|
|
59
59
|
__exportStar(require("./use-page-versions"), exports);
|
|
60
60
|
__exportStar(require("./use-user-teams"), exports);
|
|
61
61
|
__exportStar(require("./use-page-actions"), exports);
|
|
62
|
+
__exportStar(require("./use-mcp-config"), exports);
|
|
63
|
+
__exportStar(require("./use-connect-mcp-button"), exports);
|
|
62
64
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { MCPOption } from '../types';
|
|
2
|
+
export type McpButtonOptions = {
|
|
3
|
+
options?: MCPOption[];
|
|
4
|
+
};
|
|
5
|
+
export type McpButtonSettings = {
|
|
6
|
+
isCopied: boolean;
|
|
7
|
+
cursorUrl: string;
|
|
8
|
+
vscodeUrl: string;
|
|
9
|
+
triggerButtonText: string;
|
|
10
|
+
visibleOptions: MCPOption[];
|
|
11
|
+
handleAction: (action: MCPOption) => void;
|
|
12
|
+
};
|
|
13
|
+
export declare function useConnectMCPButton({ options, }?: McpButtonOptions): McpButtonSettings;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.useConnectMCPButton = useConnectMCPButton;
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const lodash_debounce_1 = __importDefault(require("lodash.debounce"));
|
|
9
|
+
const use_theme_hooks_1 = require("./use-theme-hooks");
|
|
10
|
+
const use_mcp_config_1 = require("./use-mcp-config");
|
|
11
|
+
const clipboard_service_1 = require("../utils/clipboard-service");
|
|
12
|
+
const COPIED_RESET_TIMEOUT = 1000;
|
|
13
|
+
function useConnectMCPButton({ options = ['cursor', 'vscode', 'copy'], } = {}) {
|
|
14
|
+
const { useTranslate } = (0, use_theme_hooks_1.useThemeHooks)();
|
|
15
|
+
const { translate } = useTranslate();
|
|
16
|
+
const { serverName, serverUrl, cursorUrl, vscodeUrl } = (0, use_mcp_config_1.useMCPConfig)();
|
|
17
|
+
const [isCopied, setIsCopied] = (0, react_1.useState)(false);
|
|
18
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
19
|
+
const resetCopied = (0, react_1.useCallback)((0, lodash_debounce_1.default)(() => setIsCopied(false), COPIED_RESET_TIMEOUT), []);
|
|
20
|
+
const handleAction = (0, react_1.useCallback)((action) => {
|
|
21
|
+
if (action === 'copy') {
|
|
22
|
+
const config = {
|
|
23
|
+
[serverName]: {
|
|
24
|
+
url: serverUrl,
|
|
25
|
+
description: 'MCP Server',
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
clipboard_service_1.ClipboardService.copyCustom(JSON.stringify(config, null, 2));
|
|
29
|
+
setIsCopied(true);
|
|
30
|
+
resetCopied();
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const urlMap = {
|
|
34
|
+
cursor: cursorUrl,
|
|
35
|
+
vscode: vscodeUrl,
|
|
36
|
+
};
|
|
37
|
+
window.open(urlMap[action], '_blank');
|
|
38
|
+
}, [cursorUrl, vscodeUrl, serverUrl, serverName, resetCopied]);
|
|
39
|
+
const triggerButtonText = (0, react_1.useMemo)(() => translate('page.actions.connectMcp', 'Connect MCP'), [translate]);
|
|
40
|
+
const visibleOptions = (0, react_1.useMemo)(() => options.filter(Boolean), [options]);
|
|
41
|
+
return {
|
|
42
|
+
isCopied,
|
|
43
|
+
cursorUrl,
|
|
44
|
+
vscodeUrl,
|
|
45
|
+
triggerButtonText,
|
|
46
|
+
visibleOptions,
|
|
47
|
+
handleAction,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=use-connect-mcp-button.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useMCPConfig = useMCPConfig;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const use_theme_config_1 = require("./use-theme-config");
|
|
6
|
+
const dom_1 = require("../utils/dom");
|
|
7
|
+
const constants_1 = require("../constants");
|
|
8
|
+
const mcp_1 = require("../utils/mcp");
|
|
9
|
+
function useMCPConfig() {
|
|
10
|
+
var _a, _b, _c, _d, _e;
|
|
11
|
+
const themeConfig = (0, use_theme_config_1.useThemeConfig)();
|
|
12
|
+
const origin = dom_1.IS_BROWSER ? window.location.origin : globalThis['SSR_HOSTNAME'];
|
|
13
|
+
const serverName = ((_b = (_a = themeConfig.mcp) === null || _a === void 0 ? void 0 : _a.docs) === null || _b === void 0 ? void 0 : _b.name) || constants_1.DEFAULT_MCP_SERVER_NAME;
|
|
14
|
+
const serverUrl = `${origin}/mcp`;
|
|
15
|
+
const isMcpDisabled = ((_c = themeConfig.mcp) === null || _c === void 0 ? void 0 : _c.hide) || ((_e = (_d = themeConfig.mcp) === null || _d === void 0 ? void 0 : _d.docs) === null || _e === void 0 ? void 0 : _e.hide) || false;
|
|
16
|
+
const cursorUrl = (0, react_1.useMemo)(() => (0, mcp_1.generateMCPDeepLink)('cursor', { serverName, url: serverUrl }), [serverName, serverUrl]);
|
|
17
|
+
const vscodeUrl = (0, react_1.useMemo)(() => (0, mcp_1.generateMCPDeepLink)('vscode', { serverName, url: serverUrl }), [serverName, serverUrl]);
|
|
18
|
+
return {
|
|
19
|
+
serverName,
|
|
20
|
+
origin,
|
|
21
|
+
serverUrl,
|
|
22
|
+
cursorUrl,
|
|
23
|
+
vscodeUrl,
|
|
24
|
+
isMcpDisabled,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=use-mcp-config.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { PageAction } from '../types';
|
|
2
|
-
export type PageActionType = 'copy' | 'view' | 'chatgpt' | 'claude' | 'mcp-cursor';
|
|
2
|
+
export type PageActionType = 'copy' | 'view' | 'chatgpt' | 'claude' | 'docs-mcp-cursor' | 'docs-mcp-vscode' | 'mcp-cursor' | 'mcp-vscode';
|
|
3
3
|
export declare function usePageActions(pageSlug: string, mcpUrl?: string, actions?: PageActionType[]): PageAction[];
|