Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

MUL-8092: fix(views): even spacing above and below markdown tables (#9338)

Jiayuan Zhang1961464067b9
diff --git a/packages/views/editor/styles/prose.css b/packages/views/editor/styles/prose.css
index a33861bf26..7ccfc57915 100644
--- a/packages/views/editor/styles/prose.css
+++ b/packages/views/editor/styles/prose.css
@@ -393,10 +393,16 @@
}
/* Table frame (RichTableFrame): the outer box carries the margin, and its
- toolbar row takes the place of most of the top margin. The wrapper anchors
- the resize handles, so they scroll with the columns. */
+ toolbar sits inside the top margin, so the margin is never shorter than the
+ toolbar (h-6). The bottom margin matches it, keeping the space even. The
+ wrapper anchors the resize handles, so they scroll with the columns. */
.rich-text-editor .rich-table {
- margin: 0.25rem 0 1rem;
+ margin: 1.5rem 0;
+}
+
+.rich-text-editor > .rich-table:last-child,
+.rich-text-editor > .table-node:last-child > .rich-table {
+ margin-bottom: 0;
}
.rich-text-editor .rich-table .tableWrapper {
diff --git a/packages/views/rich-content/rich-table.tsx b/packages/views/rich-content/rich-table.tsx
index f93dfcc2a3..ce7d0c55f0 100644
--- a/packages/views/rich-content/rich-table.tsx
+++ b/packages/views/rich-content/rich-table.tsx
@@ -392,12 +392,13 @@ export function RichTableFrame({ model, getMarkdown, tableRef: onTable, children
"flex h-6 items-center justify-center gap-1 rounded-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring";
return (
- <div className="rich-table group/table" data-resized={resized ? "" : undefined}>
- {/* A row of its own above the table: over the table it would cover the
- last columns' headers and resize handles. */}
+ <div className="rich-table group/table relative" data-resized={resized ? "" : undefined}>
+ {/* Above the table, inside its top margin: over the table it would cover
+ the last columns' headers and resize handles, and in the flow it
+ would make the space above the table taller than the space below. */}
<div
{...chrome}
- className="rich-table-toolbar flex h-7 items-center justify-end gap-0.5 opacity-0 transition-opacity group-hover/table:opacity-100 focus-within:opacity-100 [@media(hover:none)]:opacity-100"
+ className="rich-table-toolbar absolute right-0 bottom-full flex h-6 items-center gap-0.5 opacity-0 transition-opacity group-hover/table:opacity-100 focus-within:opacity-100 [@media(hover:none)]:opacity-100"
>
{resized && (
<button type="button" onClick={resetWidths} className={cn(toolbarButton, "px-1.5 text-caption")}>