@@ -12,7 +12,7 @@ import { ActionType } from "react-table";
1212import { VaultManagerDB } from "services/FileManagerService" ;
1313import { moveFile , updateRowFile } from "helpers/VaultManagement" ;
1414import { randomColor } from "helpers/Colors" ;
15- import { DatabaseColumn } from "cdm/DatabaseModel" ;
15+ import { DatabaseColumn , RowDatabaseFields } from "cdm/DatabaseModel" ;
1616import NoteInfo from "services/NoteInfo" ;
1717import { dbTrim } from "helpers/StylesHelper" ;
1818import { parseFrontmatterFieldsToString } from "parsers/RowDatabaseFieldsToFile" ;
@@ -54,24 +54,33 @@ export function databaseReducer(state: TableDataType, action: ActionType) {
5454 */
5555 case ActionTypes . ADD_ROW :
5656 const filename = `${ state . view . file . parent . path } /${ action . filename } .md` ;
57- const rowRecord : Record < string , any > = { } ;
57+ const rowRecord : RowDatabaseFields = { inline : { } , frontmatter : { } } ;
5858 state . columns
5959 . filter ( ( column : TableColumn ) => ! column . isMetadata )
6060 . forEach ( ( column : TableColumn ) => {
61- rowRecord [ column . key ] = "" ;
61+ if ( column . isInline ) {
62+ rowRecord . inline [ column . key ] = "" ;
63+ } else {
64+ rowRecord . frontmatter [ column . key ] = "" ;
65+ }
6266 } ) ;
6367 // Add note to persist row
6468 VaultManagerDB . create_markdown_file (
6569 state . view . file . parent ,
6670 action . filename ,
67- parseFrontmatterFieldsToString ( rowRecord )
71+ rowRecord
6872 ) ;
6973
7074 const row : RowDataType = {
71- ...rowRecord ,
75+ ...rowRecord . frontmatter ,
76+ ...rowRecord . inline ,
7277 id : state . data . length + 1 ,
7378 note : new NoteInfo (
74- { ...rowRecord , file : { path : filename } } ,
79+ {
80+ ...rowRecord . frontmatter ,
81+ ...rowRecord . inline ,
82+ file : { path : filename } ,
83+ } ,
7584 state . data . length + 1
7685 ) ,
7786 [ MetadataColumns . FILE ] : `[[${ filename } |${ action . filename } ]]` ,
@@ -408,7 +417,7 @@ export function databaseReducer(state: TableDataType, action: ActionType) {
408417 return update ( state , { skipReset : { $set : false } } ) ;
409418
410419 case ActionTypes . TOGGLE_INLINE_FRONTMATTER :
411- // Update configuration & row files on disk
420+ // Altern between inline & frontmatter mode
412421 state . view . diskConfig . updateColumnProperties ( action . columnId , {
413422 isInline : action . isInline ,
414423 } ) ;
0 commit comments