Skip to content

Commit b2a8f5c

Browse files
checkpoint
1 parent ada149b commit b2a8f5c

File tree

2 files changed

+45
-69
lines changed

2 files changed

+45
-69
lines changed

typescript/src/renderer/components/blocks/TableBlockRenderer.tsx

Lines changed: 36 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -26,71 +26,45 @@ export const TableBlockRenderer: React.FC<TableBlockRendererProps> = ({
2626
className={`notion-selectable notion-table-block${className ? ` ${className}` : ""}`}
2727
data-block-id={block.id}
2828
>
29-
<div>
30-
<div>
31-
<div className="notion-scroller horizontal">
32-
<div className="notion-table-content">
33-
<table>
34-
<tbody>
35-
{block.children?.map((child: any, index: number) => {
36-
if (child?.type === "table_row") {
37-
const rowData = child.table_row;
38-
const isHeader =
39-
index === 0 && tableData?.has_column_header;
29+
<div className="notion-scroller horizontal">
30+
<div className="notion-table-content">
31+
<table>
32+
<tbody>
33+
{block.children?.map((child: any, index: number) => {
34+
if (child?.type === "table_row") {
35+
const rowData = child.table_row;
36+
const isHeader = index === 0 && tableData?.has_column_header;
4037

41-
return (
42-
<tr
43-
key={child.id || index}
44-
className="notion-table-row"
45-
data-block-id={child.id}
46-
>
47-
{rowData?.cells?.map(
48-
(cell: any, cellIndex: number) => {
49-
const CellTag = isHeader ? "th" : "td";
50-
return (
51-
<CellTag
52-
key={cellIndex}
53-
scope={isHeader ? "col" : undefined}
54-
>
55-
<div className="notion-table-cell">
56-
<div className="notion-table-cell-text notranslate">
57-
<RichTextRenderer richText={cell || []} />
58-
</div>
59-
</div>
60-
</CellTag>
61-
);
62-
}
63-
)}
64-
</tr>
65-
);
66-
}
67-
return null;
68-
})}
69-
</tbody>
70-
</table>
71-
</div>
72-
</div>
38+
return (
39+
<tr
40+
key={child.id || index}
41+
className="notion-table-row"
42+
data-block-id={child.id}
43+
>
44+
{rowData?.cells?.map((cell: any, cellIndex: number) => {
45+
const CellTag = isHeader ? "th" : "td";
46+
return (
47+
<CellTag
48+
key={cellIndex}
49+
scope={isHeader ? "col" : undefined}
50+
>
51+
<div className="notion-table-cell">
52+
<div className="notion-table-cell-text notranslate">
53+
<RichTextRenderer richText={cell || []} />
54+
</div>
55+
</div>
56+
</CellTag>
57+
);
58+
})}
59+
</tr>
60+
);
61+
}
62+
return null;
63+
})}
64+
</tbody>
65+
</table>
7366
</div>
7467
</div>
75-
76-
{/* Render other children blocks recursively (non-table-row blocks) */}
77-
{block.children && block.children.length > 0 && (
78-
<div
79-
className="notion-block-children"
80-
style={{ marginLeft: `${depth * 24}px` }}
81-
>
82-
{block.children
83-
.filter((child: any) => child?.type !== "table_row")
84-
.map((child: any, index: number) => (
85-
<BlockRenderer
86-
key={child.id || index}
87-
block={child}
88-
depth={depth + 1}
89-
components={components}
90-
/>
91-
))}
92-
</div>
93-
)}
9468
</div>
9569
);
9670
};

typescript/src/renderer/styles/table.css

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
.notion-scroller.horizontal {
99
overflow-x: auto;
10-
overflow-y: hidden;
1110
width: 100%;
1211
}
1312

@@ -21,16 +20,19 @@
2120
border-collapse: collapse;
2221
border-spacing: 0;
2322
table-layout: auto;
24-
min-width: 600px;
23+
min-width: max-content;
2524
}
2625

2726
.notion-table-row th,
2827
.notion-table-row td {
2928
border: 1px solid var(--jsondoc-border-medium);
3029
padding: 8px 12px;
3130
vertical-align: top;
32-
white-space: nowrap;
33-
min-width: 120px;
31+
white-space: normal;
32+
min-width: 80px;
33+
max-width: 200px;
34+
word-wrap: break-word;
35+
overflow-wrap: break-word;
3436
}
3537

3638
.notion-table-row th {
@@ -39,7 +41,7 @@
3941
}
4042

4143
.notion-table-cell-text {
42-
overflow: hidden;
43-
text-overflow: ellipsis;
44-
max-width: 300px;
44+
word-wrap: break-word;
45+
overflow-wrap: break-word;
46+
white-space: normal;
4547
}

0 commit comments

Comments
 (0)