@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.d.cts CHANGED
@@ -1577,6 +1577,7 @@ interface MarkdownMessageProps {
1577
1577
  * - Mermaid diagram rendering
1578
1578
  * - Tables, lists, blockquotes
1579
1579
  * - User/assistant styling modes
1580
+ * - Plain text optimization (skips ReactMarkdown for simple text)
1580
1581
  *
1581
1582
  * @example
1582
1583
  * ```tsx
package/dist/index.d.ts CHANGED
@@ -1577,6 +1577,7 @@ interface MarkdownMessageProps {
1577
1577
  * - Mermaid diagram rendering
1578
1578
  * - Tables, lists, blockquotes
1579
1579
  * - User/assistant styling modes
1580
+ * - Plain text optimization (skips ReactMarkdown for simple text)
1580
1581
  *
1581
1582
  * @example
1582
1583
  * ```tsx
package/dist/index.mjs CHANGED
@@ -4899,15 +4899,58 @@ var createMarkdownComponents = /* @__PURE__ */ __name((isUser = false, isCompact
4899
4899
  em: /* @__PURE__ */ __name(({ children }) => /* @__PURE__ */ jsx("em", { className: "italic", children }), "em")
4900
4900
  };
4901
4901
  }, "createMarkdownComponents");
4902
+ var hasMarkdownSyntax = /* @__PURE__ */ __name((text) => {
4903
+ if (text.trim().includes("\n")) {
4904
+ return true;
4905
+ }
4906
+ const markdownPatterns = [
4907
+ /^#{1,6}\s/m,
4908
+ // Headers
4909
+ /\*\*[^*]+\*\*/,
4910
+ // Bold
4911
+ /\*[^*]+\*/,
4912
+ // Italic
4913
+ /__[^_]+__/,
4914
+ // Bold (underscore)
4915
+ /_[^_]+_/,
4916
+ // Italic (underscore)
4917
+ /\[.+\]\(.+\)/,
4918
+ // Links
4919
+ /!\[.*\]\(.+\)/,
4920
+ // Images
4921
+ /```[\s\S]*```/,
4922
+ // Code blocks
4923
+ /`[^`]+`/,
4924
+ // Inline code
4925
+ /^\s*[-*+]\s/m,
4926
+ // Unordered lists
4927
+ /^\s*\d+\.\s/m,
4928
+ // Ordered lists
4929
+ /^\s*>/m,
4930
+ // Blockquotes
4931
+ /\|.+\|/,
4932
+ // Tables
4933
+ /^---+$/m,
4934
+ // Horizontal rules
4935
+ /~~[^~]+~~/
4936
+ // Strikethrough
4937
+ ];
4938
+ return markdownPatterns.some((pattern) => pattern.test(text));
4939
+ }, "hasMarkdownSyntax");
4902
4940
  var MarkdownMessage = /* @__PURE__ */ __name(({
4903
4941
  content,
4904
4942
  className = "",
4905
4943
  isUser = false,
4906
4944
  isCompact = false
4907
4945
  }) => {
4946
+ const trimmedContent = content.trim();
4908
4947
  const components = React17.useMemo(() => createMarkdownComponents(isUser, isCompact), [isUser, isCompact]);
4909
4948
  const textSizeClass = isCompact ? "text-xs" : "text-sm";
4910
4949
  const proseClass = isCompact ? "prose-xs" : "prose-sm";
4950
+ const isPlainText = !hasMarkdownSyntax(trimmedContent);
4951
+ if (isPlainText) {
4952
+ return /* @__PURE__ */ jsx("span", { className: `${textSizeClass} leading-relaxed break-words ${className}`, children: trimmedContent });
4953
+ }
4911
4954
  return /* @__PURE__ */ jsx(
4912
4955
  "div",
4913
4956
  {
@@ -4929,7 +4972,7 @@ var MarkdownMessage = /* @__PURE__ */ __name(({
4929
4972
  {
4930
4973
  remarkPlugins: [remarkGfm],
4931
4974
  components,
4932
- children: content
4975
+ children: trimmedContent
4933
4976
  }
4934
4977
  )
4935
4978
  }