diff --git a/web/src/components/TableEditorDialog.tsx b/web/src/components/TableEditorDialog.tsx index 4e05f2e23..630377245 100644 --- a/web/src/components/TableEditorDialog.tsx +++ b/web/src/components/TableEditorDialog.tsx @@ -1,6 +1,5 @@ import { ArrowDownIcon, ArrowUpDownIcon, ArrowUpIcon, PlusIcon, TrashIcon } from "lucide-react"; import React, { useCallback, useEffect, useRef, useState } from "react"; -import { cn } from "@/lib/utils"; import type { ColumnAlignment, TableData } from "@/utils/markdown-table"; import { createEmptyTable, serializeMarkdownTable } from "@/utils/markdown-table"; import { Button } from "./ui/button"; @@ -122,9 +121,7 @@ const TableEditorDialog = ({ open, onOpenChange, initialData, onConfirm }: Table const sortByColumn = (col: number) => { let newDir: "asc" | "desc" = "asc"; - if (sortState && sortState.col === col && sortState.dir === "asc") { - newDir = "desc"; - } + if (sortState && sortState.col === col && sortState.dir === "asc") newDir = "desc"; setSortState({ col, dir: newDir }); setRows((prev) => { const sorted = [...prev].sort((a, b) => { @@ -171,16 +168,12 @@ const TableEditorDialog = ({ open, onOpenChange, initialData, onConfirm }: Table inputRefs.current.get(`${row}:${col}`)?.focus(); }; - // ---- Confirm ---- - const handleConfirm = () => { const md = serializeMarkdownTable({ headers, rows, alignments }); onConfirm(md); onOpenChange(false); }; - // ---- Sort indicator ---- - const SortIndicator = ({ col }: { col: number }) => { if (sortState?.col === col) { return sortState.dir === "asc" ? : ; @@ -188,7 +181,6 @@ const TableEditorDialog = ({ open, onOpenChange, initialData, onConfirm }: Table return ; }; - // Total colSpan: row-number col + data cols + action col const totalColSpan = colCount + 2; return ( @@ -210,12 +202,12 @@ const TableEditorDialog = ({ open, onOpenChange, initialData, onConfirm }: Table {/* ============ STICKY HEADER ============ */} - {/* Mask row: solid background strip that hides content scrolling behind the header */} + {/* Mask row: solid background that hides content scrolling behind the header */} - {/* Actual header row */} + {/* Header row */} {/* Row-number spacer */} {rows.map((row, rowIdx) => ( - {/* ---- Insert-row zone (between row rowIdx-1 and rowIdx) ---- */} - {rowIdx > 0 && ( - - + {/* Row number โ€” with insert-row zone on top border */} + - - )} - - {/* ---- Actual data row ---- */} - - {/* Row number */} - @@ -348,10 +339,7 @@ const TableEditorDialog = ({ open, onOpenChange, initialData, onConfirm }: Table setInputRef(`${rowIdx}:${col}`, el)} style={{ fontFamily: MONO_FONT }} - className={cn( - "w-full px-2 py-1.5 text-sm bg-transparent border border-border focus:outline-none focus:ring-1 focus:ring-primary/40", - rowIdx === rowCount - 1 && "rounded-bl-md", - )} + className="w-full px-2 py-1.5 text-sm bg-transparent border border-border focus:outline-none focus:ring-1 focus:ring-primary/40" value={cell} onChange={(e) => updateCell(rowIdx, col, e.target.value)} onKeyDown={(e) => handleKeyDown(e, rowIdx, col)} @@ -359,14 +347,14 @@ const TableEditorDialog = ({ open, onOpenChange, initialData, onConfirm }: Table ))} - {/* Row delete button (end of row) */} + {/* Row delete button */}
@@ -228,14 +220,17 @@ const TableEditorDialog = ({ open, onOpenChange, initialData, onConfirm }: Table className="group/cins absolute -left-4 top-0 bottom-0 w-8 z-30 flex items-center justify-center cursor-pointer" onClick={() => insertColumnAt(col)} > - {/* Blue vertical highlight line */} -
+ {/* Blue vertical line through the entire table */} +
{/* + button */} @@ -245,8 +240,8 @@ const TableEditorDialog = ({ open, onOpenChange, initialData, onConfirm }: Table
)} - {/* Header cell content โ€” bg extends across input + action buttons */} -
+ {/* Header cell โ€” bg covers input + sort + delete */} +
setInputRef(`-1:${col}`, el)} style={{ fontFamily: MONO_FONT }} @@ -260,7 +255,7 @@ const TableEditorDialog = ({ open, onOpenChange, initialData, onConfirm }: Table
+
+ {rowIdx > 0 && (
insertRowAt(rowIdx)} > - {/* Blue horizontal highlight line */} -
- {/* + button */} + {/* Blue horizontal line extending across the full table */} +
+ {/* + button at intersection of row border and first-column border */} @@ -331,14 +329,7 @@ const TableEditorDialog = ({ open, onOpenChange, initialData, onConfirm }: Table Insert row
-
+ )} {rowIdx + 1} {rowCount > 1 && (
- - +