mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-10-20 12:19:01 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| dd9179db11 | |||
| 90f6a3cc89 |
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Adjust tab panel and tab button padding so tabbed content has more breathing room.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Track `ask_trigger_click` insights event when an Ask entry point is clicked.
|
||||
@@ -1,7 +1,6 @@
|
||||
'use client';
|
||||
import type { Assistant } from '../AI';
|
||||
import { useIsMobile } from '../hooks/useIsMobile';
|
||||
import { useTrackEvent } from '../Insights';
|
||||
import { Button } from '../primitives';
|
||||
import { KeyboardShortcut } from '../primitives/KeyboardShortcut';
|
||||
import { useLanguage } from '@/intl/client';
|
||||
@@ -19,7 +18,6 @@ export function AIChatButton(props: {
|
||||
}) {
|
||||
const { assistant, showLabel = true, withShortcut = true } = props;
|
||||
const language = useLanguage();
|
||||
const trackEvent = useTrackEvent();
|
||||
const isMobile = useIsMobile(MOBILE_BREAKPOINT, '[data-gb-header-content]');
|
||||
|
||||
return (
|
||||
@@ -41,12 +39,7 @@ export function AIChatButton(props: {
|
||||
</div>
|
||||
}
|
||||
aria-label={tString(language, 'ai_chat_ask', assistant.label)}
|
||||
onClick={() => {
|
||||
if (assistant.id === 'gitbook-assistant') {
|
||||
trackEvent({ type: 'ask_trigger_click', trigger: 'site' });
|
||||
}
|
||||
assistant.open(undefined, 'site');
|
||||
}}
|
||||
onClick={() => assistant.open(undefined, 'site')}
|
||||
>
|
||||
{showLabel ? t(language, 'ask') : null}
|
||||
</Button>
|
||||
|
||||
@@ -6,7 +6,6 @@ import { createPortal } from 'react-dom';
|
||||
|
||||
import { AIChatIcon } from '../AIChatIcon';
|
||||
import { useAIChatController, useAIConfig } from '@/components/AI';
|
||||
import { useTrackEvent } from '@/components/Insights';
|
||||
import { Button } from '@/components/primitives';
|
||||
import { isAIChatEnabled } from '@/components/utils/isAIChatEnabled';
|
||||
import { t, tString, useLanguage } from '@/intl/client';
|
||||
@@ -25,7 +24,6 @@ export function AskAIParagraphButton() {
|
||||
const config = useAIConfig();
|
||||
const language = useLanguage();
|
||||
const chatController = useAIChatController();
|
||||
const trackEvent = useTrackEvent();
|
||||
const [target, setTarget] = React.useState<HTMLElement | null>(null);
|
||||
|
||||
const enabled = isAIChatEnabled(config.aiMode);
|
||||
@@ -54,7 +52,6 @@ export function AskAIParagraphButton() {
|
||||
}
|
||||
|
||||
const onClick = () => {
|
||||
trackEvent({ type: 'ask_trigger_click', trigger: 'hover' });
|
||||
const text = getParagraphText(target).trim();
|
||||
if (!text) {
|
||||
return;
|
||||
|
||||
@@ -10,7 +10,6 @@ import { useStableTextSelection } from './useStableTextSelection';
|
||||
import { useAIChatController, useAIConfig } from '@/components/AI';
|
||||
import { useIsMobile } from '@/components/hooks/useIsMobile';
|
||||
import { useIsMounted } from '@/components/hooks/useIsMounted';
|
||||
import { useTrackEvent } from '@/components/Insights';
|
||||
import { Button } from '@/components/primitives';
|
||||
import { isAIChatEnabled } from '@/components/utils/isAIChatEnabled';
|
||||
import { t, useLanguage } from '@/intl/client';
|
||||
@@ -28,7 +27,6 @@ export function AskAITextSelection() {
|
||||
const config = useAIConfig();
|
||||
const language = useLanguage();
|
||||
const chatController = useAIChatController();
|
||||
const trackEvent = useTrackEvent();
|
||||
const isMobile = useIsMobile();
|
||||
const isMounted = useIsMounted();
|
||||
|
||||
@@ -73,7 +71,6 @@ export function AskAITextSelection() {
|
||||
}, [selection]);
|
||||
|
||||
const onClick = () => {
|
||||
trackEvent({ type: 'ask_trigger_click', trigger: 'selection' });
|
||||
if (!selection) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
import { getCodeTextFromId } from './utils';
|
||||
import { useAIChatController, useAIConfig } from '@/components/AI';
|
||||
import { AIChatIcon } from '@/components/AIChat';
|
||||
import { useTrackEvent } from '@/components/Insights';
|
||||
import { Button } from '@/components/primitives';
|
||||
import { isAIChatEnabled } from '@/components/utils/isAIChatEnabled';
|
||||
import { t, useLanguage } from '@/intl/client';
|
||||
@@ -20,14 +19,12 @@ export function AskAICodeButton(props: {
|
||||
const language = useLanguage();
|
||||
const config = useAIConfig();
|
||||
const chatController = useAIChatController();
|
||||
const trackEvent = useTrackEvent();
|
||||
|
||||
if (!isAIChatEnabled(config.aiMode)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const onClick = () => {
|
||||
trackEvent({ type: 'ask_trigger_click', trigger: 'code' });
|
||||
const codeText = getCodeTextFromId(codeId);
|
||||
if (!codeText?.trim()) {
|
||||
return;
|
||||
@@ -40,7 +37,7 @@ export function AskAICodeButton(props: {
|
||||
content: codeText,
|
||||
syntax,
|
||||
});
|
||||
chatController.open('code');
|
||||
chatController.open();
|
||||
chatController.focus();
|
||||
};
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ const TabPanel = memo(function TabPanel(props: {
|
||||
aria-labelledby={getTabButtonId(tab.id)}
|
||||
className="scroll-mt-[calc(var(--content-scroll-margin)+var(--spacing)*20)]"
|
||||
>
|
||||
<div className="p-4">{tab.body}</div>
|
||||
<div className="px-8 py-6">{tab.body}</div>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
@@ -317,7 +317,7 @@ function TabButton(
|
||||
{...rest}
|
||||
type="button"
|
||||
className={tcls(
|
||||
'relative inline-flex max-w-full items-center gap-1.5 px-3.5 py-2 font-medium text-sm transition-[color]',
|
||||
'relative inline-flex max-w-full items-center gap-1.5 px-4 py-2.5 font-medium text-sm transition-[color]',
|
||||
props.className
|
||||
)}
|
||||
/>
|
||||
|
||||
@@ -10,7 +10,6 @@ import { Icon, type IconName, IconStyle } from '@gitbook/icons';
|
||||
|
||||
import { useAIChatController, useAIChatState } from '@/components/AI';
|
||||
import type { Assistant } from '@/components/AI';
|
||||
import { useTrackEvent } from '@/components/Insights';
|
||||
import { Button } from '@/components/primitives/Button';
|
||||
import { DropdownMenuItem, useDropdownMenuClose } from '@/components/primitives/DropdownMenu';
|
||||
import { getURLForLLM } from '@/components/utils';
|
||||
@@ -40,7 +39,6 @@ export function ActionOpenAssistant(props: {
|
||||
const { assistant, type, page } = props;
|
||||
const chat = useAIChatState();
|
||||
const chatController = useAIChatController();
|
||||
const trackEvent = useTrackEvent();
|
||||
const language = useLanguage();
|
||||
|
||||
return (
|
||||
@@ -57,7 +55,6 @@ export function ActionOpenAssistant(props: {
|
||||
)}
|
||||
disabled={chat.responding}
|
||||
onClick={() => {
|
||||
trackEvent({ type: 'ask_trigger_click', trigger: 'page' });
|
||||
// Stage a reference to the current page so the assistant is informed about
|
||||
// the context the user is asking from. Only the sidebar GitBook Assistant
|
||||
// uses the chat reference system.
|
||||
|
||||
Reference in New Issue
Block a user