@djangocfg/ui-tools 2.1.91 → 2.1.94
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 +44 -1
- 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 +44 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/components/markdown/MarkdownMessage.tsx +45 -1
package/dist/index.cjs
CHANGED
|
@@ -4909,15 +4909,58 @@ 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
|
+
if (text.trim().includes("\n")) {
|
|
4914
|
+
return true;
|
|
4915
|
+
}
|
|
4916
|
+
const markdownPatterns = [
|
|
4917
|
+
/^#{1,6}\s/m,
|
|
4918
|
+
// Headers
|
|
4919
|
+
/\*\*[^*]+\*\*/,
|
|
4920
|
+
// Bold
|
|
4921
|
+
/\*[^*]+\*/,
|
|
4922
|
+
// Italic
|
|
4923
|
+
/__[^_]+__/,
|
|
4924
|
+
// Bold (underscore)
|
|
4925
|
+
/_[^_]+_/,
|
|
4926
|
+
// Italic (underscore)
|
|
4927
|
+
/\[.+\]\(.+\)/,
|
|
4928
|
+
// Links
|
|
4929
|
+
/!\[.*\]\(.+\)/,
|
|
4930
|
+
// Images
|
|
4931
|
+
/```[\s\S]*```/,
|
|
4932
|
+
// Code blocks
|
|
4933
|
+
/`[^`]+`/,
|
|
4934
|
+
// Inline code
|
|
4935
|
+
/^\s*[-*+]\s/m,
|
|
4936
|
+
// Unordered lists
|
|
4937
|
+
/^\s*\d+\.\s/m,
|
|
4938
|
+
// Ordered lists
|
|
4939
|
+
/^\s*>/m,
|
|
4940
|
+
// Blockquotes
|
|
4941
|
+
/\|.+\|/,
|
|
4942
|
+
// Tables
|
|
4943
|
+
/^---+$/m,
|
|
4944
|
+
// Horizontal rules
|
|
4945
|
+
/~~[^~]+~~/
|
|
4946
|
+
// Strikethrough
|
|
4947
|
+
];
|
|
4948
|
+
return markdownPatterns.some((pattern) => pattern.test(text));
|
|
4949
|
+
}, "hasMarkdownSyntax");
|
|
4912
4950
|
var MarkdownMessage = /* @__PURE__ */ chunkUQ3XI5MY_cjs.__name(({
|
|
4913
4951
|
content,
|
|
4914
4952
|
className = "",
|
|
4915
4953
|
isUser = false,
|
|
4916
4954
|
isCompact = false
|
|
4917
4955
|
}) => {
|
|
4956
|
+
const trimmedContent = content.trim();
|
|
4918
4957
|
const components = React17__default.default.useMemo(() => createMarkdownComponents(isUser, isCompact), [isUser, isCompact]);
|
|
4919
4958
|
const textSizeClass = isCompact ? "text-xs" : "text-sm";
|
|
4920
4959
|
const proseClass = isCompact ? "prose-xs" : "prose-sm";
|
|
4960
|
+
const isPlainText = !hasMarkdownSyntax(trimmedContent);
|
|
4961
|
+
if (isPlainText) {
|
|
4962
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: `${textSizeClass} leading-relaxed break-words ${className}`, children: trimmedContent });
|
|
4963
|
+
}
|
|
4921
4964
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4922
4965
|
"div",
|
|
4923
4966
|
{
|
|
@@ -4939,7 +4982,7 @@ var MarkdownMessage = /* @__PURE__ */ chunkUQ3XI5MY_cjs.__name(({
|
|
|
4939
4982
|
{
|
|
4940
4983
|
remarkPlugins: [remarkGfm__default.default],
|
|
4941
4984
|
components,
|
|
4942
|
-
children:
|
|
4985
|
+
children: trimmedContent
|
|
4943
4986
|
}
|
|
4944
4987
|
)
|
|
4945
4988
|
}
|