Skip to content

Commit

Permalink
fix: fix markdownTable error in some case (#2590)
Browse files Browse the repository at this point in the history
Co-authored-by: pointhalo <[email protected]>
  • Loading branch information
DaiQiangReal and pointhalo authored Nov 29, 2024
1 parent 6de4a62 commit 5399569
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/semi-ui/markdownRender/components/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@ import { omit } from 'lodash';



const table = (props: PropsWithChildren<TableProps>)=>{
const table = (props: PropsWithChildren<TableProps>) => {

const { children } = props;
const toArray = value => Array.isArray(value) ? value : [value];
const columnsFiber = toArray(get(children[0], 'props.children.props.children'));
const dataFiber = toArray(get(children[1], 'props.children'));

const titles: string[] = columnsFiber.map(item=>item?.props?.children || "");
const titles: string[] = columnsFiber.map(item => item?.props?.children || "");
const tableDataSource: any[] = [];
for (let i = 0;i < dataFiber.length;i++) {
let item: Record<string, string> = {
key: String(i)
};
dataFiber[i]?.props.children.forEach((child, index)=>{
dataFiber[i]?.props.children?.forEach?.((child, index) => {
item[titles[index]] = child?.props?.children ?? "";
});
tableDataSource.push(item);
}


return <Table dataSource={tableDataSource} columns={titles.map(title=>{
return <Table dataSource={tableDataSource} columns={titles.map(title => {
return {
title,
dataIndex: title
Expand Down

0 comments on commit 5399569

Please sign in to comment.