From 1fbf4b96be49757cf759cc563847cff8d187f506 Mon Sep 17 00:00:00 2001 From: RinYato Date: Thu, 25 Jul 2024 19:22:18 +0700 Subject: [PATCH] feat: add export rows as json --- src/components/gui/query-result-table.tsx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/components/gui/query-result-table.tsx b/src/components/gui/query-result-table.tsx index be013858..19e9c7ba 100644 --- a/src/components/gui/query-result-table.tsx +++ b/src/components/gui/query-result-table.tsx @@ -9,6 +9,7 @@ import OptimizeTableState from "@/components/gui/table-optimized/OptimizeTableSt import { exportRowsToExcel, exportRowsToSqlInsert, + exportRowsToJson, } from "@/components/lib/export-helper"; import { KEY_BINDING } from "@/lib/key-matcher"; import { @@ -434,6 +435,20 @@ export default function ResultTable({ } }, }, + { + title: "Copy as Json", + onClick: () => { + const headers = state + .getHeaders() + .map((column) => column?.name ?? ""); + + if (state.getSelectedRowCount() > 0) { + window.navigator.clipboard.writeText( + exportRowsToJson(headers, state.getSelectedRowsArray()) + ); + } + }, + }, { title: "Copy as INSERT SQL", onClick: () => {