From 834b8d4e3b0ef909373e64f3c5b90d8f4f85a7ff Mon Sep 17 00:00:00 2001 From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com> Date: Wed, 4 Nov 2026 23:26:24 +0800 Subject: [PATCH] fix(database): keep line breaks when editing multi-line cells (#1311) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The inline cell editor is a single-line input that drops a value's line breaks on the first change, and it committed on every Enter; the Record view's fields had the same problem. Multi-line values now open in the multi-line editor, Shift+Enter opens it for any cell (from the grid or the inline editor) and Cmd/Ctrl+Enter applies it; CRLF values keep CRLF; the grid marks line breaks with a muted ↵; the Record view uses a text area for multi-line values. --- src/features/database/DataView.tsx | 36 +++++++++----- src/features/database/Database.module.css | 18 ++++++- src/features/database/Grid.test.tsx | 45 +++++++++++++++++ src/features/database/Grid.tsx | 60 +++++++++++++++++++---- src/features/database/cellPreview.ts | 3 ++ 5 files changed, 141 insertions(+), 21 deletions(-) diff --git a/src/features/database/DataView.tsx b/src/features/database/DataView.tsx index 11423947f..ec98a55e5 100644 --- a/src/features/database/DataView.tsx +++ b/src/features/database/DataView.tsx @@ -20,6 +20,7 @@ import { type LocalSort, } from "./resultView"; import { openDialog } from "./store"; +import { hasLineBreak } from "./cellPreview"; import styles from "./Database.module.css"; import { tx } from "@/platform/i18n"; @@ -346,17 +347,30 @@ function RecordField(props: { column: GridColumn; cell: Cell; editable: boolean; {c.name} {c.type && c.type !== "NULL" && {c.type}} - " : undefined} - onChange={(e) => setText(e.target.value)} - onBlur={commit} - onKeyDown={(e) => { - if (e.key === "Enter") commit(); - }} - /> + {hasLineBreak(props.cell ?? "") ? ( + // A single-line field would drop the line breaks on the first edit. +