diff --git a/src/block.tsx b/src/block.tsx
index 9939273..ee8ee4e 100644
--- a/src/block.tsx
+++ b/src/block.tsx
@@ -19,10 +19,22 @@ import { classNames, getTextContent, getListNumber } from "./utils";
export const createRenderChildText = (
customDecoratorComponents?: CustomDecoratorComponents
-) => (properties: DecorationType[]) => {
+) => (properties: DecorationType[], blocks: BlockMapType) => {
return properties?.map(([text, decorations], i) => {
if (!decorations) {
- return {text};
+ return (
+
+ {text.split(/(\n)/).map((t, index) => (
+
+ {t !== "\n" ? t :
}
+
+ ))}
+
+ );
+ }
+
+ if (text === "‣" && decorations[0][0] === "p") {
+ text = blocks[decorations[0][1]]?.value?.properties?.title ?? "";
}
return decorations.reduceRight((element, decorator) => {
@@ -52,6 +64,12 @@ export const createRenderChildText = (
{element}
);
+ case "p":
+ return (
+
+ {element}
+
+ );
default:
return {element};
@@ -171,7 +189,7 @@ export const Block: React.FC = props => {
)}
- {renderChildText(blockValue.properties.title)}
+ {renderChildText(blockValue.properties.title, blockMap)}
{children}
@@ -191,7 +209,7 @@ export const Block: React.FC = props => {
)}
- {renderChildText(blockValue.properties.title)}
+ {renderChildText(blockValue.properties.title, blockMap)}
);
@@ -200,21 +218,21 @@ export const Block: React.FC = props => {
if (!blockValue.properties) return null;
return (
- {renderChildText(blockValue.properties.title)}
+ {renderChildText(blockValue.properties.title, blockMap)}
);
case "sub_header":
if (!blockValue.properties) return null;
return (
- {renderChildText(blockValue.properties.title)}
+ {renderChildText(blockValue.properties.title, blockMap)}
);
case "sub_sub_header":
if (!blockValue.properties) return null;
return (
- {renderChildText(blockValue.properties.title)}
+ {renderChildText(blockValue.properties.title, blockMap)}
);
case "divider":
@@ -231,7 +249,7 @@ export const Block: React.FC = props => {
blockColor && `notion-${blockColor}`
)}
>
- {renderChildText(blockValue.properties.title)}
+ {renderChildText(blockValue.properties.title, blockMap)}
);
case "bulleted_list":
@@ -251,14 +269,16 @@ export const Block: React.FC = props => {
output = (
<>
{blockValue.properties && (
- {renderChildText(blockValue.properties.title)}
+
+ {renderChildText(blockValue.properties.title, blockMap)}
+
)}
{wrapList(children)}
>
);
} else {
output = blockValue.properties ? (
- {renderChildText(blockValue.properties.title)}
+ {renderChildText(blockValue.properties.title, blockMap)}
) : null;
}
@@ -287,13 +307,13 @@ export const Block: React.FC = props => {
{value.properties.caption && (
- {renderChildText(value.properties.caption)}
+ {renderChildText(value.properties.caption, blockMap)}
)}
);
case "code": {
- if (blockValue.properties.title) {
+ if ((blockValue.properties.title, blockMap)) {
const content = blockValue.properties.title[0][0];
const language = blockValue.properties.language[0][0];
return (
@@ -326,7 +346,7 @@ export const Block: React.FC = props => {
if (!blockValue.properties) return null;
return (
- {renderChildText(blockValue.properties.title)}
+ {renderChildText(blockValue.properties.title, blockMap)}
);
case "collection_view":
@@ -337,7 +357,7 @@ export const Block: React.FC = props => {
return (
- {renderChildText(block.collection?.title!)}
+ {renderChildText(block.collection?.title!, blockMap)}
{collectionView?.type === "table" && (
@@ -376,7 +396,8 @@ export const Block: React.FC
= props => {
renderChildText(
row[
block.collection?.schema[gp.property]?.name!
- ]
+ ],
+ blockMap
)!
}
@@ -428,7 +449,7 @@ export const Block: React.FC = props => {
- {renderChildText(blockValue.properties.title)}
+ {renderChildText(blockValue.properties.title, blockMap)}
);
@@ -453,11 +474,11 @@ export const Block: React.FC = props => {
>
- {renderChildText(title)}
+ {renderChildText(title, blockMap)}
{description && (
- {renderChildText(description)}
+ {renderChildText(description, blockMap)}
)}
@@ -465,7 +486,7 @@ export const Block: React.FC
= props => {
{bookmark_icon && (
)}
- {renderChildText(link)}
+ {renderChildText(link, blockMap)}
{bookmark_cover && (
@@ -479,7 +500,9 @@ export const Block: React.FC = props => {
case "toggle":
return (
- {renderChildText(blockValue.properties.title)}
+
+ {renderChildText(blockValue.properties.title, blockMap)}
+
{children}
);