From 3d6a5088f4684f05f1fd9967683092c9189e06e2 Mon Sep 17 00:00:00 2001 From: lxk955 <164191365+lxk955@users.noreply.github.com> Date: Thu, 1 Oct 2026 23:49:29 +0800 Subject: [PATCH] feat(grid): support word wrap in cell detail and value editors --- apps/desktop/src/components/grid/DataGrid.vue | 1 + .../grid/DataGridCellDetailDialog.vue | 20 +- .../grid/DataGridCellDetailHeader.vue | 22 +- .../grid/DataGridMongoJsonPreview.vue | 1 + .../DataGridCellDetailWordWrap.spec.ts | 217 ++++++++++++++++++ .../__tests__/useDataGridCellDetail.spec.ts | 8 +- .../src/composables/useCellDetailEditor.ts | 8 +- .../src/composables/useDataGridCellDetail.ts | 1 + 8 files changed, 272 insertions(+), 6 deletions(-) create mode 100644 apps/desktop/src/components/grid/__tests__/DataGridCellDetailWordWrap.spec.ts diff --git a/apps/desktop/src/components/grid/DataGrid.vue b/apps/desktop/src/components/grid/DataGrid.vue index 49fed4b927..41270070ef 100644 --- a/apps/desktop/src/components/grid/DataGrid.vue +++ b/apps/desktop/src/components/grid/DataGrid.vue @@ -6480,6 +6480,7 @@ watch(valueEditorContainer, async (el) => { appPalette: editorAppPalette, fontSize: editorFontSize, fontFamily: detailEditorFontFamily, + lineWrapping: () => settingsStore.editorSettings.wordWrap, }); const editor = valueDetailEditor; await editor.create(el, detailEditValue.value, activeCellDetail.value?.type); diff --git a/apps/desktop/src/components/grid/DataGridCellDetailDialog.vue b/apps/desktop/src/components/grid/DataGridCellDetailDialog.vue index c223a43cb1..829dc87c18 100644 --- a/apps/desktop/src/components/grid/DataGridCellDetailDialog.vue +++ b/apps/desktop/src/components/grid/DataGridCellDetailDialog.vue @@ -2,7 +2,7 @@ import DataGridCellDetailTextPreview from "@/components/grid/DataGridCellDetailTextPreview.vue"; import DataGridValueTransform from "@/components/grid/DataGridValueTransform.vue"; import { computed, nextTick, ref, watch } from "vue"; -import { Code2, Copy, Download, Eye, FileUp, Info, Pencil } from "@lucide/vue"; +import { Code2, Copy, Download, Eye, FileUp, Info, Pencil, WrapText } from "@lucide/vue"; import { useI18n } from "vue-i18n"; import { Button } from "@/components/ui/button"; import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog"; @@ -46,9 +46,14 @@ let jsonPreviewEditor: UseCellDetailEditorReturn | null = null; const jsonFormatted = computed(() => settingsStore.editorSettings.cellDetailJsonFormatted); const jsonView = computed(() => jsonFormatted.value && !!props.detail?.formattedJson); +const wordWrapEnabled = computed(() => settingsStore.editorSettings.wordWrap); const binaryTextPreview = computed(() => (props.detail && isBlobCellColumnType(props.detail.type) ? binaryCellUtf8Text(props.detail.value, props.detail.type, props.databaseType) : null)); const presentedValuePreview = computed(() => (binaryTextPreview.value === null ? props.detail?.rawValuePreview : props.detail?.displayValuePreview) ?? ""); +function toggleWordWrap() { + settingsStore.updateEditorSettings({ wordWrap: !wordWrapEnabled.value }); +} + function toggleJsonFormatted() { settingsStore.updateEditorSettings({ cellDetailJsonFormatted: !jsonFormatted.value }); } @@ -98,6 +103,7 @@ watch(jsonPreviewContainer, async (element) => { appPalette: () => themePalette.value, fontSize: () => settingsStore.editorSettings.fontSize, fontFamily: () => settingsStore.editorSettings.tableFontFamily, + lineWrapping: () => settingsStore.editorSettings.wordWrap, }); await jsonPreviewEditor.create(element, props.detail?.formattedJson ?? "", "json"); } else if (!element && jsonPreviewEditor) { @@ -166,6 +172,18 @@ watch( {{ t("grid.formattedJson") }} + diff --git a/apps/desktop/src/components/grid/DataGridCellDetailHeader.vue b/apps/desktop/src/components/grid/DataGridCellDetailHeader.vue index cbd87f52fb..93f46eb1b0 100644 --- a/apps/desktop/src/components/grid/DataGridCellDetailHeader.vue +++ b/apps/desktop/src/components/grid/DataGridCellDetailHeader.vue @@ -1,8 +1,10 @@