Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

feat(Markdown): tables draw a line on every cell edge (#7576)

Sherry962800ceda89
diff --git a/.changeset/table-cell-boundaries.md b/.changeset/table-cell-boundaries.md
new file mode 100644
index 0000000000..3dbfe0c4ea
--- /dev/null
+++ b/.changeset/table-cell-boundaries.md
@@ -0,0 +1,8 @@
+---
+'@astryxdesign/core': patch
+'@astryxdesign/richtext': patch
+---
+
+[feat] Tables draw a line on every cell edge, not only between rows, on both `Markdown` and the RichText surfaces, and the grid closes at the table's rim. A reader following one row across never needed vertical lines, but someone editing a table has to aim at a cell and judge where a selection stops, and the empty 3×3 a toolbar insert produces was three horizontal rules with no sign it had three columns. The line is the same `--color-border` already used between rows, the rim merges with it into one rule rather than doubling at the edge, and both surfaces move together — the read and edit renderings match block for block, more closely than before.
+
+@potatowagon
diff --git a/packages/core/src/Markdown/Markdown.tsx b/packages/core/src/Markdown/Markdown.tsx
index e328394fc0..f8cbdc6f7f 100644
--- a/packages/core/src/Markdown/Markdown.tsx
+++ b/packages/core/src/Markdown/Markdown.tsx
@@ -405,6 +405,16 @@ const markdownTableCellStyles = stylex.create({
code: {
wordBreak: 'normal',
},
+ // The grid's outer edge. `dividers="grid"` draws the lines *between* cells
+ // and stops at the table's rim, so without this the top, bottom, and sides
+ // stay open and the grid reads as unfinished. On the table element, not the
+ // wrapper, so `border-collapse: collapse` merges it with the cell lines
+ // into one 1px rule rather than doubling up at the edge.
+ tableOuterEdge: {
+ borderWidth: borderVars['--border-width'],
+ borderStyle: 'solid',
+ borderColor: colorVars['--color-border'],
+ },
});
/**
@@ -1905,7 +1915,10 @@ function renderBlock(
),
)}
{...lineStamps}>
- <Table dividers="rows" textOverflow="wrap">
+ <Table
+ dividers="grid"
+ textOverflow="wrap"
+ xstyle={markdownTableCellStyles.tableOuterEdge}>
<TableHeader>
<TableRow>
{header?.children.map((h, i) => (
diff --git a/packages/richtext/src/editorTheme.ts b/packages/richtext/src/editorTheme.ts
index 227ea6706a..02af0b95f0 100644
--- a/packages/richtext/src/editorTheme.ts
+++ b/packages/richtext/src/editorTheme.ts
@@ -317,6 +317,13 @@ const editorTheme = stylex.create({
table: {
borderCollapse: 'collapse',
width: '100%',
+ // The grid's outer edge, matching core Markdown's table: the row and
+ // column lines stop at the table's rim, so without this the top, bottom,
+ // and sides stay open. `border-collapse: collapse` merges it with the
+ // cell lines into one 1px rule rather than doubling up at the edge.
+ borderWidth: borderVars['--border-width'],
+ borderStyle: 'solid',
+ borderColor: colorVars['--color-border'],
},
tableRow: {
borderBottomWidth: '1px',
@@ -335,6 +342,17 @@ const editorTheme = stylex.create({
textAlign: 'start',
verticalAlign: 'middle',
overflowWrap: 'break-word',
+ // A line on every cell edge, as core Markdown's table draws with
+ // `dividers="grid"`. The row lines come from `tableRow`; this is the
+ // column half. The last column draws none, so the rim is the `table`
+ // rule's own border rather than two lines stacked at the edge — the
+ // same rule core `TableCell` follows (`:last-child` → 0).
+ borderInlineEndWidth: {
+ default: borderVars['--border-width'],
+ ':last-child': 0,
+ },
+ borderInlineEndStyle: 'solid',
+ borderInlineEndColor: colorVars['--color-border'],
},
tableCellHeader: {
fontWeight: fontWeightVars['--font-weight-semibold'],