mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-17 16:15:22 +00:00
Fix Embed options in React (#3964)
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
"gitbook": patch
|
||||||
|
"@gitbook/embed": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix Embed options in React
|
||||||
@@ -11,13 +11,21 @@ import { useGitBook } from './GitBookProvider';
|
|||||||
export type GitBookFrameProps = {
|
export type GitBookFrameProps = {
|
||||||
className?: string;
|
className?: string;
|
||||||
} & GetFrameURLOptions &
|
} & GetFrameURLOptions &
|
||||||
GitBookEmbeddableConfiguration;
|
Partial<GitBookEmbeddableConfiguration>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render a frame with the GitBook Assistant in it.
|
* Render a frame with the GitBook Assistant in it.
|
||||||
*/
|
*/
|
||||||
export function GitBookFrame(props: GitBookFrameProps) {
|
export function GitBookFrame(props: GitBookFrameProps) {
|
||||||
const { className, visitor, actions, greeting, suggestions, tools } = props;
|
const {
|
||||||
|
className,
|
||||||
|
visitor,
|
||||||
|
actions = [],
|
||||||
|
greeting,
|
||||||
|
suggestions = [],
|
||||||
|
tools = [],
|
||||||
|
tabs = ['assistant', 'docs'],
|
||||||
|
} = props;
|
||||||
|
|
||||||
const frameRef = useRef<HTMLIFrameElement>(null);
|
const frameRef = useRef<HTMLIFrameElement>(null);
|
||||||
const gitbook = useGitBook();
|
const gitbook = useGitBook();
|
||||||
@@ -33,13 +41,13 @@ export function GitBookFrame(props: GitBookFrameProps) {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
gitbookFrame?.configure({
|
gitbookFrame?.configure({
|
||||||
tabs: ['assistant', 'docs'],
|
tabs,
|
||||||
actions,
|
actions,
|
||||||
greeting,
|
greeting,
|
||||||
suggestions,
|
suggestions,
|
||||||
tools,
|
tools,
|
||||||
});
|
});
|
||||||
}, [gitbookFrame, actions, greeting, suggestions, tools]);
|
}, [gitbookFrame, actions, greeting, suggestions, tools, tabs]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<iframe
|
<iframe
|
||||||
|
|||||||
Reference in New Issue
Block a user