mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-10-03 12:10:34 +00:00
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import { DocumentInlineAnnotation } from '@gitbook/api';
|
|
|
|
import { getNodeFragmentByType } from '@/lib/document';
|
|
|
|
import { AnnotationPopover } from './AnnotationPopover';
|
|
import { Blocks } from '../Blocks';
|
|
import { InlineProps } from '../Inline';
|
|
import { Inlines } from '../Inlines';
|
|
|
|
export async function Annotation(props: InlineProps<DocumentInlineAnnotation>) {
|
|
const { inline, context, document, children } = props;
|
|
|
|
const fragment = getNodeFragmentByType(inline, 'annotation-body');
|
|
const content = children ?? (
|
|
<Inlines document={document} context={context} nodes={inline.nodes} ancestorInlines={[]} />
|
|
);
|
|
|
|
if (!fragment) {
|
|
return <>{content}</>;
|
|
}
|
|
|
|
return (
|
|
<AnnotationPopover
|
|
body={
|
|
<Blocks
|
|
document={document}
|
|
ancestorBlocks={[]}
|
|
context={context}
|
|
nodes={fragment.nodes}
|
|
style={['space-y-4']}
|
|
/>
|
|
}
|
|
>
|
|
{content}
|
|
</AnnotationPopover>
|
|
);
|
|
}
|