diff --git a/apps/ai-game-creator-shell/src/components/ChatMarkdownMessage/index.tsx b/apps/ai-game-creator-shell/src/components/ChatMarkdownMessage/index.tsx
index f3efd6236..39926feee 100644
--- a/apps/ai-game-creator-shell/src/components/ChatMarkdownMessage/index.tsx
+++ b/apps/ai-game-creator-shell/src/components/ChatMarkdownMessage/index.tsx
@@ -45,18 +45,22 @@ class MarkdownErrorBoundary extends Component<
}
const ListDepthContext = createContext(0);
+const ListKindContext = createContext<'unordered' | 'ordered' | null>(null);
+const ListItemContext = createContext(false);
function MarkdownUnorderedList({ children }: { children?: ReactNode }) {
const depth = useContext(ListDepthContext);
return (
0 ? 'pl-4' : 'pl-0'
- }`}
- >
- {children}
-
+ 0 ? 'pl-4' : 'pl-0'
+ }`}
+ >
+ {children}
+
+
- {children}
-
+
+ {children}
+
+
+ {children} +
+ ); +} + +function MarkdownListItem({ children }: { children?: ReactNode }) { + const listKind = useContext(ListKindContext); + return ( +{children}
- ), + p: MarkdownParagraph, ul: MarkdownUnorderedList, ol: MarkdownOrderedList, - li: ({ children }) =>{children} diff --git a/apps/ai-game-creator-shell/tests/ChatMarkdownMessage.test.tsx b/apps/ai-game-creator-shell/tests/ChatMarkdownMessage.test.tsx index f3778c4ab..43f4a9bde 100644 --- a/apps/ai-game-creator-shell/tests/ChatMarkdownMessage.test.tsx +++ b/apps/ai-game-creator-shell/tests/ChatMarkdownMessage.test.tsx @@ -38,6 +38,21 @@ describe('ChatMarkdownMessage', () => { expect(lists[2]?.className).toContain('pl-4'); }); + it('有序列表不添加无序列表短横线,列表项段落与文本同行', () => { + const { container } = render( +, + ); + + const items = container.querySelectorAll('ol > li'); + expect(items[0]?.textContent?.trim()).toBe('第一件事'); + expect(items[1]?.textContent?.trim()).toContain('第二件事'); + expect(items[0]?.querySelector('p')?.className ?? '').toContain('inline'); + expect(items[0]?.textContent).not.toContain('-'); + }); + it('不会把 react-markdown 的 node 元数据泄漏到代码节点', () => { const { container } = render(