SarahXia0405 commited on
Commit
9cc33f2
·
verified ·
1 Parent(s): 2c01580

Update web/src/components/Message.tsx

Browse files
Files changed (1) hide show
  1. web/src/components/Message.tsx +33 -67
web/src/components/Message.tsx CHANGED
@@ -195,98 +195,64 @@ export function Message({
195
  remarkPlugins={[remarkGfm]}
196
  className={markdownClass}
197
  components={{
198
- // paragraphs: keep compact and preserve line breaks
199
- p: ({ children, ...props }) => (
200
- <p className="whitespace-pre-wrap break-words" {...props}>
201
  {children}
202
  </p>
203
  ),
204
-
205
- // unordered list: "product" bullet style (dot), but if emoji-leading, no dot
206
- ul: ({ children, ...props }) => (
207
- <ul className="my-2 space-y-2 pl-0" {...props}>
208
  {children}
209
  </ul>
210
  ),
211
-
212
- // ordered list: keep decimal marker but nicer spacing + prevent huge gaps
213
- ol: ({ children, ...props }) => (
214
- <ol
215
- className="my-2 space-y-4 pl-6 list-decimal marker:font-semibold marker:text-foreground/60"
216
- {...props}
217
- >
218
  {children}
219
  </ol>
220
  ),
221
-
222
- li: ({ children, node, ...props }) => {
223
- const parentTag = (node as any)?.parent?.tagName;
224
-
225
- // For UL: custom bullet layout
226
- if (parentTag === "ul") {
227
- const first = firstTextish(children);
228
- const emoji = startsWithEmojiBullet(first);
229
-
230
  return (
231
- <li className="list-none" {...props}>
232
- <div className="flex gap-2">
233
- {!emoji ? (
234
- <span className="mt-[0.62rem] h-1.5 w-1.5 rounded-full bg-foreground/40 flex-shrink-0" />
235
- ) : null}
236
- <div className="min-w-0">{children}</div>
 
 
237
  </div>
238
  </li>
239
  );
240
  }
241
-
242
- // For OL: keep marker, but tighten inner spacing
243
  return (
244
- <li className="pl-1 [&_p]:my-1" {...props}>
245
  {children}
246
  </li>
247
  );
248
  },
249
-
250
- strong: ({ children, ...props }) => (
251
- <strong className="font-semibold" {...props}>
252
  {children}
253
  </strong>
254
  ),
255
-
256
- em: ({ children, ...props }) => (
257
- <em className="italic" {...props}>
258
  {children}
259
  </em>
260
  ),
261
-
262
- code: ({ children, ...props }) => (
263
- <code
264
- className="px-1 py-0.5 rounded bg-black/5 dark:bg-white/10"
265
- {...props}
266
- >
267
- {children}
268
- </code>
269
- ),
270
-
271
- pre: ({ children, ...props }) => (
272
- <pre
273
- className="my-2 p-3 rounded-lg overflow-auto bg-black/5 dark:bg-white/10"
274
- {...props}
275
- >
276
- {children}
277
- </pre>
278
- ),
279
-
280
- a: ({ children, ...props }) => (
281
- <a
282
- className="underline underline-offset-2"
283
- target="_blank"
284
- rel="noreferrer"
285
- {...props}
286
- >
287
- {children}
288
- </a>
289
- ),
290
  }}
291
  >
292
  {normalizedMarkdown}
 
195
  remarkPlugins={[remarkGfm]}
196
  className={markdownClass}
197
  components={{
198
+ p: ({ children }) => (
199
+ <p className="my-2 whitespace-pre-wrap break-words">
 
200
  {children}
201
  </p>
202
  ),
203
+
204
+ /* ---------- Unordered list bullet) ---------- */
205
+ ul: ({ children }) => (
206
+ <ul className="my-3 pl-6 space-y-2">
207
  {children}
208
  </ul>
209
  ),
210
+
211
+ /* ---------- Ordered list (1. 2. 3.) ---------- */
212
+ ol: ({ children }) => (
213
+ <ol className="my-3 pl-6 space-y-4 list-decimal">
 
 
 
214
  {children}
215
  </ol>
216
  ),
217
+
218
+ li: ({ children, node }) => {
219
+ const parent = (node as any)?.parent?.tagName;
220
+
221
+ // —— unordered list: custom dot, aligned & clean
222
+ if (parent === "ul") {
 
 
 
223
  return (
224
+ <li className="list-none">
225
+ <div className="flex items-start gap-2">
226
+ {/* dot */}
227
+ <span className="mt-[0.6em] h-1.5 w-1.5 rounded-full bg-foreground/50 flex-shrink-0" />
228
+ {/* content */}
229
+ <div className="min-w-0">
230
+ {children}
231
+ </div>
232
  </div>
233
  </li>
234
  );
235
  }
236
+
237
+ // —— ordered list: tighten spacing, align text
238
  return (
239
+ <li className="pl-1">
240
  {children}
241
  </li>
242
  );
243
  },
244
+
245
+ strong: ({ children }) => (
246
+ <strong className="font-semibold">
247
  {children}
248
  </strong>
249
  ),
250
+
251
+ em: ({ children }) => (
252
+ <em className="italic">
253
  {children}
254
  </em>
255
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
256
  }}
257
  >
258
  {normalizedMarkdown}