Files
gitbook/src/components/DocumentView/Inlines.tsx
T
Samy Pessé ff773233dd Prevent click on images in links to zoom it (#324)
* Prevent click on images in links to zoom it

* Fix TS
2024-03-22 16:56:08 +01:00

47 lines
1.2 KiB
TypeScript

import { DocumentInline, DocumentText, JSONDocument } from '@gitbook/api';
import { DocumentContextProps } from './DocumentView';
import { Inline } from './Inline';
import { Text } from './Text';
export function Inlines<T extends DocumentInline | DocumentText>(
props: DocumentContextProps & {
/**
* Document being rendered.
*/
document: JSONDocument;
/**
* Ancestors of the current inline.
*/
ancestorInlines: DocumentInline[];
/**
* Nodes to render
*/
nodes: T[];
},
) {
const { nodes, document, ancestorInlines, ...contextProps } = props;
return (
<>
{nodes.map((node, index) => {
if (node.object === 'text') {
return <Text key={node.key} text={node} />;
}
return (
<Inline
key={node.key}
inline={node}
document={document}
ancestorInlines={ancestorInlines}
{...contextProps}
/>
);
})}
</>
);
}