@udus/notion-renderer
Version:

47 lines (46 loc) • 1.92 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { useMapper } from "../../hooks.js";
import { Bold } from "./Bold.js";
import { Color } from "./Color.js";
import { InlineCode } from "./InlineCode.js";
import { Italic } from "./Italic.js";
import { Strikethrough } from "./Strikethrough.js";
import { Underline } from "./Underline.js";
export const AnnotationItem = ({ richTextItem, children }) => {
const { annotationMapper } = useMapper();
const mapper = {
bold: Bold,
underline: Underline,
strikethrough: Strikethrough,
italic: Italic,
code: InlineCode,
color: Color,
...annotationMapper,
};
let element = children;
if (richTextItem.annotations.bold) {
const BoldAnnotation = mapper["bold"];
element = (_jsx(BoldAnnotation, { richTextItem: richTextItem, children: element }));
}
if (richTextItem.annotations.italic) {
const ItalicAnnotation = mapper["italic"];
element = (_jsx(ItalicAnnotation, { richTextItem: richTextItem, children: element }));
}
if (richTextItem.annotations.strikethrough) {
const StrikethroughAnnotation = mapper["strikethrough"];
element = (_jsx(StrikethroughAnnotation, { richTextItem: richTextItem, children: element }));
}
if (richTextItem.annotations.underline) {
const UnderlineAnnotation = mapper["underline"];
element = (_jsx(UnderlineAnnotation, { richTextItem: richTextItem, children: element }));
}
if (richTextItem.annotations.code) {
const InlineCodeAnnotation = mapper["code"];
element = (_jsx(InlineCodeAnnotation, { richTextItem: richTextItem, children: element }));
}
if (richTextItem?.annotations.color) {
const ColorAnnotation = mapper["color"];
element = (_jsx(ColorAnnotation, { richTextItem: richTextItem, children: element }));
}
return element;
};