File tree Expand file tree Collapse file tree 15 files changed +84
-88
lines changed
Expand file tree Collapse file tree 15 files changed +84
-88
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " react-notion-blocks" ,
3- "version" : " 1.1.6 " ,
3+ "version" : " 1.1.8 " ,
44 "type" : " module" ,
55 "description" : " A library for mapping Notion blocks to React components" ,
66 "main" : " dist/index.js" ,
7- "module" : " dist/index.mjs " ,
7+ "module" : " dist/index.js " ,
88 "exports" : {
9- "import" : " ./dist/index.mjs " ,
9+ "import" : " ./dist/index.js " ,
1010 "require" : " ./dist/index.js" ,
1111 "default" : " ./dist/index.mjs"
1212 },
3636 ],
3737 "scripts" : {
3838 "dev" : " vite" ,
39- "build" : " tsc --build" ,
40- "build:app" : " tsc --build tsconfig.app.json" ,
39+ "build" : " tsc -b && vite build" ,
4140 "lint" : " eslint ." ,
4241 "preview" : " vite preview" ,
4342 "prepublishOnly" : " npm run build"
5554 }
5655 },
5756 "dependencies" : {
58- "@tailwindcss/vite" : " ^4.0.9" ,
5957 "prismjs" : " ^1.29.0"
6058 },
6159 "devDependencies" : {
6260 "@eslint/js" : " ^9.21.0" ,
61+ "@tailwindcss/vite" : " ^4.0.9" ,
6362 "@types/node" : " ^22.13.5" ,
6463 "@types/prismjs" : " ^1.26.5" ,
6564 "@types/react" : " ^19.0.10" ,
Original file line number Diff line number Diff line change 1+ import { BaseBlock } from "@/types" ;
2+ import { Paragraph } from "./Paragraph" ;
3+ import { ParagraphBlock } from "@/types/paragraph.types" ;
4+
5+ interface ChildrenProps {
6+ children : BaseBlock [ ] ;
7+ className ?: string
8+ }
9+
10+ export const Children = ( { children, className } : ChildrenProps ) => {
11+ if ( ! Array . isArray ( children ) || children . length === 0 ) {
12+ return null ;
13+ }
14+
15+ return (
16+ < div className = { `ml-4 ${ className } ` } >
17+ { children . map ( ( child ) => {
18+ switch ( child . type ) {
19+ case "paragraph" :
20+ return < Paragraph key = { child . id } block = { child as ParagraphBlock } /> ;
21+ default :
22+ return null ;
23+ }
24+ } ) }
25+ </ div >
26+ ) ;
27+ } ;
Original file line number Diff line number Diff line change 11// src/modules/notion-blocks/components/Paragraph.tsx
22import { ParagraphBlock } from "../types/paragraph.types" ;
3+ import { Children } from "./Children" ;
34import { RichText } from "./RichText" ;
45
56export const Paragraph = ( { block } : { block : ParagraphBlock } ) => {
@@ -9,8 +10,11 @@ export const Paragraph = ({ block }: { block: ParagraphBlock }) => {
910 }
1011
1112 return (
12- < p className = "text-base leading-relaxed mb-4" >
13- < RichText richText = { block . paragraph . rich_text } />
14- </ p >
13+ < div >
14+ < p className = "text-base leading-relaxed mb-4" >
15+ < RichText richText = { block . paragraph . rich_text } />
16+ </ p >
17+ { block . has_children && block . children && ( < Children className = "ml-4" children = { block . children } /> ) }
18+ </ div >
1519 ) ;
1620} ;
Original file line number Diff line number Diff line change @@ -19,8 +19,9 @@ export { Video } from "./Video";
1919export { Audio } from "./Audio" ;
2020export { PDF } from "./PDF" ;
2121export { Equation } from "./Equation" ;
22- export { ChildPage } from "./ChildPage" ;
2322export { ChildDatabase } from "./ChildDatabase" ;
23+ export { ChildPage } from "./ChildPage" ;
24+ export { Children } from "./Children" ;
2425export { LinkPreview } from "./LinkPreview" ;
2526export { Column } from "./Column" ;
2627export { ColumnList } from "./ColumnList" ;
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ export { Audio } from "./components/Audio";
2020export { PDF } from "./components/PDF" ;
2121export { Equation } from "./components/Equation" ;
2222export { ChildPage } from "./components/ChildPage" ;
23+ export { Children } from "./components/Children" ;
2324export { ChildDatabase } from "./components/ChildDatabase" ;
2425export { LinkPreview } from "./components/LinkPreview" ;
2526export { Column } from "./components/Column" ;
Original file line number Diff line number Diff line change 11import { StrictMode } from "react" ;
22import { createRoot } from "react-dom/client" ;
33import "./styles/index.css" ;
4- import App from "./App.tsx " ;
4+ import App from "./App" ;
55
66createRoot ( document . getElementById ( "root" ) ! ) . render (
77 < StrictMode >
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { BulletedListItemBlock } from "./bulletedListItem.types";
66import { CalloutBlock } from "./callout.types" ;
77import { ChildDatabaseBlock } from "./childDatabase.types" ;
88import { ChildPageBlock } from "./childPage.types" ;
9+ import { ChildrenBlock } from "./children.types" ;
910import { CodeBlock } from "./code.types" ;
1011import { ColumnBlock } from "./column.types" ;
1112import { ColumnListBlock } from "./columnList.types" ;
@@ -48,8 +49,9 @@ export type NotionBlock =
4849 | AudioBlock
4950 | PDFBlock
5051 | EquationBlock
51- | ChildPageBlock
5252 | ChildDatabaseBlock
53+ | ChildPageBlock
54+ | ChildrenBlock
5355 | LinkPreviewBlock
5456 | ColumnBlock
5557 | ColumnListBlock
Original file line number Diff line number Diff line change @@ -6,4 +6,5 @@ export interface ParagraphBlock extends BaseBlock {
66 rich_text : RichText [ ] ;
77 color : string ;
88 } ;
9+ children ?: BaseBlock [ ]
910}
Original file line number Diff line number Diff line change 88 "skipLibCheck" : true ,
99 "forceConsistentCasingInFileNames" : true ,
1010 "declaration" : true ,
11+ "declarationDir" : " ./dist" ,
1112 "outDir" : " ./dist" ,
1213 "rootDir" : " ./src" ,
1314
1920 "noEmit" : false ,
2021 "emitDeclarationOnly" : true ,
2122 "jsx" : " react-jsx" ,
22- "resolveJsonModule" : true ,
2323
2424 "baseUrl" : " ." ,
2525 "paths" : {
3434 "noUncheckedSideEffectImports" : true
3535 },
3636 "include" : [" src" ],
37- "exclude" : [" node_modules" ]
38- }
37+ "exclude" : [" node_modules" , " dist " ]
38+ }
Original file line number Diff line number Diff line change 1+ // {
2+ // "files": [],
3+ // "references": [
4+ // { "path": "./tsconfig.app.json" },
5+ // { "path": "./tsconfig.node.json" }
6+ // ]
7+ // }
8+
19{
2- "files" : [],
3- "references" : [
4- { "path" : " ./tsconfig.app.json" },
5- { "path" : " ./tsconfig.node.json" }
6- ]
7- }
10+ "compilerOptions" : {
11+ "skipLibCheck" : true ,
12+ "moduleResolution" : " bundler" ,
13+ "allowSyntheticDefaultImports" : true ,
14+ "target" : " ESNext" ,
15+ "module" : " ESNext" ,
16+ "esModuleInterop" : true ,
17+ "jsx" : " react-jsx" ,
18+ "strict" : true ,
19+ "baseUrl" : " ." ,
20+ "paths" : {
21+ "@/*" : [" src/*" ],
22+ "@components/*" : [" src/components/*" ],
23+ "@lib/*" : [" src/lib/*" ],
24+ "@hooks/*" : [" src/hooks/*" ],
25+ "@ui/*" : [" src/components/ui/*" ]
26+ },
27+ "noEmit" : true
28+ }
29+ }
You can’t perform that action at this time.
0 commit comments