88} from '@/components/AIActions/AIActions' ;
99import { Button } from '@/components/primitives/Button' ;
1010import { DropdownMenu } from '@/components/primitives/DropdownMenu' ;
11+ import type { SiteCustomizationSettings } from '@gitbook/api' ;
1112
1213import { Icon } from '@gitbook/icons' ;
1314import { useRef } from 'react' ;
@@ -16,10 +17,7 @@ interface AIActionsDropdownProps {
1617 markdownPageUrl : string ;
1718 withAIChat ?: boolean ;
1819 trademark : boolean ;
19- /**
20- * Whether to include the "Open in LLM" entries in the dropdown menu.
21- */
22- withLLMActions ?: boolean ;
20+ actions : SiteCustomizationSettings [ 'pageActions' ] ;
2321}
2422
2523/**
@@ -59,22 +57,26 @@ export function AIActionsDropdown(props: AIActionsDropdownProps) {
5957 * The content of the dropdown menu.
6058 */
6159function AIActionsDropdownMenuContent ( props : AIActionsDropdownProps ) {
62- const { markdownPageUrl, withAIChat, trademark, withLLMActions } = props ;
60+ const { markdownPageUrl, withAIChat, trademark, actions } = props ;
6361
6462 return (
6563 < >
6664 { withAIChat ? (
6765 < OpenDocsAssistant trademark = { trademark } type = "dropdown-menu-item" />
6866 ) : null }
6967
70- < CopyMarkdown
71- isDefaultAction = { ! withAIChat }
72- markdownPageUrl = { markdownPageUrl }
73- type = "dropdown-menu-item"
74- />
75- < ViewAsMarkdown markdownPageUrl = { markdownPageUrl } type = "dropdown-menu-item" />
68+ { actions . markdown ? (
69+ < >
70+ < CopyMarkdown
71+ isDefaultAction = { ! withAIChat }
72+ markdownPageUrl = { markdownPageUrl }
73+ type = "dropdown-menu-item"
74+ />
75+ < ViewAsMarkdown markdownPageUrl = { markdownPageUrl } type = "dropdown-menu-item" />
76+ </ >
77+ ) : null }
7678
77- { withLLMActions ? (
79+ { actions . externalAI ? (
7880 < >
7981 < OpenInLLM provider = "chatgpt" url = { markdownPageUrl } type = "dropdown-menu-item" />
8082 < OpenInLLM provider = "claude" url = { markdownPageUrl } type = "dropdown-menu-item" />
@@ -88,17 +90,27 @@ function AIActionsDropdownMenuContent(props: AIActionsDropdownProps) {
8890 * A default action shown as a quick-access button beside the dropdown menu
8991 */
9092function DefaultAction ( props : AIActionsDropdownProps ) {
91- const { markdownPageUrl, withAIChat, trademark } = props ;
93+ const { markdownPageUrl, withAIChat, trademark, actions } = props ;
9294
9395 if ( withAIChat ) {
9496 return < OpenDocsAssistant trademark = { trademark } type = "button" /> ;
9597 }
9698
97- return (
98- < CopyMarkdown
99- isDefaultAction = { ! withAIChat }
100- markdownPageUrl = { markdownPageUrl }
101- type = "button"
102- />
103- ) ;
99+ if ( actions . markdown ) {
100+ return (
101+ < CopyMarkdown
102+ isDefaultAction = { ! withAIChat }
103+ markdownPageUrl = { markdownPageUrl }
104+ type = "button"
105+ />
106+ ) ;
107+ }
108+
109+ if ( actions . externalAI ) {
110+ return (
111+ < >
112+ < OpenInLLM provider = "chatgpt" url = { markdownPageUrl } type = "button" />
113+ </ >
114+ ) ;
115+ }
104116}
0 commit comments