Spaces:
Sleeping
Sleeping
Update web/src/components/Message.tsx
Browse files- 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 |
-
|
| 199 |
-
|
| 200 |
-
<p className="whitespace-pre-wrap break-words" {...props}>
|
| 201 |
{children}
|
| 202 |
</p>
|
| 203 |
),
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
ul: ({ children
|
| 207 |
-
<ul className="my-
|
| 208 |
{children}
|
| 209 |
</ul>
|
| 210 |
),
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
ol: ({ children
|
| 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
|
| 223 |
-
const
|
| 224 |
-
|
| 225 |
-
//
|
| 226 |
-
if (
|
| 227 |
-
const first = firstTextish(children);
|
| 228 |
-
const emoji = startsWithEmojiBullet(first);
|
| 229 |
-
|
| 230 |
return (
|
| 231 |
-
<li className="list-none"
|
| 232 |
-
<div className="flex gap-2">
|
| 233 |
-
{
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
<div className="min-w-0">
|
|
|
|
|
|
|
| 237 |
</div>
|
| 238 |
</li>
|
| 239 |
);
|
| 240 |
}
|
| 241 |
-
|
| 242 |
-
//
|
| 243 |
return (
|
| 244 |
-
<li className="pl-1
|
| 245 |
{children}
|
| 246 |
</li>
|
| 247 |
);
|
| 248 |
},
|
| 249 |
-
|
| 250 |
-
strong: ({ children
|
| 251 |
-
<strong className="font-semibold"
|
| 252 |
{children}
|
| 253 |
</strong>
|
| 254 |
),
|
| 255 |
-
|
| 256 |
-
em: ({ children
|
| 257 |
-
<em className="italic"
|
| 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}
|