From 0fb2f1fddb69e142329f45594ef3c49feca0c72e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E4=B8=AB=E8=AE=B2=E6=A2=B5?= Date: Wed, 30 Sep 2026 15:01:36 +0800 Subject: [PATCH] feat(grid): render HTML in value conversion preview --- .../grid/DataGridValueTransform.vue | 4 +++ apps/desktop/src/i18n/locales/az.ts | 2 ++ apps/desktop/src/i18n/locales/en.ts | 2 ++ apps/desktop/src/i18n/locales/es.ts | 2 ++ apps/desktop/src/i18n/locales/it.ts | 2 ++ apps/desktop/src/i18n/locales/ja.ts | 2 ++ apps/desktop/src/i18n/locales/ko.ts | 2 ++ apps/desktop/src/i18n/locales/pt-BR.ts | 2 ++ apps/desktop/src/i18n/locales/ru.ts | 2 ++ apps/desktop/src/i18n/locales/tr.ts | 2 ++ apps/desktop/src/i18n/locales/zh-CN.ts | 2 ++ apps/desktop/src/i18n/locales/zh-TW.ts | 2 ++ .../src/lib/ai/richContent/aiHtmlPreview.ts | 33 +++---------------- .../desktop/src/lib/common/safeHtmlPreview.ts | 10 ++++++ .../src/lib/dataGrid/cellValueTransform.ts | 5 ++- packages/app-tests/cellValueTransform.test.ts | 5 +++ 16 files changed, 50 insertions(+), 29 deletions(-) create mode 100644 apps/desktop/src/lib/common/safeHtmlPreview.ts diff --git a/apps/desktop/src/components/grid/DataGridValueTransform.vue b/apps/desktop/src/components/grid/DataGridValueTransform.vue index 0c5f0ea472..a4b5650295 100644 --- a/apps/desktop/src/components/grid/DataGridValueTransform.vue +++ b/apps/desktop/src/components/grid/DataGridValueTransform.vue @@ -7,6 +7,7 @@ import { Button } from "@/components/ui/button"; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog"; import { CELL_TRANSFORM_KINDS, CELL_TRANSFORM_MAX_INPUT, CELL_TRANSFORM_MAX_OUTPUT, CELL_TRANSFORM_MAX_RADIX_DIGITS, transformCellValue, type CellTransformKind, type CellTransformResult } from "@/lib/dataGrid/cellValueTransform"; import { DataGridDateTimePatterns, getSupportedTimeZoneOptions } from "@/lib/dataGrid/columnFormatter"; +import { buildSafeHtmlPreview } from "@/lib/common/safeHtmlPreview"; const props = defineProps<{ source: string | null; @@ -81,6 +82,8 @@ function convert() { if (blockedReason.value || props.source === null) return; result.value = transformCellValue(props.source, { kind: kind.value, unit: unit.value, timezone: timezone.value, pattern: pattern.value, fromBase: fromBase.value, toBase: toBase.value }); } +const htmlPreviewDocument = computed(() => (kind.value === "html" && result.value?.ok ? buildSafeHtmlPreview(result.value.text) : "")); + async function copyResult() { if (!result.value?.ok) return; try { @@ -155,6 +158,7 @@ async function copyResult() { > +