notion-content-render
Advanced tools
Comparing version 0.2.9 to 0.2.10
@@ -1,2 +0,2 @@ | ||
import type { Block, RichText } from "@notionhq/client/build/src/api-types"; | ||
import type { Block, HeadingOneBlock, HeadingThreeBlock, HeadingTwoBlock, ParagraphBlock, RichText, ToDoBlock, ToggleBlock } from "@notionhq/client/build/src/api-types"; | ||
export declare const BLOCK_TYPES: { | ||
@@ -19,6 +19,6 @@ PARAGRAPH: string; | ||
export declare type StyleFactory<R> = { | ||
heading_1: (input: R) => R; | ||
heading_2: (input: R) => R; | ||
heading_3: (input: R) => R; | ||
paragraph: (input: R) => R; | ||
heading_1: (input: R, block: HeadingOneBlock) => R; | ||
heading_2: (input: R, block: HeadingTwoBlock) => R; | ||
heading_3: (input: R, block: HeadingThreeBlock) => R; | ||
paragraph: (input: R, block: ParagraphBlock) => R; | ||
bold: Modifier<R>; | ||
@@ -35,4 +35,4 @@ strikethrough: Modifier<R>; | ||
richText: (input: Array<R>) => R; | ||
toggle: (title: R, content: R) => R; | ||
todo: (checked: boolean, content: R) => R; | ||
toggle: (title: R, content: R, block: ToggleBlock) => R; | ||
todo: (checked: boolean, content: R | undefined, block: ToDoBlock) => R; | ||
unsupported: (block: Block) => R; | ||
@@ -39,0 +39,0 @@ }; |
@@ -26,3 +26,3 @@ "use strict"; | ||
var richText = toRichTextBlock(text); | ||
return styleFactory.heading_1(richText); | ||
return styleFactory.heading_1(richText, block); | ||
} | ||
@@ -32,3 +32,3 @@ function toHeading_2(block) { | ||
var richText = toRichTextBlock(text); | ||
return styleFactory.heading_2(richText); | ||
return styleFactory.heading_2(richText, block); | ||
} | ||
@@ -38,7 +38,7 @@ function toHeading_3(block) { | ||
var richText = toRichTextBlock(text); | ||
return styleFactory.heading_3(richText); | ||
return styleFactory.heading_3(richText, block); | ||
} | ||
function toParagraph(block) { | ||
var richText = toRichTextBlock(block.paragraph.text); | ||
return styleFactory.paragraph(richText); | ||
return styleFactory.paragraph(richText, block); | ||
} | ||
@@ -73,2 +73,7 @@ function toRichTextBlock(textArray) { | ||
} | ||
function toToggle(content) { | ||
var title = toRichTextBlock(content.toggle.text); | ||
var children = undefined; //Notion doesn't return this yet | ||
return styleFactory.toggle(title, children, content); | ||
} | ||
return { | ||
@@ -90,2 +95,4 @@ renderRichText: toRichTextBlock, | ||
]); | ||
case exports.BLOCK_TYPES.TOGGLE: | ||
return toToggle(block); | ||
default: | ||
@@ -92,0 +99,0 @@ return styleFactory.unsupported(block); |
{ | ||
"name": "notion-content-render", | ||
"version": "0.2.9", | ||
"version": "0.2.10", | ||
"description": "A library to render notion content structure to React or MD", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14232
250