UNPKG

nav-frontend-tekstomrade

Version:
27 lines (26 loc) 1.24 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.LinkRule = exports.ParagraphRule = void 0; const textparser_1 = require("@navikt/textparser"); const nav_frontend_lenker_1 = __importDefault(require("nav-frontend-lenker")); const nav_frontend_typografi_1 = require("nav-frontend-typografi"); const utils_1 = require("@navikt/textparser/dist/utils"); exports.ParagraphRule = Object.assign(Object.assign({}, textparser_1.ParagraphRule), { react(node, ast) { const isLastInAST = ast.indexOf(node) === ast.length - 1; const props = isLastInAST ? undefined : { className: "blokk-xs" }; return { props, type: nav_frontend_typografi_1.Normaltekst, }; } }); exports.LinkRule = Object.assign(Object.assign({}, textparser_1.LinkRule), { react(node) { const text = (0, utils_1.getText)(node); const href = this.startsWithHttp.test(text) ? text : `https://${text}`; return { type: nav_frontend_lenker_1.default, props: { href, target: "_blank" }, }; } });