@@ -4,6 +4,10 @@ import { t } from "lang/helpers";
44import { RowDataType } from "cdm/FolderModel" ;
55import { CsvHeaders } from "cdm/ServicesModel" ;
66import { CsvParserService } from "services/csv/CsvParserService" ;
7+ import { ParseService } from "services/ParseService" ;
8+ import { InputType } from "helpers/Constants" ;
9+ import { CustomView } from "views/AbstractView" ;
10+ import { Literal } from "obsidian-dataview" ;
711
812const ExportCsvAction = ( actionProps : TableActionProps ) => {
913 const { table } = actionProps ;
@@ -22,7 +26,7 @@ const ExportCsvAction = (actionProps: TableActionProps) => {
2226 table . getRowModel ( ) . rows
2327 ) ;
2428
25- exportToCsv ( `${ view . diskConfig . yaml . name } .csv` , csvRows , csvHeaders ) ;
29+ exportToCsv ( `${ view . diskConfig . yaml . name } .csv` , csvRows , csvHeaders , view ) ;
2630 } ;
2731
2832 const handleCsvDownload = ( e : MouseEvent ) => {
@@ -52,7 +56,8 @@ const ExportCsvAction = (actionProps: TableActionProps) => {
5256export const exportToCsv = (
5357 filename : string ,
5458 rows : RowDataType [ ] ,
55- headers : CsvHeaders [ ]
59+ headers : CsvHeaders [ ] ,
60+ view : CustomView
5661) : void => {
5762 if ( ! rows || ! rows . length ) {
5863 return ;
@@ -72,12 +77,13 @@ export const exportToCsv = (
7277 . map ( ( k ) => {
7378 let cell = row [ k ] === null || row [ k ] === undefined ? "" : row [ k ] ;
7479
75- cell =
76- cell instanceof Date
77- ? cell . toLocaleString ( )
78- : cell . toString ( ) . replace ( / " / g, '""' ) ;
80+ cell = ParseService . parseLiteral (
81+ cell as Literal ,
82+ InputType . MARKDOWN ,
83+ view . diskConfig . yaml . config
84+ ) as string ;
7985
80- if ( cell . search ( / ( " | , | \n ) / g) >= 0 ) {
86+ if ( cell . toString ( ) . search ( / ( " | , | \n ) / g) >= 0 ) {
8187 cell = `"${ cell } "` ;
8288 }
8389 return cell ;
0 commit comments