@messenger-box/tailwind-ui-inbox 10.0.3-alpha.72 → 10.0.3-alpha.74
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/CHANGELOG.md +8 -0
- package/lib/components/AIAgent/AIAgent.d.ts +7 -0
- package/lib/components/AIAgent/AIAgent.d.ts.map +1 -1
- package/lib/components/AIAgent/AIAgent.js +362 -615
- package/lib/components/AIAgent/AIAgent.js.map +1 -1
- package/lib/components/InboxMessage/InputComponent.d.ts.map +1 -1
- package/lib/components/InboxMessage/InputComponent.js +143 -140
- package/lib/components/InboxMessage/InputComponent.js.map +1 -1
- package/lib/components/InboxMessage/RightSidebarAi.d.ts +23 -0
- package/lib/components/InboxMessage/RightSidebarAi.d.ts.map +1 -0
- package/lib/components/InboxMessage/RightSidebarAi.js +9 -0
- package/lib/components/InboxMessage/RightSidebarAi.js.map +1 -0
- package/lib/components/InboxMessage/index.d.ts +1 -0
- package/lib/components/InboxMessage/index.d.ts.map +1 -1
- package/lib/components/InboxMessage/message-widgets/ErrorFixCard.d.ts +11 -0
- package/lib/components/InboxMessage/message-widgets/ErrorFixCard.d.ts.map +1 -0
- package/lib/components/InboxMessage/message-widgets/ErrorFixCard.js +194 -0
- package/lib/components/InboxMessage/message-widgets/ErrorFixCard.js.map +1 -0
- package/lib/components/InboxMessage/message-widgets/ModernMessageGroup.d.ts +5 -1
- package/lib/components/InboxMessage/message-widgets/ModernMessageGroup.d.ts.map +1 -1
- package/lib/components/InboxMessage/message-widgets/ModernMessageGroup.js +308 -857
- package/lib/components/InboxMessage/message-widgets/ModernMessageGroup.js.map +1 -1
- package/lib/components/ModelConfigPanel.d.ts +12 -0
- package/lib/components/ModelConfigPanel.d.ts.map +1 -0
- package/lib/components/ModelConfigPanel.js +304 -0
- package/lib/components/ModelConfigPanel.js.map +1 -0
- package/lib/components/filler-components/RightSiderBar.d.ts +24 -0
- package/lib/components/filler-components/RightSiderBar.d.ts.map +1 -0
- package/lib/components/filler-components/RightSiderBar.js +335 -0
- package/lib/components/filler-components/RightSiderBar.js.map +1 -0
- package/lib/components/index.d.ts +4 -2
- package/lib/components/index.d.ts.map +1 -1
- package/lib/components/live-code-editor/hybrid-live-editor.d.ts +20 -0
- package/lib/components/live-code-editor/hybrid-live-editor.d.ts.map +1 -0
- package/lib/components/live-code-editor/hybrid-live-editor.js +68 -0
- package/lib/components/live-code-editor/hybrid-live-editor.js.map +1 -0
- package/lib/components/live-code-editor/index.d.ts +4 -0
- package/lib/components/live-code-editor/index.d.ts.map +1 -0
- package/lib/components/live-code-editor/live-code-editor.d.ts +14 -0
- package/lib/components/live-code-editor/live-code-editor.d.ts.map +1 -0
- package/lib/components/live-code-editor/live-code-editor.js +207 -0
- package/lib/components/live-code-editor/live-code-editor.js.map +1 -0
- package/lib/components/slot-fill/chat-message-filler.js +1 -1
- package/lib/components/slot-fill/chat-message-filler.js.map +1 -1
- package/lib/components/slot-fill/index.d.ts +1 -0
- package/lib/components/slot-fill/index.d.ts.map +1 -1
- package/lib/components/slot-fill/right-sidebar-filler.d.ts +4 -0
- package/lib/components/slot-fill/right-sidebar-filler.d.ts.map +1 -0
- package/lib/components/slot-fill/right-sidebar-filler.js +13 -0
- package/lib/components/slot-fill/right-sidebar-filler.js.map +1 -0
- package/lib/components/ui/button.d.ts +9 -0
- package/lib/components/ui/button.d.ts.map +1 -0
- package/lib/compute.js +1 -2
- package/lib/container/AiInbox.d.ts.map +1 -1
- package/lib/container/AiLandingInput.d.ts.map +1 -1
- package/lib/container/AiLandingInput.js +46 -119
- package/lib/container/AiLandingInput.js.map +1 -1
- package/lib/container/Inbox.js +1 -1
- package/lib/container/Inbox.js.map +1 -1
- package/lib/container/InboxAiMessagesLoader.d.ts +0 -21
- package/lib/container/InboxAiMessagesLoader.d.ts.map +1 -1
- package/lib/container/InboxAiMessagesLoader.js +18 -35
- package/lib/container/InboxAiMessagesLoader.js.map +1 -1
- package/lib/container/ServiceInbox.js +1 -1
- package/lib/container/ServiceInbox.js.map +1 -1
- package/lib/container/ThreadMessages.js +1 -1
- package/lib/container/ThreadMessages.js.map +1 -1
- package/lib/container/ThreadMessagesInbox.js +1 -1
- package/lib/container/ThreadMessagesInbox.js.map +1 -1
- package/lib/container/Threads.js +1 -1
- package/lib/container/Threads.js.map +1 -1
- package/lib/container/index.d.ts +5 -4
- package/lib/container/index.d.ts.map +1 -1
- package/lib/enums/messenger-slot-fill-name-enum.d.ts +2 -1
- package/lib/enums/messenger-slot-fill-name-enum.d.ts.map +1 -1
- package/lib/enums/messenger-slot-fill-name-enum.js +1 -0
- package/lib/enums/messenger-slot-fill-name-enum.js.map +1 -1
- package/lib/hooks/index.d.ts +3 -0
- package/lib/hooks/index.d.ts.map +1 -0
- package/lib/hooks/use-file-sync.d.ts +16 -0
- package/lib/hooks/use-file-sync.d.ts.map +1 -0
- package/lib/hooks/use-file-sync.js +63 -0
- package/lib/hooks/use-file-sync.js.map +1 -0
- package/lib/hooks/usePersistentModelConfig.d.ts +15 -0
- package/lib/hooks/usePersistentModelConfig.d.ts.map +1 -0
- package/lib/hooks/usePersistentModelConfig.js +46 -0
- package/lib/hooks/usePersistentModelConfig.js.map +1 -0
- package/lib/index.d.ts +5 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/machines/aiAgentMachine.d.ts.map +1 -1
- package/lib/machines/aiAgentMachine.js +64 -21
- package/lib/machines/aiAgentMachine.js.map +1 -1
- package/lib/machines/aiAgentMachine.simple.d.ts +3 -0
- package/lib/machines/aiAgentMachine.simple.d.ts.map +1 -0
- package/lib/machines/aiAgentMachine.simple.js +108 -0
- package/lib/machines/aiAgentMachine.simple.js.map +1 -0
- package/lib/machines/index.d.ts +3 -0
- package/lib/machines/index.d.ts.map +1 -0
- package/lib/module.d.ts +2 -1
- package/lib/module.d.ts.map +1 -1
- package/lib/module.js +11 -3
- package/lib/module.js.map +1 -1
- package/lib/routes.json +1 -2
- package/lib/templates/InboxWithAi.d.ts.map +1 -1
- package/lib/templates/InboxWithAi.js +129 -70
- package/lib/templates/InboxWithAi.js.map +1 -1
- package/lib/templates/InboxWithAi.tsx +151 -90
- package/lib/templates/index.d.ts +2 -0
- package/lib/templates/index.d.ts.map +1 -0
- package/lib/templates/index.ts +1 -0
- package/lib/utils/utils.d.ts +2 -0
- package/lib/utils/utils.d.ts.map +1 -0
- package/lib/utils/utils.js +3 -0
- package/lib/utils/utils.js.map +1 -0
- package/package.json +8 -5
- package/src/components/AIAgent/AIAgent.tsx +469 -731
- package/src/components/AIAgent/AIAgent.tsx.bk +1365 -0
- package/src/components/InboxMessage/InputComponent.tsx +2 -1
- package/src/components/InboxMessage/RightSidebarAi.tsx +37 -0
- package/src/components/InboxMessage/index.ts +1 -0
- package/src/components/InboxMessage/message-widgets/ErrorFixCard.tsx +240 -0
- package/src/components/InboxMessage/message-widgets/ModernMessageGroup.tsx +337 -1116
- package/src/components/ModelConfigPanel.tsx +334 -0
- package/src/components/filler-components/RightSiderBar.tsx +408 -0
- package/src/components/index.ts +4 -1
- package/src/components/live-code-editor/hybrid-live-editor.tsx +105 -0
- package/src/components/live-code-editor/index.ts +3 -0
- package/src/components/live-code-editor/live-code-editor.tsx +257 -0
- package/src/components/slot-fill/index.ts +1 -0
- package/src/components/slot-fill/right-sidebar-filler.tsx +39 -0
- package/src/components/ui/button.tsx +32 -0
- package/src/container/AiInbox.tsx +26 -3
- package/src/container/AiLandingInput.tsx +48 -22
- package/src/container/InboxAiMessagesLoader.tsx +17 -41
- package/src/container/index.ts +14 -6
- package/src/enums/messenger-slot-fill-name-enum.ts +1 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/use-file-sync.ts +91 -0
- package/src/hooks/usePersistentModelConfig.ts +63 -0
- package/src/index.ts +19 -1
- package/src/machines/aiAgentMachine.simple.ts +89 -0
- package/src/machines/aiAgentMachine.ts +67 -19
- package/src/machines/aiAgentMachine.ts.bk +1296 -0
- package/src/machines/index.ts +2 -0
- package/src/module.tsx +10 -1
- package/src/templates/InboxWithAi.tsx +151 -90
- package/src/templates/index.ts +1 -0
- package/src/utils/utils.ts +3 -0
- package/lib/components/InboxMessage/MessageInputComponent.js +0 -173
- package/lib/components/InboxMessage/MessageInputComponent.js.map +0 -1
- package/lib/components/InboxMessage/MessagesBuilderUi.js +0 -162
- package/lib/components/InboxMessage/MessagesBuilderUi.js.map +0 -1
- package/lib/container/AiInbox.js +0 -1520
- package/lib/container/AiInbox.js.map +0 -1
- package/lib/container/AiInboxWithLoader.js +0 -300
- package/lib/container/AiInboxWithLoader.js.map +0 -1
- package/lib/container/InboxTemplate1.js +0 -1375
- package/lib/container/InboxTemplate1.js.map +0 -1
- package/lib/container/InboxTemplate2.js +0 -1426
- package/lib/container/InboxTemplate2.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React__default,{useEffect}from'react';import {format,differenceInMinutes}from'date-fns';import {FilesList}from'../../inbox/FilesList.js';import'../../inbox/MessageItem.js';import'../../inbox/ThreadItem.js';// Enhanced CSS styles for HTML content rendering with prettification
|
|
1
|
+
import React__default,{useEffect}from'react';import {format,differenceInMinutes}from'date-fns';import {FilesList}from'../../inbox/FilesList.js';import'../../inbox/MessageItem.js';import'../../inbox/ThreadItem.js';import {ErrorFixCard}from'./ErrorFixCard.js';import ReactMarkdown from'react-markdown';import remarkGfm from'remark-gfm';// Enhanced CSS styles for HTML content rendering with prettification
|
|
2
2
|
const htmlContentStyles = `
|
|
3
3
|
.html-content {
|
|
4
4
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
@@ -172,216 +172,183 @@ const htmlContentStyles = `
|
|
|
172
172
|
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
.html-content .info-box {
|
|
183
|
-
background-color: #dbeafe;
|
|
184
|
-
border: 1px solid #3b82f6;
|
|
185
|
-
border-radius: 0.5rem;
|
|
186
|
-
padding: 1rem;
|
|
187
|
-
margin: 1rem 0;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
.html-content .warning-box {
|
|
191
|
-
background-color: #fef3c7;
|
|
192
|
-
border: 1px solid #f59e0b;
|
|
193
|
-
border-radius: 0.5rem;
|
|
194
|
-
padding: 1rem;
|
|
195
|
-
margin: 1rem 0;
|
|
175
|
+
/* Enhanced message container styling */
|
|
176
|
+
.message-container {
|
|
177
|
+
background: #ffffff;
|
|
178
|
+
padding: 16px;
|
|
179
|
+
margin: 12px 0;
|
|
180
|
+
transition: all 0.2s ease-in-out;
|
|
196
181
|
}
|
|
197
182
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
margin: 1rem 0;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
.html-content .error-box {
|
|
207
|
-
background-color: #fee2e2;
|
|
208
|
-
border: 1px solid #ef4444;
|
|
209
|
-
border-radius: 0.5rem;
|
|
210
|
-
padding: 1rem;
|
|
211
|
-
margin: 1rem 0;
|
|
183
|
+
/* Markdown content styling */
|
|
184
|
+
.markdown-content {
|
|
185
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
186
|
+
line-height: 1.6;
|
|
187
|
+
color: #374151;
|
|
212
188
|
}
|
|
213
189
|
|
|
214
|
-
.
|
|
215
|
-
|
|
216
|
-
margin-bottom: 1rem;
|
|
190
|
+
.markdown-content h1 {
|
|
191
|
+
font-size: 1.5rem;
|
|
217
192
|
font-weight: 700;
|
|
218
|
-
|
|
193
|
+
margin-top: 1.5rem;
|
|
194
|
+
margin-bottom: 1rem;
|
|
219
195
|
color: #111827;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
.html-content .html-heading-1 {
|
|
223
|
-
font-size: 2rem;
|
|
224
|
-
border-bottom: 3px solid #3b82f6;
|
|
225
|
-
padding-bottom: 0.75rem;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
.html-content .html-heading-2 {
|
|
229
|
-
font-size: 1.5rem;
|
|
230
|
-
border-bottom: 2px solid #e5e7eb;
|
|
231
196
|
padding-bottom: 0.5rem;
|
|
197
|
+
border-bottom: 2px solid #e5e7eb;
|
|
232
198
|
}
|
|
233
199
|
|
|
234
|
-
.
|
|
200
|
+
.markdown-content h2 {
|
|
235
201
|
font-size: 1.25rem;
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
.html-content .html-paragraph {
|
|
240
|
-
margin-bottom: 1.25rem;
|
|
241
|
-
line-height: 1.8;
|
|
242
|
-
color: #4b5563;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
.html-content .html-list {
|
|
246
|
-
margin: 1.5rem 0;
|
|
247
|
-
padding-left: 2rem;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
.html-content .html-list li {
|
|
202
|
+
font-weight: 600;
|
|
203
|
+
margin-top: 1.25rem;
|
|
251
204
|
margin-bottom: 0.75rem;
|
|
252
|
-
|
|
253
|
-
|
|
205
|
+
color: #1f2937;
|
|
206
|
+
padding-bottom: 0.375rem;
|
|
207
|
+
border-bottom: 1px solid #e5e7eb;
|
|
254
208
|
}
|
|
255
209
|
|
|
256
|
-
.
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
210
|
+
.markdown-content h3 {
|
|
211
|
+
font-size: 1.125rem;
|
|
212
|
+
font-weight: 600;
|
|
213
|
+
margin-top: 1rem;
|
|
214
|
+
margin-bottom: 0.5rem;
|
|
215
|
+
color: #374151;
|
|
262
216
|
}
|
|
263
217
|
|
|
264
|
-
.
|
|
265
|
-
|
|
218
|
+
.markdown-content p {
|
|
219
|
+
margin-bottom: 0.75rem;
|
|
220
|
+
line-height: 1.6;
|
|
221
|
+
color: #4b5563;
|
|
266
222
|
}
|
|
267
223
|
|
|
268
|
-
.
|
|
269
|
-
|
|
224
|
+
.markdown-content ul, .markdown-content ol {
|
|
225
|
+
margin: 1rem 0;
|
|
226
|
+
padding-left: 1.5rem;
|
|
270
227
|
}
|
|
271
228
|
|
|
272
|
-
.
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
font-weight: 600;
|
|
276
|
-
position: absolute;
|
|
277
|
-
left: -2rem;
|
|
229
|
+
.markdown-content li {
|
|
230
|
+
margin-bottom: 0.5rem;
|
|
231
|
+
line-height: 1.6;
|
|
278
232
|
}
|
|
279
233
|
|
|
280
|
-
.
|
|
234
|
+
.markdown-content code {
|
|
281
235
|
background-color: #f3f4f6;
|
|
282
|
-
padding: 0.
|
|
283
|
-
border-radius: 0.
|
|
236
|
+
padding: 0.125rem 0.375rem;
|
|
237
|
+
border-radius: 0.25rem;
|
|
284
238
|
font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
|
|
285
239
|
font-size: 0.875rem;
|
|
286
240
|
color: #dc2626;
|
|
287
241
|
border: 1px solid #e5e7eb;
|
|
288
242
|
}
|
|
289
243
|
|
|
290
|
-
.
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
padding: 1.5rem;
|
|
294
|
-
border-radius: 0.75rem;
|
|
244
|
+
.markdown-content pre {
|
|
245
|
+
color: #1f2937;
|
|
246
|
+
border-radius: 8px;
|
|
295
247
|
overflow-x: auto;
|
|
296
248
|
font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
|
|
297
249
|
font-size: 0.875rem;
|
|
298
|
-
line-height: 1.
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
250
|
+
line-height: 1.5;
|
|
251
|
+
margin: 1rem 0;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
.markdown-content pre code {
|
|
255
|
+
background-color: transparent;
|
|
256
|
+
padding: 0;
|
|
257
|
+
border: none;
|
|
258
|
+
color: #1f2937;
|
|
259
|
+
font-size: inherit;
|
|
302
260
|
}
|
|
303
261
|
|
|
304
|
-
.
|
|
262
|
+
.markdown-content blockquote {
|
|
305
263
|
border-left: 4px solid #3b82f6;
|
|
306
|
-
background:
|
|
307
|
-
padding:
|
|
308
|
-
margin:
|
|
309
|
-
border-radius:
|
|
264
|
+
background-color: #f8fafc;
|
|
265
|
+
padding: 1rem;
|
|
266
|
+
margin: 1rem 0;
|
|
267
|
+
border-radius: 6px;
|
|
310
268
|
font-style: italic;
|
|
311
269
|
color: #475569;
|
|
312
|
-
|
|
270
|
+
border-top: 1px solid #e5e7eb;
|
|
271
|
+
border-right: 1px solid #e5e7eb;
|
|
272
|
+
border-bottom: 1px solid #e5e7eb;
|
|
313
273
|
}
|
|
314
274
|
|
|
315
|
-
.
|
|
275
|
+
.markdown-content table {
|
|
316
276
|
border-collapse: collapse;
|
|
317
|
-
border:
|
|
277
|
+
border: 1px solid #e5e7eb;
|
|
318
278
|
width: 100%;
|
|
319
|
-
margin:
|
|
320
|
-
border-radius:
|
|
279
|
+
margin: 1rem 0;
|
|
280
|
+
border-radius: 8px;
|
|
321
281
|
overflow: hidden;
|
|
322
|
-
box-shadow: 0
|
|
282
|
+
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
|
|
323
283
|
}
|
|
324
284
|
|
|
325
|
-
.
|
|
326
|
-
background:
|
|
327
|
-
color:
|
|
328
|
-
font-weight:
|
|
329
|
-
padding:
|
|
285
|
+
.markdown-content th {
|
|
286
|
+
background-color: #f9fafb;
|
|
287
|
+
color: #374151;
|
|
288
|
+
font-weight: 600;
|
|
289
|
+
padding: 0.75rem;
|
|
330
290
|
text-align: left;
|
|
331
|
-
border-bottom:
|
|
291
|
+
border-bottom: 1px solid #e5e7eb;
|
|
292
|
+
font-size: 0.875rem;
|
|
332
293
|
}
|
|
333
294
|
|
|
334
|
-
.
|
|
295
|
+
.markdown-content td {
|
|
335
296
|
border: 1px solid #e5e7eb;
|
|
336
|
-
padding:
|
|
297
|
+
padding: 0.75rem;
|
|
337
298
|
text-align: left;
|
|
338
299
|
vertical-align: top;
|
|
339
300
|
background-color: white;
|
|
301
|
+
font-size: 0.875rem;
|
|
340
302
|
}
|
|
341
303
|
|
|
342
|
-
.
|
|
304
|
+
.markdown-content tr:nth-child(even) td {
|
|
343
305
|
background-color: #f9fafb;
|
|
344
306
|
}
|
|
345
307
|
|
|
346
|
-
.
|
|
308
|
+
.markdown-content tr:hover td {
|
|
347
309
|
background-color: #f3f4f6;
|
|
348
310
|
}
|
|
349
311
|
|
|
350
|
-
/* Enhanced
|
|
351
|
-
.
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
padding: 1.5rem;
|
|
355
|
-
border-radius: 0.75rem;
|
|
356
|
-
overflow-x: auto;
|
|
357
|
-
font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
|
|
358
|
-
font-size: 0.875rem;
|
|
359
|
-
line-height: 1.6;
|
|
360
|
-
border: 1px solid #374151;
|
|
361
|
-
margin: 1.5rem 0;
|
|
362
|
-
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
|
|
312
|
+
/* Enhanced list styling */
|
|
313
|
+
.markdown-content ul li {
|
|
314
|
+
position: relative;
|
|
315
|
+
padding-left: 0.5rem;
|
|
363
316
|
}
|
|
364
317
|
|
|
365
|
-
.
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
318
|
+
.markdown-content ul li::before {
|
|
319
|
+
content: "•";
|
|
320
|
+
color: #000;
|
|
321
|
+
font-weight: bold;
|
|
322
|
+
position: absolute;
|
|
323
|
+
left: -1rem;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
.markdown-content ol li {
|
|
327
|
+
position: relative;
|
|
328
|
+
padding-left: 0.5rem;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
.markdown-content ol li::before {
|
|
332
|
+
content: counter(list-item) ".";
|
|
333
|
+
font-weight: 600;
|
|
334
|
+
position: absolute;
|
|
335
|
+
left: -1.5rem;
|
|
371
336
|
}
|
|
372
337
|
|
|
373
338
|
/* Code block container styling */
|
|
374
|
-
.
|
|
375
|
-
|
|
339
|
+
.code-block-container {
|
|
340
|
+
background: #ffffff;
|
|
341
|
+
border: 1px solid #e5e7eb;
|
|
342
|
+
border-radius: 8px;
|
|
376
343
|
overflow: hidden;
|
|
377
|
-
|
|
378
|
-
|
|
344
|
+
margin: 1rem 0;
|
|
345
|
+
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
|
|
379
346
|
}
|
|
380
347
|
|
|
381
|
-
.
|
|
382
|
-
background:
|
|
383
|
-
padding: 0.
|
|
384
|
-
border-bottom: 1px solid #
|
|
348
|
+
.code-block-header {
|
|
349
|
+
background: #f9fafb;
|
|
350
|
+
padding: 0.5rem 1rem;
|
|
351
|
+
border-bottom: 1px solid #e5e7eb;
|
|
385
352
|
font-weight: 600;
|
|
386
353
|
color: #374151;
|
|
387
354
|
font-size: 0.875rem;
|
|
@@ -389,36 +356,15 @@ const htmlContentStyles = `
|
|
|
389
356
|
letter-spacing: 0.05em;
|
|
390
357
|
}
|
|
391
358
|
|
|
392
|
-
.
|
|
393
|
-
|
|
394
|
-
padding: 1.5rem;
|
|
359
|
+
.code-block-content {
|
|
360
|
+
padding: 1rem;
|
|
395
361
|
overflow-x: auto;
|
|
396
362
|
}
|
|
363
|
+
|
|
364
|
+
.hover\:bg-gray-100:hover {
|
|
365
|
+
background-color: transparent !important;
|
|
366
|
+
}
|
|
397
367
|
`;
|
|
398
|
-
// Function to prettify HTML content
|
|
399
|
-
const prettifyHtmlContent = htmlContent => {
|
|
400
|
-
// Add semantic classes for better styling
|
|
401
|
-
let prettified = htmlContent;
|
|
402
|
-
// Enhance headings with better styling
|
|
403
|
-
prettified = prettified.replace(/<h([1-6])>/g, '<h$1 class="html-heading html-heading-$1">');
|
|
404
|
-
// Enhance lists with better styling
|
|
405
|
-
prettified = prettified.replace(/<ul>/g, '<ul class="html-list html-list-unordered">');
|
|
406
|
-
prettified = prettified.replace(/<ol>/g, '<ol class="html-list html-list-ordered">');
|
|
407
|
-
// Enhance paragraphs with better spacing
|
|
408
|
-
prettified = prettified.replace(/<p>/g, '<p class="html-paragraph">');
|
|
409
|
-
// Enhance code blocks
|
|
410
|
-
prettified = prettified.replace(/<code>/g, '<code class="html-inline-code">');
|
|
411
|
-
prettified = prettified.replace(/<pre>/g, '<pre class="html-code-block">');
|
|
412
|
-
// Enhance blockquotes
|
|
413
|
-
prettified = prettified.replace(/<blockquote>/g, '<blockquote class="html-blockquote">');
|
|
414
|
-
// Enhance tables
|
|
415
|
-
prettified = prettified.replace(/<table>/g, '<table class="html-table">');
|
|
416
|
-
prettified = prettified.replace(/<th>/g, '<th class="html-table-header">');
|
|
417
|
-
prettified = prettified.replace(/<td>/g, '<td class="html-table-cell">');
|
|
418
|
-
// Add info boxes for certain content patterns
|
|
419
|
-
prettified = prettified.replace(/<p>(Note|Tip|Info|Warning|Error):\s*(.*?)<\/p>/gi, '<div class="html-info-box"><strong>$1:</strong> $2</div>');
|
|
420
|
-
return prettified;
|
|
421
|
-
};
|
|
422
368
|
// Hook to inject CSS styles
|
|
423
369
|
const useInjectStyles = () => {
|
|
424
370
|
useEffect(() => {
|
|
@@ -477,44 +423,6 @@ const isProbablyHTML = value => {
|
|
|
477
423
|
const htmlStructurePattern = /<[^>]+>[^<]*<\/[^>]+>/i;
|
|
478
424
|
return htmlTagPattern.test(value.trim()) || htmlEntityPattern.test(value.trim()) || htmlAttrPattern.test(value.trim()) || htmlStructurePattern.test(value.trim());
|
|
479
425
|
};
|
|
480
|
-
// Detect if a string looks like a code block
|
|
481
|
-
const isCodeBlock = text => {
|
|
482
|
-
if (!text || text.length < 10) return false;
|
|
483
|
-
// Check for common programming patterns
|
|
484
|
-
const codePatterns = [/\b(if|else|for|while|switch|case|break|continue|return|function|class|import|export|const|let|var|default)\b/, /\b(public|private|protected|static|final|abstract|interface|extends|implements)\b/, /\b(try|catch|finally|throw|throws)\b/, /\b(new|this|super|null|undefined|true|false)\b/,
|
|
485
|
-
// Narrow punctuation: exclude parentheses, brackets, hyphen, question/colon to reduce false positives
|
|
486
|
-
/[{}<>;=+*/%&|^~]/, /\b(System\.out\.println|console\.log|print|printf)\b/, /\b(int|string|boolean|float|double|long|char|byte|short)\b/, /\b(void|int|main|args)\b/, /\/\/.*$/m,
|
|
487
|
-
// Single line comments
|
|
488
|
-
/\/\*[\s\S]*?\*\//m,
|
|
489
|
-
// Multi-line comments
|
|
490
|
-
/^\s*[a-zA-Z_$][a-zA-Z0-9_$]*\s*[=:]\s*/,
|
|
491
|
-
// Variable assignment
|
|
492
|
-
/^\s*[a-zA-Z_$][a-zA-Z0-9_$]*\s*\(.*\)\s*{/,
|
|
493
|
-
// Function definition
|
|
494
|
-
/\bexport\s+default\b/,
|
|
495
|
-
// Export default statements
|
|
496
|
-
/\breturn\s+\(/,
|
|
497
|
-
// Return with JSX
|
|
498
|
-
/\bJSX\.Element\b/ // JSX types
|
|
499
|
-
];
|
|
500
|
-
// Count how many patterns match
|
|
501
|
-
let matchCount = 0;
|
|
502
|
-
codePatterns.forEach(pattern => {
|
|
503
|
-
if (pattern.test(text)) {
|
|
504
|
-
matchCount++;
|
|
505
|
-
}
|
|
506
|
-
});
|
|
507
|
-
// Debug logging
|
|
508
|
-
console.log('Code block detection for:', text.substring(0, 100) + '...');
|
|
509
|
-
console.log('Match count:', matchCount);
|
|
510
|
-
console.log('Contains export default:', /\bexport\s+default\b/.test(text));
|
|
511
|
-
console.log('Contains function:', /\bfunction\b/.test(text));
|
|
512
|
-
console.log('Contains braces:', /[{}<>;]/.test(text));
|
|
513
|
-
// If multiple patterns match or if it contains specific strong indicators, consider it code
|
|
514
|
-
const result = matchCount >= 2 || /\b(if|else|for|while|function|class|export)\b/.test(text) || /[{}<>;]/.test(text) || /\bexport\s+default\b/.test(text);
|
|
515
|
-
console.log('Is code block:', result);
|
|
516
|
-
return result;
|
|
517
|
-
};
|
|
518
426
|
// Enhanced sanitizer that allows most HTML tags while maintaining security
|
|
519
427
|
const sanitizeHtml = html => {
|
|
520
428
|
try {
|
|
@@ -550,6 +458,30 @@ const sanitizeHtml = html => {
|
|
|
550
458
|
return html.replace(/<script[\s\S]*?>[\s\S]*?<\/script>/gi, '');
|
|
551
459
|
}
|
|
552
460
|
};
|
|
461
|
+
// Function to prettify HTML content
|
|
462
|
+
const prettifyHtmlContent = htmlContent => {
|
|
463
|
+
// Add semantic classes for better styling
|
|
464
|
+
let prettified = htmlContent;
|
|
465
|
+
// Enhance headings with better styling
|
|
466
|
+
prettified = prettified.replace(/<h([1-6])>/g, '<h$1 class="html-heading html-heading-$1">');
|
|
467
|
+
// Enhance lists with better styling
|
|
468
|
+
prettified = prettified.replace(/<ul>/g, '<ul class="html-list html-list-unordered">');
|
|
469
|
+
prettified = prettified.replace(/<ol>/g, '<ol class="html-list html-list-ordered">');
|
|
470
|
+
// Enhance paragraphs with better spacing
|
|
471
|
+
prettified = prettified.replace(/<p>/g, '<p class="html-paragraph">');
|
|
472
|
+
// Enhance code blocks
|
|
473
|
+
prettified = prettified.replace(/<code>/g, '<code class="html-inline-code">');
|
|
474
|
+
prettified = prettified.replace(/<pre>/g, '<pre class="html-code-block">');
|
|
475
|
+
// Enhance blockquotes
|
|
476
|
+
prettified = prettified.replace(/<blockquote>/g, '<blockquote class="html-blockquote">');
|
|
477
|
+
// Enhance tables
|
|
478
|
+
prettified = prettified.replace(/<table>/g, '<table class="html-table">');
|
|
479
|
+
prettified = prettified.replace(/<th>/g, '<th class="html-table-header">');
|
|
480
|
+
prettified = prettified.replace(/<td>/g, '<td class="html-table-cell">');
|
|
481
|
+
// Add info boxes for certain content patterns
|
|
482
|
+
prettified = prettified.replace(/<p>(Note|Tip|Info|Warning|Error):\s*(.*?)<\/p>/gi, '<div class="html-info-box"><strong>$1:</strong> $2</div>');
|
|
483
|
+
return prettified;
|
|
484
|
+
};
|
|
553
485
|
// Minimal Builder-like blocks renderer (text/image/button/columns)
|
|
554
486
|
const BuilderLikeRenderer = ({
|
|
555
487
|
blocks
|
|
@@ -564,7 +496,7 @@ const BuilderLikeRenderer = ({
|
|
|
564
496
|
const html = sanitizeHtml(block?.text || block?.data?.text || '');
|
|
565
497
|
return React__default.createElement("div", {
|
|
566
498
|
key: idx,
|
|
567
|
-
className: "
|
|
499
|
+
className: "max-w-none text-gray-800",
|
|
568
500
|
dangerouslySetInnerHTML: {
|
|
569
501
|
__html: html
|
|
570
502
|
}
|
|
@@ -606,651 +538,157 @@ const BuilderLikeRenderer = ({
|
|
|
606
538
|
blocks: col?.blocks || col?.children
|
|
607
539
|
}))));
|
|
608
540
|
}
|
|
609
|
-
return React__default.createElement("
|
|
541
|
+
return React__default.createElement("div", {
|
|
610
542
|
key: idx,
|
|
611
|
-
className: "
|
|
612
|
-
},
|
|
543
|
+
className: "message-container"
|
|
544
|
+
}, React__default.createElement("pre", {
|
|
545
|
+
className: "text-xs text-gray-600 overflow-x-auto"
|
|
546
|
+
}, JSON.stringify(block, null, 2)));
|
|
613
547
|
}));
|
|
614
548
|
};
|
|
615
|
-
// Enhanced markdown
|
|
616
|
-
// Helper: render multiple inline lists from a single paragraph like
|
|
617
|
-
// "Intro A: - item1 - item2 Intro B: - item3 - item4"
|
|
618
|
-
const tryRenderMultipleInlineLists = text => {
|
|
619
|
-
if (!text || !text.includes(' - ') || !text.includes(':')) return null;
|
|
620
|
-
// Split while keeping the section headers (ending with ":")
|
|
621
|
-
const segments = text.split(/([^:]+:\s*)/).filter(s => s.length > 0);
|
|
622
|
-
if (segments.length < 3) return null; // need at least header + content
|
|
623
|
-
const nodes = [];
|
|
624
|
-
// Handle leading text before the first header
|
|
625
|
-
if (segments[0] && !segments[0].endsWith(':')) {
|
|
626
|
-
const leading = segments[0].trim();
|
|
627
|
-
if (leading) {
|
|
628
|
-
nodes.push(React__default.createElement("p", {
|
|
629
|
-
key: `inline-leading`,
|
|
630
|
-
className: "text-gray-700 leading-relaxed"
|
|
631
|
-
}, leading));
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
for (let i = 1; i < segments.length; i += 2) {
|
|
635
|
-
const header = (segments[i] || '').trim();
|
|
636
|
-
const rest = (segments[i + 1] || '').trim();
|
|
637
|
-
if (!header.endsWith(':')) continue;
|
|
638
|
-
const parts = rest.split(/\s-\s+/).filter(p => p.trim());
|
|
639
|
-
// When split on " - ", the first element is the tail right after header; ignore if empty
|
|
640
|
-
const items = parts.length && !rest.startsWith('- ') ? parts.slice(1) : parts;
|
|
641
|
-
if (items.length >= 2) {
|
|
642
|
-
nodes.push(React__default.createElement("div", {
|
|
643
|
-
key: `inline-group-${i}`,
|
|
644
|
-
className: "space-y-2"
|
|
645
|
-
}, React__default.createElement("p", {
|
|
646
|
-
className: "text-gray-900 font-semibold leading-relaxed"
|
|
647
|
-
}, header.replace(/:$/, '')), React__default.createElement("ul", {
|
|
648
|
-
className: "space-y-2"
|
|
649
|
-
}, items.map((it, idx) => React__default.createElement("li", {
|
|
650
|
-
key: `inline-item-${i}-${idx}`,
|
|
651
|
-
className: "flex items-start space-x-3 items-center"
|
|
652
|
-
}, React__default.createElement("svg", {
|
|
653
|
-
className: "w-5 h-5 text-black mt-0.5 flex-shrink-0",
|
|
654
|
-
fill: "currentColor",
|
|
655
|
-
viewBox: "0 0 20 20"
|
|
656
|
-
}, React__default.createElement("path", {
|
|
657
|
-
fillRule: "evenodd",
|
|
658
|
-
d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",
|
|
659
|
-
clipRule: "evenodd"
|
|
660
|
-
})), React__default.createElement("span", {
|
|
661
|
-
className: "text-gray-700 leading-relaxed"
|
|
662
|
-
}, it.trim()))))));
|
|
663
|
-
} else {
|
|
664
|
-
// Not enough items; treat as plain text
|
|
665
|
-
const combined = `${header} ${rest}`.trim();
|
|
666
|
-
if (combined) {
|
|
667
|
-
nodes.push(React__default.createElement("p", {
|
|
668
|
-
key: `inline-fallback-${i}`,
|
|
669
|
-
className: "text-gray-700 leading-relaxed"
|
|
670
|
-
}, combined));
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
return nodes.length ? nodes : null;
|
|
675
|
-
};
|
|
549
|
+
// Enhanced markdown renderer using react-markdown with remark-gfm
|
|
676
550
|
const FormattedMessageContent = ({
|
|
677
551
|
content
|
|
678
552
|
}) => {
|
|
679
553
|
if (!content) return null;
|
|
680
|
-
//
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
if (content.includes('export default function Home()') || content.includes('export default') && content.includes('function') && content.includes('return')) {
|
|
684
|
-
console.log('Direct code pattern match detected!');
|
|
685
|
-
// If content has fenced code, extract language and code, removing the fences
|
|
686
|
-
const fenceMatch = content.match(/```([\w-]*)\n?([\s\S]*?)```/);
|
|
687
|
-
let language = 'typescript';
|
|
688
|
-
let codeBody = content;
|
|
689
|
-
if (fenceMatch) {
|
|
690
|
-
language = (fenceMatch[1] || 'code').trim() || 'code';
|
|
691
|
-
codeBody = fenceMatch[2];
|
|
692
|
-
}
|
|
693
|
-
// Clean up the code content for better display
|
|
694
|
-
const cleanCode = codeBody.replace(/^\s+/, '') // Remove leading whitespace
|
|
695
|
-
.replace(/\s+$/, '') // Remove trailing whitespace
|
|
696
|
-
.split('\n').map(line => line.trim()).filter(line => line.length > 0).join('\n');
|
|
554
|
+
// Check if content contains markdown patterns
|
|
555
|
+
const hasMarkdown = /[#*`>|]/.test(content) || content.includes('```');
|
|
556
|
+
if (hasMarkdown) {
|
|
697
557
|
return React__default.createElement("div", {
|
|
698
|
-
className: "
|
|
558
|
+
className: "message-container"
|
|
699
559
|
}, React__default.createElement("div", {
|
|
700
|
-
className: "
|
|
701
|
-
},
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
},
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
className: "text-xl font-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
className: "text-lg font-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
},
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
}
|
|
770
|
-
if (t.startsWith('- ') || t.startsWith('• ')) {
|
|
771
|
-
const items = t.split('\n').filter(line => line.trim());
|
|
772
|
-
parts.push(React__default.createElement("div", {
|
|
773
|
-
key: key,
|
|
774
|
-
className: "bg-blue-50 border-l-4 border-blue-500 p-4 rounded-r-lg"
|
|
775
|
-
}, React__default.createElement("ul", {
|
|
776
|
-
className: "space-y-2"
|
|
777
|
-
}, items.map((item, itemIndex) => React__default.createElement("li", {
|
|
778
|
-
key: `${key}-li-${itemIndex}`,
|
|
779
|
-
className: "flex items-start space-x-3 items-center"
|
|
780
|
-
}, React__default.createElement("svg", {
|
|
781
|
-
className: "w-5 h-5 text-black mt-0.5 flex-shrink-0",
|
|
782
|
-
fill: "currentColor",
|
|
783
|
-
viewBox: "0 0 20 20"
|
|
784
|
-
}, React__default.createElement("path", {
|
|
785
|
-
fillRule: "evenodd",
|
|
786
|
-
d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",
|
|
787
|
-
clipRule: "evenodd"
|
|
788
|
-
})), React__default.createElement("span", {
|
|
789
|
-
className: "text-gray-700 leading-relaxed"
|
|
790
|
-
}, item.replace(/^[\u2212\-•]\s*/, '')))))));
|
|
791
|
-
return;
|
|
792
|
-
}
|
|
793
|
-
if (isProbablyHTML(t)) {
|
|
794
|
-
parts.push(React__default.createElement("div", {
|
|
795
|
-
key: key,
|
|
796
|
-
className: "prose prose-sm max-w-none text-gray-800",
|
|
797
|
-
dangerouslySetInnerHTML: {
|
|
798
|
-
__html: sanitizeHtml(t)
|
|
799
|
-
}
|
|
800
|
-
}));
|
|
801
|
-
return;
|
|
802
|
-
}
|
|
803
|
-
if (t.includes('**') || t.includes('`')) {
|
|
804
|
-
const formatted = t.replace(/\*\*(.*?)\*\*/g, '<span class="font-semibold text-gray-900 bg-yellow-100 px-1 py-0.5 rounded">$1</span>').replace(/`([^`]+)`/g, '<code class="bg-gray-100 px-2 py-1 rounded text-sm font-mono text-gray-800">$1</code>');
|
|
805
|
-
parts.push(React__default.createElement("div", {
|
|
806
|
-
key: key,
|
|
560
|
+
className: "markdown-content"
|
|
561
|
+
}, React__default.createElement(ReactMarkdown, {
|
|
562
|
+
remarkPlugins: [remarkGfm],
|
|
563
|
+
components: {
|
|
564
|
+
// Custom styling for code blocks
|
|
565
|
+
code: ({
|
|
566
|
+
className,
|
|
567
|
+
children,
|
|
568
|
+
...props
|
|
569
|
+
}) => {
|
|
570
|
+
const match = /language-(\w+)/.exec(className || '');
|
|
571
|
+
const isInline = !className?.includes('language-');
|
|
572
|
+
return !isInline ? React__default.createElement("div", {
|
|
573
|
+
className: "code-block-container"
|
|
574
|
+
}, React__default.createElement("div", {
|
|
575
|
+
className: "code-block-header"
|
|
576
|
+
}, match?.[1] || 'code'), React__default.createElement("div", {
|
|
577
|
+
className: "code-block-content"
|
|
578
|
+
}, React__default.createElement("pre", {
|
|
579
|
+
className: "text-sm text-gray-900 font-mono leading-relaxed whitespace-pre-wrap"
|
|
580
|
+
}, React__default.createElement("code", {
|
|
581
|
+
className: className,
|
|
582
|
+
...props
|
|
583
|
+
}, children)))) : React__default.createElement("code", {
|
|
584
|
+
className: "bg-gray-100 px-1.5 py-0.5 rounded text-sm font-mono text-gray-800 border border-gray-200",
|
|
585
|
+
...props
|
|
586
|
+
}, children);
|
|
587
|
+
},
|
|
588
|
+
// Custom styling for headings
|
|
589
|
+
h1: ({
|
|
590
|
+
children,
|
|
591
|
+
...props
|
|
592
|
+
}) => React__default.createElement("h1", {
|
|
593
|
+
className: "text-xl font-bold text-gray-900 mb-3",
|
|
594
|
+
...props
|
|
595
|
+
}, children),
|
|
596
|
+
h2: ({
|
|
597
|
+
children,
|
|
598
|
+
...props
|
|
599
|
+
}) => React__default.createElement("h2", {
|
|
600
|
+
className: "text-lg font-semibold text-gray-800 mb-2",
|
|
601
|
+
...props
|
|
602
|
+
}, children),
|
|
603
|
+
h3: ({
|
|
604
|
+
children,
|
|
605
|
+
...props
|
|
606
|
+
}) => React__default.createElement("h3", {
|
|
607
|
+
className: "text-base font-medium text-gray-700 mb-2",
|
|
608
|
+
...props
|
|
609
|
+
}, children),
|
|
610
|
+
// Custom styling for lists
|
|
611
|
+
ul: ({
|
|
612
|
+
children,
|
|
613
|
+
...props
|
|
614
|
+
}) => React__default.createElement("ul", {
|
|
615
|
+
className: "space-y-1",
|
|
616
|
+
...props
|
|
617
|
+
}, children),
|
|
618
|
+
ol: ({
|
|
619
|
+
children,
|
|
620
|
+
...props
|
|
621
|
+
}) => React__default.createElement("ol", {
|
|
622
|
+
className: "space-y-1",
|
|
623
|
+
...props
|
|
624
|
+
}, children),
|
|
625
|
+
li: ({
|
|
626
|
+
children,
|
|
627
|
+
...props
|
|
628
|
+
}) => React__default.createElement("li", {
|
|
807
629
|
className: "text-gray-700 leading-relaxed",
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
},
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
}, React__default.createElement("code", null, cleanCode)))));
|
|
862
|
-
lastIndex = m.index + full.length;
|
|
863
|
-
}
|
|
864
|
-
const after = normalizedContent.slice(lastIndex);
|
|
865
|
-
if (!foundAnyFence) {
|
|
866
|
-
// Fallback: opening fence exists but no closing fence found
|
|
867
|
-
const fenceIndex = normalizedContent.indexOf('```');
|
|
868
|
-
const before = normalizedContent.slice(0, fenceIndex);
|
|
869
|
-
const afterFence = normalizedContent.slice(fenceIndex + 3); // skip opening backticks
|
|
870
|
-
// Try to read language up to end of line. If none, treat whole remainder as code.
|
|
871
|
-
const firstNewline = afterFence.indexOf('\n');
|
|
872
|
-
const language = firstNewline >= 0 ? afterFence.slice(0, firstNewline).trim() || 'code' : 'code';
|
|
873
|
-
const rawCodeBody = firstNewline >= 0 ? afterFence.slice(firstNewline + 1) : afterFence;
|
|
874
|
-
const codeBody = rawCodeBody.replace(/^\s+/, '').replace(/\s+$/, '').split('\n').map(line => line.trimEnd()).join('\n');
|
|
875
|
-
pushTextBlock(before, `global-fallback-before-${fenceIndex}`);
|
|
876
|
-
parts.push(React__default.createElement("div", {
|
|
877
|
-
key: `global-fallback-code-${fenceIndex}`,
|
|
878
|
-
className: "rounded-xl border border-gray-200 bg-gray-50 overflow-hidden shadow-sm"
|
|
879
|
-
}, React__default.createElement("div", {
|
|
880
|
-
className: "px-4 py-2 text-sm font-bold text-gray-900 bg-gray-100 border-b border-gray-200"
|
|
881
|
-
}, language), React__default.createElement("div", {
|
|
882
|
-
className: "px-4 py-4 overflow-x-auto bg-white"
|
|
883
|
-
}, React__default.createElement("pre", {
|
|
884
|
-
className: "text-sm text-gray-900 font-mono leading-relaxed whitespace-pre-wrap not-prose"
|
|
885
|
-
}, React__default.createElement("code", null, codeBody)))));
|
|
886
|
-
} else {
|
|
887
|
-
// If there's a dangling opening fence in the tail, render it as a fallback code block
|
|
888
|
-
if (after.includes('```')) {
|
|
889
|
-
const fenceIndexTail = after.indexOf('```');
|
|
890
|
-
const beforeTail = after.slice(0, fenceIndexTail);
|
|
891
|
-
const afterFenceTail = after.slice(fenceIndexTail + 3);
|
|
892
|
-
const firstNewlineTail = afterFenceTail.indexOf('\n');
|
|
893
|
-
const languageTail = firstNewlineTail >= 0 ? afterFenceTail.slice(0, firstNewlineTail).trim() || 'code' : 'code';
|
|
894
|
-
const rawCodeTail = firstNewlineTail >= 0 ? afterFenceTail.slice(firstNewlineTail + 1) : afterFenceTail;
|
|
895
|
-
const cleanTail = rawCodeTail.replace(/^\s+/, '').replace(/\s+$/, '').split('\n').map(line => line.trimEnd()).join('\n');
|
|
896
|
-
pushTextBlock(beforeTail, `global-after-text-${lastIndex}`);
|
|
897
|
-
parts.push(React__default.createElement("div", {
|
|
898
|
-
key: `global-after-fallback-code-${lastIndex}`,
|
|
899
|
-
className: "rounded-xl border border-gray-200 bg-gray-50 overflow-hidden shadow-sm"
|
|
900
|
-
}, React__default.createElement("div", {
|
|
901
|
-
className: "px-4 py-2 text-sm font-bold text-gray-900 bg-gray-100 border-b border-gray-200"
|
|
902
|
-
}, languageTail), React__default.createElement("div", {
|
|
903
|
-
className: "px-4 py-4 overflow-x-auto bg-white"
|
|
904
|
-
}, React__default.createElement("pre", {
|
|
905
|
-
className: "text-sm text-gray-900 font-mono leading-relaxed whitespace-pre-wrap not-prose"
|
|
906
|
-
}, React__default.createElement("code", null, cleanTail)))));
|
|
907
|
-
} else {
|
|
908
|
-
pushTextBlock(after, `global-after-${lastIndex}`);
|
|
630
|
+
...props
|
|
631
|
+
}, children),
|
|
632
|
+
// Custom styling for blockquotes
|
|
633
|
+
blockquote: ({
|
|
634
|
+
children,
|
|
635
|
+
...props
|
|
636
|
+
}) => React__default.createElement("blockquote", {
|
|
637
|
+
className: "border-l-4 border-blue-400 pl-3 py-2 bg-blue-50 rounded-r-md my-3",
|
|
638
|
+
...props
|
|
639
|
+
}, children),
|
|
640
|
+
// Custom styling for tables
|
|
641
|
+
table: ({
|
|
642
|
+
children,
|
|
643
|
+
...props
|
|
644
|
+
}) => React__default.createElement("div", {
|
|
645
|
+
className: "overflow-x-auto my-3"
|
|
646
|
+
}, React__default.createElement("table", {
|
|
647
|
+
className: "min-w-full border border-gray-200 rounded-md overflow-hidden",
|
|
648
|
+
...props
|
|
649
|
+
}, children)),
|
|
650
|
+
th: ({
|
|
651
|
+
children,
|
|
652
|
+
...props
|
|
653
|
+
}) => React__default.createElement("th", {
|
|
654
|
+
className: "px-3 py-2 text-left font-medium text-gray-700 border border-gray-200",
|
|
655
|
+
...props
|
|
656
|
+
}, children),
|
|
657
|
+
td: ({
|
|
658
|
+
children,
|
|
659
|
+
...props
|
|
660
|
+
}) => React__default.createElement("td", {
|
|
661
|
+
className: "px-3 py-2 border border-gray-200 text-gray-700",
|
|
662
|
+
...props
|
|
663
|
+
}, children),
|
|
664
|
+
// Custom styling for task lists (from remark-gfm)
|
|
665
|
+
input: ({
|
|
666
|
+
checked,
|
|
667
|
+
...props
|
|
668
|
+
}) => React__default.createElement("input", {
|
|
669
|
+
type: "checkbox",
|
|
670
|
+
checked: checked,
|
|
671
|
+
readOnly: true,
|
|
672
|
+
className: "mr-2 mt-1 h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500",
|
|
673
|
+
...props
|
|
674
|
+
}),
|
|
675
|
+
// Custom styling for strikethrough (from remark-gfm)
|
|
676
|
+
del: ({
|
|
677
|
+
children,
|
|
678
|
+
...props
|
|
679
|
+
}) => React__default.createElement("del", {
|
|
680
|
+
className: "text-gray-500 line-through",
|
|
681
|
+
...props
|
|
682
|
+
}, children)
|
|
909
683
|
}
|
|
910
|
-
}
|
|
911
|
-
return React__default.createElement("div", {
|
|
912
|
-
className: "space-y-4"
|
|
913
|
-
}, parts);
|
|
684
|
+
}, content)));
|
|
914
685
|
}
|
|
915
|
-
//
|
|
916
|
-
const blocks = normalizedContent.split('\n\n').filter(block => block.trim());
|
|
917
|
-
// Debug logging for blocks
|
|
918
|
-
console.log('Content blocks:', blocks.map(b => b.substring(0, 100) + '...'));
|
|
686
|
+
// For plain text content
|
|
919
687
|
return React__default.createElement("div", {
|
|
920
|
-
className: "
|
|
921
|
-
},
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
console.log(`Block ${index}:`, trimmedBlock.substring(0, 100) + '...');
|
|
925
|
-
console.log(`Block ${index} isCodeBlock:`, isCodeBlock(trimmedBlock));
|
|
926
|
-
// If the block contains fenced code anywhere, render text parts + code parts in order
|
|
927
|
-
if (trimmedBlock.includes('```')) {
|
|
928
|
-
const parts = [];
|
|
929
|
-
const pushTextBlock = (text, key) => {
|
|
930
|
-
const t = (text || '').trim();
|
|
931
|
-
if (!t) return;
|
|
932
|
-
const multiInlineInner = tryRenderMultipleInlineLists(t);
|
|
933
|
-
if (multiInlineInner) {
|
|
934
|
-
multiInlineInner.forEach((n, idx) => parts.push(React__default.createElement(React__default.Fragment, {
|
|
935
|
-
key: `${key}-mil-${idx}`
|
|
936
|
-
}, n)));
|
|
937
|
-
return;
|
|
938
|
-
}
|
|
939
|
-
if (t.startsWith('# ')) {
|
|
940
|
-
parts.push(React__default.createElement("h1", {
|
|
941
|
-
key: key,
|
|
942
|
-
className: "text-2xl font-bold text-gray-900 mb-4 bg-gradient-to-r from-blue-600 to-purple-600 bg-clip-text text-transparent"
|
|
943
|
-
}, t.substring(2)));
|
|
944
|
-
return;
|
|
945
|
-
}
|
|
946
|
-
if (t.startsWith('## ')) {
|
|
947
|
-
parts.push(React__default.createElement("h2", {
|
|
948
|
-
key: key,
|
|
949
|
-
className: "text-xl font-semibold text-gray-800 mb-3 border-b border-gray-200 pb-2"
|
|
950
|
-
}, t.substring(3)));
|
|
951
|
-
return;
|
|
952
|
-
}
|
|
953
|
-
if (t.startsWith('### ')) {
|
|
954
|
-
parts.push(React__default.createElement("h3", {
|
|
955
|
-
key: key,
|
|
956
|
-
className: "text-lg font-medium text-gray-700 mb-2"
|
|
957
|
-
}, t.substring(4)));
|
|
958
|
-
return;
|
|
959
|
-
}
|
|
960
|
-
// Inline list heuristic inside block
|
|
961
|
-
if (!t.includes('\n') && t.includes(' - ') && t.split(' - ').length >= 3) {
|
|
962
|
-
const [intro, ...rawItems] = t.split(/\s-\s+/);
|
|
963
|
-
parts.push(React__default.createElement("div", {
|
|
964
|
-
key: `${key}-inline-list`,
|
|
965
|
-
className: "space-y-2"
|
|
966
|
-
}, intro.trim() ? React__default.createElement("p", {
|
|
967
|
-
className: "text-gray-700 leading-relaxed"
|
|
968
|
-
}, intro.trim()) : null, React__default.createElement("ul", {
|
|
969
|
-
className: "space-y-2"
|
|
970
|
-
}, rawItems.map((item, itemIndex) => React__default.createElement("li", {
|
|
971
|
-
key: `${key}-inli-${itemIndex}`,
|
|
972
|
-
className: "flex items-start space-x-3 items-center"
|
|
973
|
-
}, React__default.createElement("svg", {
|
|
974
|
-
className: "w-5 h-5 text-black mt-0.5 flex-shrink-0",
|
|
975
|
-
fill: "currentColor",
|
|
976
|
-
viewBox: "0 0 20 20"
|
|
977
|
-
}, React__default.createElement("path", {
|
|
978
|
-
fillRule: "evenodd",
|
|
979
|
-
d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",
|
|
980
|
-
clipRule: "evenodd"
|
|
981
|
-
})), React__default.createElement("span", {
|
|
982
|
-
className: "text-gray-700 leading-relaxed"
|
|
983
|
-
}, item.trim()))))));
|
|
984
|
-
return;
|
|
985
|
-
}
|
|
986
|
-
if (t.startsWith('- ') || t.startsWith('• ')) {
|
|
987
|
-
const items = t.split('\n').filter(line => line.trim());
|
|
988
|
-
parts.push(
|
|
989
|
-
// <div key={key} className="bg-blue-50 border-l-4 border-blue-500 p-4 rounded-r-lg">
|
|
990
|
-
React__default.createElement("div", {
|
|
991
|
-
key: key,
|
|
992
|
-
className: " p-4 rounded-r-lg"
|
|
993
|
-
}, React__default.createElement("ul", {
|
|
994
|
-
className: "space-y-2"
|
|
995
|
-
}, items.map((item, itemIndex) => React__default.createElement("li", {
|
|
996
|
-
key: `${key}-li-${itemIndex}`,
|
|
997
|
-
className: "flex items-start space-x-3 items-center"
|
|
998
|
-
}, React__default.createElement("svg", {
|
|
999
|
-
className: "w-5 h-5 text-black mt-0.5 flex-shrink-0",
|
|
1000
|
-
fill: "currentColor",
|
|
1001
|
-
viewBox: "0 0 20 20"
|
|
1002
|
-
}, React__default.createElement("path", {
|
|
1003
|
-
fillRule: "evenodd",
|
|
1004
|
-
d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",
|
|
1005
|
-
clipRule: "evenodd"
|
|
1006
|
-
})), React__default.createElement("span", {
|
|
1007
|
-
className: "text-gray-700 leading-relaxed"
|
|
1008
|
-
}, item.replace(/^[\u2212\-•]\s*/, '')))))));
|
|
1009
|
-
return;
|
|
1010
|
-
}
|
|
1011
|
-
if (t.includes('**') || t.includes('`')) {
|
|
1012
|
-
const formatted = t.replace(/\*\*(.*?)\*\*/g, '<span class="font-semibold text-gray-900 bg-yellow-100 px-1 py-0.5 rounded">$1</span>').replace(/`([^`]+)`/g, '<code class="bg-gray-100 px-2 py-1 rounded text-sm font-mono text-gray-800">$1</code>');
|
|
1013
|
-
parts.push(React__default.createElement("div", {
|
|
1014
|
-
key: key,
|
|
1015
|
-
className: "text-gray-700 leading-relaxed",
|
|
1016
|
-
dangerouslySetInnerHTML: {
|
|
1017
|
-
__html: sanitizeHtml(formatted)
|
|
1018
|
-
}
|
|
1019
|
-
}));
|
|
1020
|
-
return;
|
|
1021
|
-
}
|
|
1022
|
-
// Check if the text looks like a code block (contains programming keywords, syntax, etc.)
|
|
1023
|
-
if (isCodeBlock(t)) {
|
|
1024
|
-
// Clean up the code content for better display
|
|
1025
|
-
const cleanCode = t.replace(/^\s+/, '') // Remove leading whitespace
|
|
1026
|
-
.replace(/\s+$/, '') // Remove trailing whitespace
|
|
1027
|
-
.split('\n').map(line => line.trim()).filter(line => line.length > 0).join('\n');
|
|
1028
|
-
parts.push(React__default.createElement("div", {
|
|
1029
|
-
key: key,
|
|
1030
|
-
className: "rounded-xl border border-gray-200 bg-gray-50 overflow-hidden"
|
|
1031
|
-
}, React__default.createElement("div", {
|
|
1032
|
-
className: "px-4 py-2 text-sm font-bold text-gray-900"
|
|
1033
|
-
}, "typescript"), React__default.createElement("div", {
|
|
1034
|
-
className: "px-4 pb-4 overflow-x-auto"
|
|
1035
|
-
}, React__default.createElement("pre", {
|
|
1036
|
-
className: "text-sm text-gray-900 font-mono leading-relaxed whitespace-pre-wrap not-prose"
|
|
1037
|
-
}, React__default.createElement("code", null, cleanCode)))));
|
|
1038
|
-
return;
|
|
1039
|
-
}
|
|
1040
|
-
parts.push(React__default.createElement("p", {
|
|
1041
|
-
key: key,
|
|
1042
|
-
className: "text-gray-700 leading-relaxed whitespace-pre-wrap"
|
|
1043
|
-
}, t));
|
|
1044
|
-
};
|
|
1045
|
-
const codeRegex = /```([\w-]*)\n?([\s\S]*?)```/g;
|
|
1046
|
-
let lastIndex = 0;
|
|
1047
|
-
let match;
|
|
1048
|
-
while ((match = codeRegex.exec(trimmedBlock)) !== null) {
|
|
1049
|
-
const [full, lang, code] = match;
|
|
1050
|
-
const before = trimmedBlock.slice(lastIndex, match.index).trim();
|
|
1051
|
-
pushTextBlock(before, `${index}-before-${lastIndex}`);
|
|
1052
|
-
const language = (lang || '').trim() || 'code';
|
|
1053
|
-
// Clean up the code content properly
|
|
1054
|
-
const cleanCode = code.replace(/^\s+/, '') // Remove leading whitespace
|
|
1055
|
-
.replace(/\s+$/, '') // Remove trailing whitespace
|
|
1056
|
-
.split('\n').map(line => line.trim()).filter(line => line.length > 0).join('\n');
|
|
1057
|
-
parts.push(React__default.createElement("div", {
|
|
1058
|
-
key: `${index}-code-${match.index}`,
|
|
1059
|
-
className: "rounded-xl border border-gray-200 bg-gray-50 overflow-hidden shadow-sm"
|
|
1060
|
-
}, React__default.createElement("div", {
|
|
1061
|
-
className: "px-4 py-2 text-sm font-bold text-gray-900 bg-gray-100 border-b border-gray-200"
|
|
1062
|
-
}, language), React__default.createElement("div", {
|
|
1063
|
-
className: "px-4 py-4 overflow-x-auto bg-white"
|
|
1064
|
-
}, React__default.createElement("pre", {
|
|
1065
|
-
className: "text-sm text-gray-900 font-mono leading-relaxed whitespace-pre-wrap not-prose"
|
|
1066
|
-
}, React__default.createElement("code", null, cleanCode)))));
|
|
1067
|
-
lastIndex = match.index + full.length;
|
|
1068
|
-
}
|
|
1069
|
-
const after = trimmedBlock.slice(lastIndex).trim();
|
|
1070
|
-
pushTextBlock(after, `${index}-after`);
|
|
1071
|
-
return React__default.createElement("div", {
|
|
1072
|
-
key: index,
|
|
1073
|
-
className: "space-y-3"
|
|
1074
|
-
}, parts);
|
|
1075
|
-
}
|
|
1076
|
-
// Raw HTML support per block
|
|
1077
|
-
if (isProbablyHTML(trimmedBlock)) {
|
|
1078
|
-
return React__default.createElement("div", {
|
|
1079
|
-
key: index,
|
|
1080
|
-
className: "prose prose-sm max-w-none text-gray-800",
|
|
1081
|
-
dangerouslySetInnerHTML: {
|
|
1082
|
-
__html: sanitizeHtml(trimmedBlock)
|
|
1083
|
-
}
|
|
1084
|
-
});
|
|
1085
|
-
}
|
|
1086
|
-
// Check for different content types
|
|
1087
|
-
if (trimmedBlock.startsWith('# ')) {
|
|
1088
|
-
// Main heading
|
|
1089
|
-
return React__default.createElement("h1", {
|
|
1090
|
-
key: index,
|
|
1091
|
-
className: "text-2xl font-bold text-gray-900 mb-4 bg-gradient-to-r from-blue-600 to-purple-600 bg-clip-text text-transparent"
|
|
1092
|
-
}, trimmedBlock.substring(2));
|
|
1093
|
-
} else if (trimmedBlock.startsWith('## ')) {
|
|
1094
|
-
// Secondary heading
|
|
1095
|
-
return React__default.createElement("h2", {
|
|
1096
|
-
key: index,
|
|
1097
|
-
className: "text-xl font-semibold text-gray-800 mb-3 border-b border-gray-200 pb-2"
|
|
1098
|
-
}, trimmedBlock.substring(3));
|
|
1099
|
-
} else if (trimmedBlock.startsWith('### ')) {
|
|
1100
|
-
// Tertiary heading
|
|
1101
|
-
return React__default.createElement("h3", {
|
|
1102
|
-
key: index,
|
|
1103
|
-
className: "text-lg font-medium text-gray-700 mb-2"
|
|
1104
|
-
}, trimmedBlock.substring(4));
|
|
1105
|
-
} else if (trimmedBlock.startsWith('- ') || trimmedBlock.startsWith('• ')) {
|
|
1106
|
-
// Bullet points
|
|
1107
|
-
const items = trimmedBlock.split('\n').filter(line => line.trim());
|
|
1108
|
-
return (
|
|
1109
|
-
// <div key={index} className="bg-blue-50 border-l-4 border-blue-500 p-4 rounded-r-lg">
|
|
1110
|
-
React__default.createElement("div", {
|
|
1111
|
-
key: index,
|
|
1112
|
-
className: " p-4 rounded-r-lg"
|
|
1113
|
-
}, React__default.createElement("ul", {
|
|
1114
|
-
className: "space-y-2"
|
|
1115
|
-
}, items.map((item, itemIndex) => React__default.createElement("li", {
|
|
1116
|
-
key: itemIndex,
|
|
1117
|
-
className: "flex items-start space-x-3 items-center"
|
|
1118
|
-
}, React__default.createElement("svg", {
|
|
1119
|
-
className: "w-5 h-5 text-black mt-0.5 flex-shrink-0",
|
|
1120
|
-
fill: "currentColor",
|
|
1121
|
-
viewBox: "0 0 20 20"
|
|
1122
|
-
}, React__default.createElement("path", {
|
|
1123
|
-
fillRule: "evenodd",
|
|
1124
|
-
d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",
|
|
1125
|
-
clipRule: "evenodd"
|
|
1126
|
-
})), React__default.createElement("span", {
|
|
1127
|
-
className: "text-gray-700 leading-relaxed"
|
|
1128
|
-
}, item.replace(/^[-•]\s*/, '').split(/(\*\*.*?\*\*)/).map((part, partIndex) => {
|
|
1129
|
-
if (part.match(/\*\*.*?\*\*/)) {
|
|
1130
|
-
// Extract text between ** markers and make it bold
|
|
1131
|
-
const boldText = part.replace(/\*\*/g, '');
|
|
1132
|
-
return React__default.createElement("strong", {
|
|
1133
|
-
key: partIndex,
|
|
1134
|
-
className: "font-semibold text-gray-900"
|
|
1135
|
-
}, boldText);
|
|
1136
|
-
}
|
|
1137
|
-
return part;
|
|
1138
|
-
}))))))
|
|
1139
|
-
);
|
|
1140
|
-
} else if (trimmedBlock.startsWith('```')) {
|
|
1141
|
-
// Code block
|
|
1142
|
-
const codeMatch = trimmedBlock.match(/^```([\w-]*)\n?([\s\S]*?)```$/);
|
|
1143
|
-
if (codeMatch) {
|
|
1144
|
-
const [, language, codeContent] = codeMatch;
|
|
1145
|
-
const lang = (language || '').trim() || 'code';
|
|
1146
|
-
// Clean up the code content properly
|
|
1147
|
-
const cleanCode = codeContent.replace(/^\s+/, '') // Remove leading whitespace
|
|
1148
|
-
.replace(/\s+$/, '') // Remove trailing whitespace
|
|
1149
|
-
.split('\n').map(line => line.trim()).filter(line => line.length > 0).join('\n');
|
|
1150
|
-
return React__default.createElement("div", {
|
|
1151
|
-
key: index,
|
|
1152
|
-
className: "rounded-xl border border-gray-200 bg-gray-50 overflow-hidden shadow-sm"
|
|
1153
|
-
}, React__default.createElement("div", {
|
|
1154
|
-
className: "px-4 py-2 text-sm font-bold text-gray-900 bg-gray-100 border-b border-gray-200"
|
|
1155
|
-
}, lang), React__default.createElement("div", {
|
|
1156
|
-
className: "px-4 py-4 overflow-x-auto bg-white"
|
|
1157
|
-
}, React__default.createElement("pre", {
|
|
1158
|
-
className: "text-sm text-gray-900 font-mono leading-relaxed whitespace-pre-wrap not-prose"
|
|
1159
|
-
}, React__default.createElement("code", null, cleanCode))));
|
|
1160
|
-
}
|
|
1161
|
-
// Fallback for malformed code blocks
|
|
1162
|
-
const codeContent = trimmedBlock.replace(/^```[\w]*\n?/, '').replace(/```$/, '');
|
|
1163
|
-
// If the fenced code actually looks like plain bullet text, render as text instead of code
|
|
1164
|
-
const hyphenLines = codeContent.split('\n').filter(l => /^[-•]/.test(l.trim())).length;
|
|
1165
|
-
const hasCodeSymbols = /[{}<>;=]/.test(codeContent) || /\b(function|class|import|export)\b/.test(codeContent);
|
|
1166
|
-
if (hyphenLines >= 2 && !hasCodeSymbols) {
|
|
1167
|
-
return React__default.createElement("p", {
|
|
1168
|
-
key: index,
|
|
1169
|
-
className: "text-gray-700 leading-relaxed whitespace-pre-wrap"
|
|
1170
|
-
}, codeContent);
|
|
1171
|
-
}
|
|
1172
|
-
return React__default.createElement("div", {
|
|
1173
|
-
key: index,
|
|
1174
|
-
className: "rounded-xl border border-gray-200 bg-gray-50 overflow-hidden shadow-sm"
|
|
1175
|
-
}, React__default.createElement("div", {
|
|
1176
|
-
className: "px-4 py-2 text-sm font-bold text-gray-900 bg-gray-100 border-b border-gray-200"
|
|
1177
|
-
}, "code"), React__default.createElement("div", {
|
|
1178
|
-
className: "px-4 py-4 overflow-x-auto bg-white"
|
|
1179
|
-
}, React__default.createElement("pre", {
|
|
1180
|
-
className: "text-sm text-gray-900 font-mono leading-relaxed whitespace-pre-wrap not-prose"
|
|
1181
|
-
}, React__default.createElement("code", null, codeContent))));
|
|
1182
|
-
} else if (trimmedBlock.startsWith('🔧 ')) {
|
|
1183
|
-
// Tool status message - render as bordered container
|
|
1184
|
-
const toolText = trimmedBlock.substring(2); // Remove the 🔧 emoji
|
|
1185
|
-
return React__default.createElement("div", {
|
|
1186
|
-
key: index,
|
|
1187
|
-
className: "mt-2"
|
|
1188
|
-
}, React__default.createElement("div", {
|
|
1189
|
-
className: "inline-block px-3 py-1 bg-gray-100 border border-gray-300 rounded-lg text-sm text-gray-700"
|
|
1190
|
-
}, React__default.createElement("span", {
|
|
1191
|
-
className: "text-green-500 mr-2"
|
|
1192
|
-
}, "\uD83D\uDD27"), toolText));
|
|
1193
|
-
} else if (trimmedBlock.includes('**') || trimmedBlock.includes('`')) {
|
|
1194
|
-
// Inline formatting (bold, inline code, highlights)
|
|
1195
|
-
const formattedContent = trimmedBlock.replace(/\*\*(.*?)\*\*/g, '<span class="font-semibold text-gray-900 bg-yellow-100 px-1 py-0.5 rounded">$1</span>').replace(/`([^`]+)`/g, '<code class="bg-gray-100 px-2 py-1 rounded text-sm font-mono text-gray-800">$1</code>');
|
|
1196
|
-
return React__default.createElement("div", {
|
|
1197
|
-
key: index,
|
|
1198
|
-
className: "text-gray-700 leading-relaxed",
|
|
1199
|
-
dangerouslySetInnerHTML: {
|
|
1200
|
-
__html: sanitizeHtml(formattedContent)
|
|
1201
|
-
}
|
|
1202
|
-
});
|
|
1203
|
-
} else if (isCodeBlock(trimmedBlock)) {
|
|
1204
|
-
// Code block detection for content that looks like code
|
|
1205
|
-
// Clean up the code content for better display
|
|
1206
|
-
const cleanCode = trimmedBlock.replace(/^\s+/, '') // Remove leading whitespace
|
|
1207
|
-
.replace(/\s+$/, '') // Remove trailing whitespace
|
|
1208
|
-
.split('\n').map(line => line.trim()).filter(line => line.length > 0).join('\n');
|
|
1209
|
-
// Heuristic: if the "code" contains many leading hyphen bullets and no typical code symbols, treat as text
|
|
1210
|
-
const hyphenLines = cleanCode.split('\n').filter(l => /^[-•]/.test(l.trim())).length;
|
|
1211
|
-
const hasCodeSymbols = /[{}<>;=]/.test(cleanCode) || /\b(function|class|import|export)\b/.test(cleanCode);
|
|
1212
|
-
if (hyphenLines >= 2 && !hasCodeSymbols) {
|
|
1213
|
-
return React__default.createElement("p", {
|
|
1214
|
-
key: index,
|
|
1215
|
-
className: "text-gray-700 leading-relaxed whitespace-pre-wrap"
|
|
1216
|
-
}, trimmedBlock);
|
|
1217
|
-
}
|
|
1218
|
-
return React__default.createElement("div", {
|
|
1219
|
-
key: index,
|
|
1220
|
-
className: "rounded-xl border border-gray-200 bg-gray-50 overflow-hidden"
|
|
1221
|
-
}, React__default.createElement("div", {
|
|
1222
|
-
className: "px-4 py-2 text-sm font-bold text-gray-900"
|
|
1223
|
-
}, "typescript"), React__default.createElement("div", {
|
|
1224
|
-
className: "px-4 pb-4 overflow-x-auto"
|
|
1225
|
-
}, React__default.createElement("pre", {
|
|
1226
|
-
className: "text-sm text-gray-900 font-mono leading-relaxed whitespace-pre-wrap not-prose"
|
|
1227
|
-
}, React__default.createElement("code", null, cleanCode))));
|
|
1228
|
-
} else if (
|
|
1229
|
-
// Fallback: More aggressive code detection for specific patterns
|
|
1230
|
-
trimmedBlock.includes('export default') || trimmedBlock.includes('function') || trimmedBlock.includes('return (') || trimmedBlock.includes('className=') || trimmedBlock.includes('Route::') || trimmedBlock.includes('class Post') || trimmedBlock.includes('extends Model') || trimmedBlock.includes('extends Controller') || trimmedBlock.includes('{') && trimmedBlock.includes('}') && trimmedBlock.includes(';')) {
|
|
1231
|
-
console.log('Fallback code detection triggered for block:', trimmedBlock.substring(0, 100) + '...');
|
|
1232
|
-
// Clean up the code content for better display
|
|
1233
|
-
const cleanCode = trimmedBlock.replace(/^\s+/, '') // Remove leading whitespace
|
|
1234
|
-
.replace(/\s+$/, '') // Remove trailing whitespace
|
|
1235
|
-
.split('\n').map(line => line.trim()).filter(line => line.length > 0).join('\n');
|
|
1236
|
-
return React__default.createElement("div", {
|
|
1237
|
-
key: index,
|
|
1238
|
-
className: "rounded-xl border border-gray-200 bg-gray-50 overflow-hidden shadow-sm"
|
|
1239
|
-
}, React__default.createElement("div", {
|
|
1240
|
-
className: "px-4 py-2 text-sm font-bold text-gray-900 bg-gray-100 border-b border-gray-200"
|
|
1241
|
-
}, "code"), React__default.createElement("div", {
|
|
1242
|
-
className: "px-4 py-4 overflow-x-auto bg-white"
|
|
1243
|
-
}, React__default.createElement("pre", {
|
|
1244
|
-
className: "text-sm text-gray-900 font-mono leading-relaxed whitespace-pre-wrap not-prose"
|
|
1245
|
-
}, React__default.createElement("code", null, cleanCode))));
|
|
1246
|
-
} else {
|
|
1247
|
-
// Regular paragraph
|
|
1248
|
-
return React__default.createElement("p", {
|
|
1249
|
-
key: index,
|
|
1250
|
-
className: "text-gray-700 leading-relaxed whitespace-pre-wrap"
|
|
1251
|
-
}, trimmedBlock);
|
|
1252
|
-
}
|
|
1253
|
-
}));
|
|
688
|
+
className: "message-container"
|
|
689
|
+
}, React__default.createElement("p", {
|
|
690
|
+
className: "text-gray-700 leading-relaxed whitespace-pre-wrap"
|
|
691
|
+
}, content));
|
|
1254
692
|
};
|
|
1255
693
|
// Detect predominant text direction (RTL/LTR) for international content
|
|
1256
694
|
const detectTextDirection = text => {
|
|
@@ -1377,26 +815,27 @@ const ModernMessageBubble = ({
|
|
|
1377
815
|
const handleClick = () => {
|
|
1378
816
|
onMessageClick?.(message);
|
|
1379
817
|
};
|
|
818
|
+
const isAssistantRole = message?.propsConfiguration?.contents?.role === 'ASSISTANT';
|
|
1380
819
|
// For user messages, create a right-aligned layout with avatar and name
|
|
1381
820
|
if (isOwnMessage) {
|
|
1382
821
|
const authorName = message.author?.givenName && message.author?.familyName ? `${message.author.givenName} ${message.author.familyName}` : message.author?.username || 'You';
|
|
1383
822
|
return React__default.createElement("div", {
|
|
1384
|
-
className:
|
|
823
|
+
className: `py-1 hover:bg-gray-50 hover:bg-opacity-50 rounded px-1 sm:px-2 -mx-1 sm:-mx-2 group ${isAssistantRole ? 'border border-gray-200' : ''}`
|
|
1385
824
|
}, React__default.createElement("div", {
|
|
1386
825
|
className: "flex items-start justify-end gap-2"
|
|
1387
826
|
}, React__default.createElement("div", {
|
|
1388
827
|
className: "flex flex-col items-end max-w-xs lg:max-w-md"
|
|
1389
|
-
}, React__default.createElement("div", {
|
|
828
|
+
}, !isAssistantRole && React__default.createElement("div", {
|
|
1390
829
|
className: "flex items-end space-x-2 mb-0.5"
|
|
1391
830
|
}, React__default.createElement("span", {
|
|
1392
831
|
className: "text-sm font-semibold text-gray-900"
|
|
1393
832
|
}, authorName)), React__default.createElement("div", {
|
|
1394
|
-
className:
|
|
1395
|
-
onClick: handleClick,
|
|
833
|
+
className: `text-sm text-gray-900 ${isAssistantRole ? 'cursor-pointer' : ''} px-1 sm:px-2 py-1 rounded`,
|
|
834
|
+
onClick: isAssistantRole ? handleClick : undefined,
|
|
1396
835
|
dir: detectTextDirection(message?.message || ''),
|
|
1397
836
|
lang: detectLanguageTag(message?.message || '')
|
|
1398
837
|
}, message.message && React__default.createElement("div", {
|
|
1399
|
-
className: "
|
|
838
|
+
className: "max-w-none"
|
|
1400
839
|
}, isProbablyHTML(message.message) ? React__default.createElement("div", {
|
|
1401
840
|
className: "text-gray-800 html-content",
|
|
1402
841
|
dangerouslySetInnerHTML: {
|
|
@@ -1417,13 +856,13 @@ const ModernMessageBubble = ({
|
|
|
1417
856
|
}, React__default.createElement(FilesList, {
|
|
1418
857
|
uploaded: true,
|
|
1419
858
|
files: message.files.data
|
|
1420
|
-
})))), React__default.createElement("div", {
|
|
859
|
+
})))), !isAssistantRole && React__default.createElement("div", {
|
|
1421
860
|
className: "flex-shrink-0 mt-0.5"
|
|
1422
861
|
}, React__default.createElement("img", {
|
|
1423
|
-
className:
|
|
862
|
+
className: `w-8 h-8 sm:w-10 sm:h-10 rounded-lg ${isAssistantRole ? '' : 'cursor-pointer hover:opacity-80'} transition-opacity object-cover`,
|
|
1424
863
|
src: message.author?.picture || '/default-avatar.svg',
|
|
1425
864
|
alt: authorName,
|
|
1426
|
-
onClick: handleClick,
|
|
865
|
+
onClick: isAssistantRole ? undefined : handleClick,
|
|
1427
866
|
onError: e => {
|
|
1428
867
|
e.currentTarget.src = '/default-avatar.svg';
|
|
1429
868
|
}
|
|
@@ -1431,20 +870,20 @@ const ModernMessageBubble = ({
|
|
|
1431
870
|
}
|
|
1432
871
|
// For other messages (left-aligned with full formatting)
|
|
1433
872
|
return React__default.createElement("div", {
|
|
1434
|
-
className: `group/message transition-all duration-200 hover:bg-gray-50 rounded-lg px-3 py-1 -mx-3 ${isSystemMessage ? '' : 'cursor-pointer'}`,
|
|
1435
|
-
onClick: isSystemMessage ? undefined : handleClick
|
|
873
|
+
className: `group/message transition-all duration-200 hover:bg-gray-50 rounded-lg px-3 py-1 -mx-3 ${isSystemMessage || isAssistantRole ? '' : 'cursor-pointer'}`,
|
|
874
|
+
onClick: isSystemMessage || isAssistantRole ? undefined : handleClick
|
|
1436
875
|
}, React__default.createElement("div", {
|
|
1437
876
|
className: "flex items-start justify-between gap-3"
|
|
1438
877
|
}, React__default.createElement("div", {
|
|
1439
878
|
className: "flex-1 min-w-0"
|
|
1440
879
|
}, message.message && React__default.createElement("div", {
|
|
1441
|
-
className: `
|
|
880
|
+
className: `max-w-none ${isSystemMessage ? 'text-gray-800' : 'text-gray-900'}`,
|
|
1442
881
|
dir: detectTextDirection(message?.message || ''),
|
|
1443
882
|
lang: detectLanguageTag(message?.message || '')
|
|
1444
883
|
}, message.message.includes('```') ? React__default.createElement(FormattedMessageContent, {
|
|
1445
884
|
content: message.message
|
|
1446
885
|
}) : isProbablyHTML(message.message) ? React__default.createElement("div", {
|
|
1447
|
-
className: "
|
|
886
|
+
className: "max-w-none text-gray-800 html-content",
|
|
1448
887
|
dangerouslySetInnerHTML: {
|
|
1449
888
|
__html: prettifyHtmlContent(sanitizeHtml(message.message))
|
|
1450
889
|
}
|
|
@@ -1499,7 +938,11 @@ const ModernMessageGroupComponent = ({
|
|
|
1499
938
|
onOpen,
|
|
1500
939
|
onMessageClick,
|
|
1501
940
|
isDesktopView = false,
|
|
1502
|
-
isSmallScreen = false
|
|
941
|
+
isSmallScreen = false,
|
|
942
|
+
sandboxErrors = [],
|
|
943
|
+
currentFiles = {},
|
|
944
|
+
onFixError,
|
|
945
|
+
onRecreateSandbox
|
|
1503
946
|
}) => {
|
|
1504
947
|
// Inject CSS styles for HTML content
|
|
1505
948
|
useInjectStyles();
|
|
@@ -1521,5 +964,13 @@ const ModernMessageGroupComponent = ({
|
|
|
1521
964
|
isDesktopView: isDesktopView,
|
|
1522
965
|
isSmallScreen: isSmallScreen
|
|
1523
966
|
});
|
|
1524
|
-
})
|
|
967
|
+
}), sandboxErrors?.map(error => React__default.createElement("div", {
|
|
968
|
+
key: error.id,
|
|
969
|
+
className: "px-2"
|
|
970
|
+
}, React__default.createElement(ErrorFixCard, {
|
|
971
|
+
error: error,
|
|
972
|
+
onFixError: onFixError || (() => Promise.resolve()),
|
|
973
|
+
currentFiles: currentFiles,
|
|
974
|
+
isFixing: false
|
|
975
|
+
}))));
|
|
1525
976
|
};export{ModernMessageGroupComponent,groupMessagesByUserAndTime};//# sourceMappingURL=ModernMessageGroup.js.map
|