From 55464029d40c0ccdce710cdadbf171b683f142c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samy=20Pess=C3=A9?= Date: Mon, 30 Oct 2023 18:59:17 -0400 Subject: [PATCH] Add support for quote --- src/components/DocumentView/Block.tsx | 71 +++++++++++++++++++++------ src/components/DocumentView/Quote.tsx | 16 ++++++ 2 files changed, 71 insertions(+), 16 deletions(-) create mode 100644 src/components/DocumentView/Quote.tsx diff --git a/src/components/DocumentView/Block.tsx b/src/components/DocumentView/Block.tsx index 1a781ef1c..3c4b11e28 100644 --- a/src/components/DocumentView/Block.tsx +++ b/src/components/DocumentView/Block.tsx @@ -14,44 +14,83 @@ import { Expandable } from './Expandable'; import { Table } from './Table'; import { Swagger } from './Swagger'; import { Embed } from './Embed'; +import { Quote } from './Quote'; +import { + DocumentBlockCode, + DocumentBlockEmbed, + DocumentBlockExpandable, + DocumentBlockHeading, + DocumentBlockHint, + DocumentBlockImages, + DocumentBlockListItem, + DocumentBlockListOrdered, + DocumentBlockListTasks, + DocumentBlockListUnordered, + DocumentBlockParagraph, + DocumentBlockQuote, + DocumentBlockSwagger, + DocumentBlockTable, + DocumentBlockTabs, + DocumentBlockTaskListItem, +} from '@gitbook/api'; -export interface BlockProps extends DocumentContextProps { - block: T; +export type SupportedBlock = + | DocumentBlockParagraph + | DocumentBlockHeading + | DocumentBlockListOrdered + | DocumentBlockListUnordered + | DocumentBlockListTasks + | DocumentBlockListItem + | DocumentBlockTaskListItem + | DocumentBlockHint + | DocumentBlockCode + | DocumentBlockImages + | DocumentBlockTabs + | DocumentBlockExpandable + | DocumentBlockSwagger + | DocumentBlockTable + | DocumentBlockEmbed + | DocumentBlockQuote; + +export interface BlockProps extends DocumentContextProps { + block: Block; style?: ClassValue; } -export function Block(props: BlockProps) { +export function Block(props: BlockProps) { const { block, style, ...contextProps } = props; switch (block.type) { case 'paragraph': - return ; + return ; case 'heading-1': case 'heading-2': case 'heading-3': - return ; + return ; case 'list-ordered': - return ; + return ; case 'list-unordered': - return ; + return ; case 'list-item': - return ; + return ; case 'code': - return ; + return ; case 'hint': - return ; + return ; case 'images': - return ; + return ; case 'tabs': - return ; + return ; case 'expandable': - return ; + return ; case 'table': - return ; + return
; case 'swagger': - return ; + return ; case 'embed': - return ; + return ; + case 'blockquote': + return ; default: return
Unsupported block {block.type}
; } diff --git a/src/components/DocumentView/Quote.tsx b/src/components/DocumentView/Quote.tsx new file mode 100644 index 000000000..b7e6130c3 --- /dev/null +++ b/src/components/DocumentView/Quote.tsx @@ -0,0 +1,16 @@ +import { BlockProps } from './Block'; +import { Blocks } from './Blocks'; +import { DocumentBlockQuote } from '@gitbook/api'; + +export function Quote(props: BlockProps) { + const { block, style, ...contextProps } = props; + + return ( + + ); +}