@glodon-aiot/react-components
Version:
aiot react components
88 lines (87 loc) • 2.6 kB
JavaScript
var c = Object.defineProperty, C = Object.defineProperties;
var T = Object.getOwnPropertyDescriptors;
var m = Object.getOwnPropertySymbols;
var u = Object.prototype.hasOwnProperty, h = Object.prototype.propertyIsEnumerable;
var g = (e, i, r) => i in e ? c(e, i, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[i] = r, d = (e, i) => {
for (var r in i || (i = {}))
u.call(i, r) && g(e, r, i[r]);
if (m)
for (var r of m(i))
h.call(i, r) && g(e, r, i[r]);
return e;
}, n = (e, i) => C(e, T(i));
var s = (e, i) => {
var r = {};
for (var a in e)
u.call(e, a) && i.indexOf(a) < 0 && (r[a] = e[a]);
if (e != null && m)
for (var a of m(e))
i.indexOf(a) < 0 && h.call(e, a) && (r[a] = e[a]);
return r;
};
import { jsx as l } from "react/jsx-runtime";
import { useRef as _ } from "react";
import y from "react-markdown";
import L from "remark-gfm";
import R from "rehype-external-links";
import b from "remark-math";
import j from "rehype-katex";
import "katex/dist/katex.min.css";
import "./style.less.mjs";
import A from "./Image/index.mjs";
import D from "./Code/index.mjs";
import { replaceLatexDelimiters as E } from "../../utils/markdown/index.mjs";
import G from "./ATag/index.mjs";
import I from "./Video/index.mjs";
function K(e) {
return e && e.replace(/<think>/gi, '<div class="think">').replace(/<\/think>/gi, "</div>").replace(/<redacted_reasoning>/gi, '<div class="redacted_reasoning">').replace(/<\/redacted_reasoning>/gi, "</div>");
}
const $ = (N) => {
var f = N, {
showLatex: e = !0,
components: i = {},
componentProps: r,
children: a
} = f, w = s(f, [
"showLatex",
"components",
"componentProps",
"children"
]);
const v = _(null), M = d({
img(t) {
return /* @__PURE__ */ l(A, d(d({}, t), r == null ? void 0 : r.img));
},
code(t) {
return /* @__PURE__ */ l(D, d(d({}, t), r == null ? void 0 : r.code));
},
video(t) {
return /* @__PURE__ */ l(I, d(d({}, t), r == null ? void 0 : r.video));
},
a(t) {
return /* @__PURE__ */ l(G, d(d({}, t), r == null ? void 0 : r.a));
}
}, i), k = K(a), x = e ? E(k) : k;
return /* @__PURE__ */ l("div", {
ref: v,
children: /* @__PURE__ */ l(y, n(d({
className: "markdown",
rehypePlugins: [j, [R, {
target: "_blank"
}]],
remarkPlugins: [b, [L, {
singleTilde: !1
}]]
}, w), {
children: x,
components: M
}))
});
};
export {
$ as Markdown,
G as MarkdownATag,
D as MarkdownCode,
A as MarkdownImage,
I as MarkdownVideo
};