mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-19 09:06:03 +00:00
Add link to generate links in PDF mode
This commit is contained in:
@@ -4,14 +4,15 @@ import { BlockProps } from './Block';
|
||||
import { Inlines } from './Inlines';
|
||||
import { DocumentBlockHeading } from '@gitbook/api';
|
||||
import { getBlockTextStyle } from './spacing';
|
||||
import { pageLocalId } from '@/lib/links';
|
||||
|
||||
export function Heading(props: BlockProps<DocumentBlockHeading>) {
|
||||
const { block, style, ...contextProps } = props;
|
||||
const { block, style, context, ...rest } = props;
|
||||
|
||||
const textStyle = getBlockTextStyle(block);
|
||||
const Tag = TAGS[block.type];
|
||||
|
||||
const id = block.meta?.id ?? '';
|
||||
const id = pageLocalId(context.page, block.meta?.id ?? '', context);
|
||||
|
||||
return (
|
||||
<Tag id={id} className={tcls(textStyle.textSize, 'group', 'relative', style)}>
|
||||
@@ -56,7 +57,7 @@ export function Heading(props: BlockProps<DocumentBlockHeading>) {
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<Inlines {...contextProps} nodes={block.nodes} />
|
||||
<Inlines {...rest} context={context} nodes={block.nodes} />
|
||||
</Tag>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import { Inlines } from './Inlines';
|
||||
import { DocumentBlockImage, DocumentBlockImages } from '@gitbook/api';
|
||||
|
||||
export function Images(props: BlockProps<DocumentBlockImages>) {
|
||||
const { block, style, ...contextProps } = props;
|
||||
const { block, style, context } = props;
|
||||
|
||||
return (
|
||||
<div
|
||||
@@ -28,7 +28,7 @@ export function Images(props: BlockProps<DocumentBlockImages>) {
|
||||
block={node}
|
||||
style={[i > 0 && 'mt-4', style]}
|
||||
siblings={block.nodes.length}
|
||||
{...contextProps}
|
||||
context={context}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -9,19 +9,19 @@ export async function RecordCard(
|
||||
record: TableRecordKV;
|
||||
},
|
||||
) {
|
||||
const { block, view, record } = props;
|
||||
const { block, view, record, context } = props;
|
||||
|
||||
const coverFile = view.coverDefinition
|
||||
? (record[1].values[view.coverDefinition]?.[0] as string)
|
||||
: null;
|
||||
const cover = coverFile
|
||||
? await resolveContentRef({ kind: 'file', file: coverFile }, props.context)
|
||||
? await resolveContentRef({ kind: 'file', file: coverFile }, context)
|
||||
: null;
|
||||
|
||||
const targetRef = view.targetDefinition
|
||||
? (record[1].values[view.targetDefinition] as ContentRef)
|
||||
: null;
|
||||
const target = targetRef ? await resolveContentRef(targetRef, props.context) : null;
|
||||
const target = targetRef ? await resolveContentRef(targetRef, context) : null;
|
||||
|
||||
const body = (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user