mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-11-25 01:33:41 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e94fdd1572 | |||
| 6b4fdae0dd | |||
| 4f53fcfbed |
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Render Heading 4 blocks.
|
||||
@@ -342,6 +342,7 @@
|
||||
},
|
||||
"patchedDependencies": {
|
||||
"decode-named-character-reference@1.0.2": "patches/decode-named-character-reference@1.0.2.patch",
|
||||
"@gitbook/api@0.214.0": "patches/@gitbook%2Fapi@0.214.0.patch",
|
||||
"@shikijs/langs@3.21.0": "patches/@shikijs%2Flangs@3.21.0.patch",
|
||||
"mermaid@11.16.1": "patches/mermaid@11.16.1.patch",
|
||||
"next@16.4.6": "patches/next@16.4.6.patch",
|
||||
|
||||
+2
-1
@@ -69,6 +69,7 @@
|
||||
"@vercel/next@4.4.2": "patches/@vercel%2Fnext@4.4.2.patch",
|
||||
"mermaid@11.16.1": "patches/mermaid@11.16.1.patch",
|
||||
"next@16.4.6": "patches/next@16.4.6.patch",
|
||||
"@shikijs/langs@3.21.0": "patches/@shikijs%2Flangs@3.21.0.patch"
|
||||
"@shikijs/langs@3.21.0": "patches/@shikijs%2Flangs@3.21.0.patch",
|
||||
"@gitbook/api@0.214.0": "patches/@gitbook%2Fapi@0.214.0.patch"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ export function Block<T extends DocumentBlock>(props: BlockProps<T>) {
|
||||
case 'heading-1':
|
||||
case 'heading-2':
|
||||
case 'heading-3':
|
||||
case 'heading-4':
|
||||
return <Heading {...props} block={block} />;
|
||||
case 'list-ordered':
|
||||
case 'list-unordered':
|
||||
@@ -140,6 +141,7 @@ export function BlockSkeleton(props: { block: DocumentBlock; style: ClassValue }
|
||||
case 'heading-1':
|
||||
case 'heading-2':
|
||||
case 'heading-3':
|
||||
case 'heading-4':
|
||||
case 'file':
|
||||
return <SkeletonHeading id={id} style={style} />;
|
||||
case 'paragraph':
|
||||
|
||||
@@ -92,4 +92,5 @@ const TAGS: { [type in DocumentBlockHeading['type']]: React.ElementType } = {
|
||||
'heading-1': 'h2',
|
||||
'heading-2': 'h3',
|
||||
'heading-3': 'h4',
|
||||
'heading-4': 'h5',
|
||||
};
|
||||
|
||||
@@ -27,6 +27,7 @@ export function StepperStep(props: BlockProps<DocumentBlockStepperStep>) {
|
||||
case 'heading-2':
|
||||
return '-mt-[calc(1.25rem+1px)]';
|
||||
case 'heading-3':
|
||||
case 'heading-4':
|
||||
return '-mt-[calc(0.50rem+1px)]';
|
||||
default:
|
||||
return '';
|
||||
|
||||
@@ -35,6 +35,12 @@ export function getBlockTextStyle(block: DocumentBlock): {
|
||||
lineHeight: 'leading-snug',
|
||||
marginTop: 'column-first-of-type:pt-0 pt-[0.5em]',
|
||||
};
|
||||
case 'heading-4':
|
||||
return {
|
||||
textSize: 'text-base @xs:text-lg font-semibold',
|
||||
lineHeight: 'leading-snug',
|
||||
marginTop: 'column-first-of-type:pt-0 pt-[0.5em]',
|
||||
};
|
||||
case 'divider':
|
||||
return {
|
||||
textSize: '',
|
||||
|
||||
@@ -83,6 +83,7 @@ const getBlockHeight = memoize((block: DocumentBlock | undefined): number => {
|
||||
case 'heading-2':
|
||||
return 50;
|
||||
case 'heading-3':
|
||||
case 'heading-4':
|
||||
return 40;
|
||||
case 'paragraph':
|
||||
return 30;
|
||||
|
||||
@@ -237,8 +237,11 @@ describe('getDocumentSections', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it('nests heading-3 under the heading before it', async () => {
|
||||
const heading = (type: 'heading-1' | 'heading-2' | 'heading-3', id: string) => ({
|
||||
it('nests heading-3 under the heading before it and leaves heading-4 out', async () => {
|
||||
const heading = (
|
||||
type: 'heading-1' | 'heading-2' | 'heading-3' | 'heading-4',
|
||||
id: string
|
||||
) => ({
|
||||
object: 'block' as const,
|
||||
type,
|
||||
data: {},
|
||||
@@ -261,6 +264,7 @@ describe('getDocumentSections', () => {
|
||||
heading('heading-3', 'h3-under-h1'),
|
||||
heading('heading-2', 'h2'),
|
||||
heading('heading-3', 'h3-under-h1-h2'),
|
||||
heading('heading-4', 'h4-not-in-outline'),
|
||||
{
|
||||
object: 'block',
|
||||
type: 'stepper',
|
||||
@@ -272,7 +276,10 @@ describe('getDocumentSections', () => {
|
||||
type: 'stepper-step',
|
||||
data: {},
|
||||
isVoid: false,
|
||||
nodes: [heading('heading-3', 'h3-in-stepper')],
|
||||
nodes: [
|
||||
heading('heading-3', 'h3-in-stepper'),
|
||||
heading('heading-4', 'h4-in-stepper'),
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -183,6 +183,7 @@ const TEXT_ONLY_BLOCKS = new Set<DocumentBlock['type']>([
|
||||
'heading-1',
|
||||
'heading-2',
|
||||
'heading-3',
|
||||
'heading-4',
|
||||
]);
|
||||
|
||||
/**
|
||||
@@ -270,7 +271,7 @@ export function getBlocksByType<Type extends DocumentBlock['type']>(
|
||||
* Check if a block is a heading block.
|
||||
*/
|
||||
export function isHeadingBlock(block: DocumentBlock): block is DocumentBlockHeading {
|
||||
return ['heading-1', 'heading-2', 'heading-3'].includes(block.type);
|
||||
return ['heading-1', 'heading-2', 'heading-3', 'heading-4'].includes(block.type);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -133,6 +133,8 @@ function getNodeHTML(node: DocumentBlock | DocumentInline | DocumentText): strin
|
||||
return `<h3>${children}</h3>`;
|
||||
case 'heading-3':
|
||||
return `<h4>${children}</h4>`;
|
||||
case 'heading-4':
|
||||
return `<h5>${children}</h5>`;
|
||||
case 'list-unordered':
|
||||
case 'list-tasks':
|
||||
return `<ul>${children}</ul>`;
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
diff --git a/dist/client.d.ts b/dist/client.d.ts
|
||||
index a55c2aa43b1fe90f2050ef14607a42d4082cccf4..60e8a5fe17844652a1cf7cd368dbeb0c96708a23 100644
|
||||
--- a/dist/client.d.ts
|
||||
+++ b/dist/client.d.ts
|
||||
@@ -2496,7 +2496,7 @@ export interface DocumentBlockParagraph {
|
||||
export type DocumentInline = DocumentInlineLink | DocumentInlineEmoji | DocumentInlineIcon | DocumentInlineExpression | DocumentInlineMath | DocumentInlineImage | DocumentInlineAnnotation | DocumentInlineMention | DocumentInlineButton;
|
||||
export interface DocumentBlockHeading {
|
||||
object: "block";
|
||||
- type: "heading-1" | "heading-2" | "heading-3";
|
||||
+ type: "heading-1" | "heading-2" | "heading-3" | "heading-4";
|
||||
key?: string;
|
||||
nodes: (DocumentInline | DocumentText)[];
|
||||
data: {
|
||||
Reference in New Issue
Block a user