UNPKG

notion-block-renderer

Version:
40 lines (39 loc) 1.45 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getJoinedRichText = exports.Context = exports.annotationToClassName = void 0; const react_1 = require("react"); const config_1 = require("./config"); function annotationToClassName(annotations, prefix) { const classNames = []; if (annotations.bold) classNames.push(`${prefix}-bold`); if (annotations.code) classNames.push(`${prefix}-inline-code`); if (annotations.italic) classNames.push(`${prefix}-italic`); if (annotations.strikethrough) classNames.push(`${prefix}-trikethrough`); if (annotations.underline) classNames.push(`${prefix}-underline`); if (annotations.color !== "default") classNames.push(`${prefix}-color-${annotations.color}`); return classNames.join(" "); } exports.annotationToClassName = annotationToClassName; exports.Context = (0, react_1.createContext)({ prefix: config_1.PREFIX, blockPrefix: config_1.BLOCK_PREFIX, blocksPrefix: config_1.BLOCKS_PREFIX, isCodeHighlighter: config_1.IS_CODE_HIGHLIGHTER, syntaxHighlighterCSS: config_1.SYNTAX_HIGHLIGHTER_CSS, }); /** * * @param richTextArr - array of rich_text objects * @returns joined text */ const getJoinedRichText = (richTextArr) => { const textArr = richTextArr.map((richText) => richText.plain_text); return textArr.join(""); }; exports.getJoinedRichText = getJoinedRichText;