@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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@djangocfg/ui-tools",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.92",
|
|
4
4
|
"description": "Heavy React tools with lazy loading - for Electron, Vite, CRA, Next.js apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ui-tools",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"consola": "^3.4.2"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@djangocfg/ui-core": "^2.1.
|
|
58
|
+
"@djangocfg/ui-core": "^2.1.92",
|
|
59
59
|
"@rjsf/core": "^6.1.2",
|
|
60
60
|
"@rjsf/utils": "^6.1.2",
|
|
61
61
|
"@rjsf/validator-ajv8": "^6.1.2",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"wavesurfer.js": "^7.12.1"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
|
-
"@djangocfg/typescript-config": "^2.1.
|
|
76
|
+
"@djangocfg/typescript-config": "^2.1.92",
|
|
77
77
|
"@types/node": "^24.7.2",
|
|
78
78
|
"@types/react": "^19.1.0",
|
|
79
79
|
"@types/react-dom": "^19.1.0",
|
|
@@ -282,6 +282,30 @@ const createMarkdownComponents = (isUser: boolean = false, isCompact: boolean =
|
|
|
282
282
|
),
|
|
283
283
|
};};
|
|
284
284
|
|
|
285
|
+
// Check if content contains markdown syntax
|
|
286
|
+
const hasMarkdownSyntax = (text: string): boolean => {
|
|
287
|
+
// Common markdown patterns
|
|
288
|
+
const markdownPatterns = [
|
|
289
|
+
/^#{1,6}\s/m, // Headers
|
|
290
|
+
/\*\*[^*]+\*\*/, // Bold
|
|
291
|
+
/\*[^*]+\*/, // Italic
|
|
292
|
+
/__[^_]+__/, // Bold (underscore)
|
|
293
|
+
/_[^_]+_/, // Italic (underscore)
|
|
294
|
+
/\[.+\]\(.+\)/, // Links
|
|
295
|
+
/!\[.*\]\(.+\)/, // Images
|
|
296
|
+
/```[\s\S]*```/, // Code blocks
|
|
297
|
+
/`[^`]+`/, // Inline code
|
|
298
|
+
/^\s*[-*+]\s/m, // Unordered lists
|
|
299
|
+
/^\s*\d+\.\s/m, // Ordered lists
|
|
300
|
+
/^\s*>/m, // Blockquotes
|
|
301
|
+
/\|.+\|/, // Tables
|
|
302
|
+
/^---+$/m, // Horizontal rules
|
|
303
|
+
/~~[^~]+~~/, // Strikethrough
|
|
304
|
+
];
|
|
305
|
+
|
|
306
|
+
return markdownPatterns.some(pattern => pattern.test(text));
|
|
307
|
+
};
|
|
308
|
+
|
|
285
309
|
/**
|
|
286
310
|
* MarkdownMessage - Renders markdown content with syntax highlighting and GFM support
|
|
287
311
|
*
|
|
@@ -291,6 +315,7 @@ const createMarkdownComponents = (isUser: boolean = false, isCompact: boolean =
|
|
|
291
315
|
* - Mermaid diagram rendering
|
|
292
316
|
* - Tables, lists, blockquotes
|
|
293
317
|
* - User/assistant styling modes
|
|
318
|
+
* - Plain text optimization (skips ReactMarkdown for simple text)
|
|
294
319
|
*
|
|
295
320
|
* @example
|
|
296
321
|
* ```tsx
|
|
@@ -311,6 +336,17 @@ export const MarkdownMessage: React.FC<MarkdownMessageProps> = ({
|
|
|
311
336
|
const textSizeClass = isCompact ? 'text-xs' : 'text-sm';
|
|
312
337
|
const proseClass = isCompact ? 'prose-xs' : 'prose-sm';
|
|
313
338
|
|
|
339
|
+
// For plain text without markdown, render directly without ReactMarkdown
|
|
340
|
+
const isPlainText = !hasMarkdownSyntax(content);
|
|
341
|
+
|
|
342
|
+
if (isPlainText) {
|
|
343
|
+
return (
|
|
344
|
+
<span className={`${textSizeClass} leading-relaxed break-words ${className}`}>
|
|
345
|
+
{content}
|
|
346
|
+
</span>
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
|
|
314
350
|
return (
|
|
315
351
|
<div
|
|
316
352
|
className={`
|