@djangocfg/ui-tools 2.1.91 → 2.1.92
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +39 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +39 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/components/markdown/MarkdownMessage.tsx +36 -0
package/dist/index.cjs
CHANGED
|
@@ -4909,6 +4909,41 @@ var createMarkdownComponents = /* @__PURE__ */ chunkUQ3XI5MY_cjs.__name((isUser
|
|
|
4909
4909
|
em: /* @__PURE__ */ chunkUQ3XI5MY_cjs.__name(({ children }) => /* @__PURE__ */ jsxRuntime.jsx("em", { className: "italic", children }), "em")
|
|
4910
4910
|
};
|
|
4911
4911
|
}, "createMarkdownComponents");
|
|
4912
|
+
var hasMarkdownSyntax = /* @__PURE__ */ chunkUQ3XI5MY_cjs.__name((text) => {
|
|
4913
|
+
const markdownPatterns = [
|
|
4914
|
+
/^#{1,6}\s/m,
|
|
4915
|
+
// Headers
|
|
4916
|
+
/\*\*[^*]+\*\*/,
|
|
4917
|
+
// Bold
|
|
4918
|
+
/\*[^*]+\*/,
|
|
4919
|
+
// Italic
|
|
4920
|
+
/__[^_]+__/,
|
|
4921
|
+
// Bold (underscore)
|
|
4922
|
+
/_[^_]+_/,
|
|
4923
|
+
// Italic (underscore)
|
|
4924
|
+
/\[.+\]\(.+\)/,
|
|
4925
|
+
// Links
|
|
4926
|
+
/!\[.*\]\(.+\)/,
|
|
4927
|
+
// Images
|
|
4928
|
+
/```[\s\S]*```/,
|
|
4929
|
+
// Code blocks
|
|
4930
|
+
/`[^`]+`/,
|
|
4931
|
+
// Inline code
|
|
4932
|
+
/^\s*[-*+]\s/m,
|
|
4933
|
+
// Unordered lists
|
|
4934
|
+
/^\s*\d+\.\s/m,
|
|
4935
|
+
// Ordered lists
|
|
4936
|
+
/^\s*>/m,
|
|
4937
|
+
// Blockquotes
|
|
4938
|
+
/\|.+\|/,
|
|
4939
|
+
// Tables
|
|
4940
|
+
/^---+$/m,
|
|
4941
|
+
// Horizontal rules
|
|
4942
|
+
/~~[^~]+~~/
|
|
4943
|
+
// Strikethrough
|
|
4944
|
+
];
|
|
4945
|
+
return markdownPatterns.some((pattern) => pattern.test(text));
|
|
4946
|
+
}, "hasMarkdownSyntax");
|
|
4912
4947
|
var MarkdownMessage = /* @__PURE__ */ chunkUQ3XI5MY_cjs.__name(({
|
|
4913
4948
|
content,
|
|
4914
4949
|
className = "",
|
|
@@ -4918,6 +4953,10 @@ var MarkdownMessage = /* @__PURE__ */ chunkUQ3XI5MY_cjs.__name(({
|
|
|
4918
4953
|
const components = React17__default.default.useMemo(() => createMarkdownComponents(isUser, isCompact), [isUser, isCompact]);
|
|
4919
4954
|
const textSizeClass = isCompact ? "text-xs" : "text-sm";
|
|
4920
4955
|
const proseClass = isCompact ? "prose-xs" : "prose-sm";
|
|
4956
|
+
const isPlainText = !hasMarkdownSyntax(content);
|
|
4957
|
+
if (isPlainText) {
|
|
4958
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: `${textSizeClass} leading-relaxed break-words ${className}`, children: content });
|
|
4959
|
+
}
|
|
4921
4960
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4922
4961
|
"div",
|
|
4923
4962
|
{
|