UNPKG

@ea-lab/reactive-json

Version:

A REACT-based lib that transforms JSON (or YAML) into interactive HTML markup.

54 lines (53 loc) 1.33 kB
import { jsx as a, Fragment as m } from "react/jsx-runtime"; import { p as s } from "../../../index-NNBvIV0S.js"; import { useContext as l } from "react"; import { ActionDependant as c } from "../../../engine/Actions.js"; import { GlobalDataContext as p } from "../../../engine/GlobalDataContext.js"; import { TemplateContext as f } from "../../../engine/TemplateContext.js"; import { evaluateTemplateValue as h } from "../../../engine/TemplateSystem.js"; const u = [ "abbr", "acronym", "b", "blockquote", "br", "caption", "code", "div", "em", "h1", "h2", "h3", "h4", "h5", "h6", "i", "li", "ol", "p", "span", "sup", "strong", "table", "tbody", "td", "tfoot", "th", "thead", "tr", "ul" ], L = ({ props: t }) => { const r = l(f), n = l(p), o = h({ valueToEvaluate: t.content, templateContext: r, globalDataContext: n }); if (typeof o != "string") return console.error("PreformattedMarkup: the given content is not a string."), null; const i = [...Array.isArray(t.htmlTagAllowList) ? t.htmlTagAllowList : u, ...t.additionalAllowedTags ?? []]; return /* @__PURE__ */ a(c, { ...t, children: s(o, { replace(e) { if (e.type === "tag" && i.indexOf(e.name) < 0) return /* @__PURE__ */ a(m, {}); } }) }); }; export { L as PreformattedMarkup };