@copilotkit/react-ui
Version:
<div align="center"> <a href="https://copilotkit.ai" target="_blank"> <img src="https://github.com/copilotkit/copilotkit/raw/main/assets/banner.png" alt="CopilotKit Logo"> </a>
72 lines (70 loc) • 2.15 kB
JavaScript
import {
CodeBlock
} from "./chunk-PCTCOQK2.mjs";
import {
__objRest,
__spreadProps,
__spreadValues
} from "./chunk-MRXNTQOX.mjs";
// src/components/chat/Markdown.tsx
import { memo } from "react";
import ReactMarkdown from "react-markdown";
import remarkGfm from "remark-gfm";
import remarkMath from "remark-math";
import { jsx } from "react/jsx-runtime";
var MemoizedReactMarkdown = memo(
ReactMarkdown,
(prevProps, nextProps) => prevProps.children === nextProps.children && prevProps.className === nextProps.className
);
var Markdown = ({ content }) => {
return /* @__PURE__ */ jsx("div", { className: "copilotKitMarkdown", children: /* @__PURE__ */ jsx(MemoizedReactMarkdown, { components, remarkPlugins: [remarkGfm, remarkMath], children: content }) });
};
var components = {
a(_a) {
var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
return /* @__PURE__ */ jsx(
"a",
__spreadProps(__spreadValues({
style: { color: "blue", textDecoration: "underline" }
}, props), {
target: "_blank",
rel: "noopener noreferrer",
children
})
);
},
code(_c) {
var _d = _c, { children, className, inline } = _d, props = __objRest(_d, ["children", "className", "inline"]);
if (children.length) {
if (children[0] == "\u258D") {
return /* @__PURE__ */ jsx(
"span",
{
style: {
animation: "pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite",
marginTop: "0.25rem"
},
children: "\u258D"
}
);
}
children[0] = children[0].replace("`\u258D`", "\u258D");
}
const match = /language-(\w+)/.exec(className || "");
if (inline) {
return /* @__PURE__ */ jsx("code", __spreadProps(__spreadValues({ className }, props), { children }));
}
return /* @__PURE__ */ jsx(
CodeBlock,
__spreadValues({
language: match && match[1] || "",
value: String(children).replace(/\n$/, "")
}, props),
Math.random()
);
}
};
export {
Markdown
};
//# sourceMappingURL=chunk-XNQO5AZZ.mjs.map