Files
gitbook/src/components/DocumentView/DocumentView.tsx
T
Samy Pessé 24f5e73bbe PDF export (#72)
* Start

* Improve generation

* Improve style

* Lint

* Use tilde instead of dot in the url

* Improve style

* Fix page group

* Format

* Add visual tests for PDF
2023-12-26 18:36:44 +01:00

57 lines
1.2 KiB
TypeScript

import { ContentRef, JSONDocument } from '@gitbook/api';
import { ContentPointer } from '@/lib/api';
import { ResolvedContentRef } from '@/lib/references';
import { ClassValue } from '@/lib/tailwind';
import { Blocks } from './Blocks';
export interface DocumentContext {
/**
* Content being rendered.
*/
content?: ContentPointer;
/**
* Resolve a content reference.
*/
resolveContentRef: (ref: ContentRef) => Promise<ResolvedContentRef | null>;
/**
* Transform an ID to be added to the DOM.
*/
getId?: (id: string) => string;
}
export interface DocumentContextProps {
context: DocumentContext;
}
/**
* Render an entire document.
*/
export function DocumentView(
props: DocumentContextProps & {
document: JSONDocument;
/** Style passed to the container */
style?: ClassValue;
/** Style passed to all blocks */
blockStyle?: ClassValue;
},
) {
const { document, style, blockStyle = [], context } = props;
return (
<Blocks
nodes={document.nodes}
document={document}
ancestorBlocks={[]}
blockStyle={blockStyle}
style={['space-y-6', style]}
context={context}
/>
);
}