1- import { RowDatabaseFields } from "cdm/DatabaseModel" ;
2- import { NoteContentAction , TableColumn } from "cdm/FolderModel" ;
1+ import { TableColumn } from "cdm/FolderModel" ;
32import { LocalSettings } from "cdm/SettingsModel" ;
4- import { FileContent } from "helpers/FileContent" ;
5- import { inline_regex_target_in_function_of , resolve_tfile } from "helpers/FileManagement" ;
6- import { Notice , parseYaml , TFile , TFolder } from "obsidian" ;
7- import { parseFrontmatterFieldsToString , parseInlineFieldsToString } from "parsers/RowDatabaseFieldsToFile" ;
3+ import { inline_regex_target_in_function_of } from "helpers/FileManagement" ;
4+ import { TFile } from "obsidian" ;
5+ import { parseFrontmatterFieldsToString } from "parsers/RowDatabaseFieldsToFile" ;
86import { LOGGER } from "services/Logger" ;
97import { DataviewService } from "services/DataviewService" ;
10- import { InputType , SourceDataTypes , UpdateRowOptions } from "helpers/Constants" ;
8+ import { InputType , UpdateRowOptions } from "helpers/Constants" ;
119import { Literal } from "obsidian-dataview" ;
1210import { VaultManagerDB } from "services/FileManagerService" ;
1311import { inlineRegexInFunctionOf } from "helpers/QueryHelper" ;
14- import { EditionError } from "errors/ErrorTypes" ;
12+ import { EditionError , showDBError } from "errors/ErrorTypes" ;
1513import { hasFrontmatter } from "helpers/VaultManagement" ;
1614import obtainRowDatabaseFields from "parsers/FileToRowDatabaseFields" ;
1715class EditEngine {
@@ -26,7 +24,7 @@ class EditEngine {
2624 */
2725 public async updateRowFileProxy ( file : TFile , columnId : string , newValue : Literal , columns : TableColumn [ ] , ddbbConfig : LocalSettings , option : string ) : Promise < void > {
2826 await this . updateRowFile ( file , columnId , newValue , columns , ddbbConfig , option ) . catch ( ( err ) => {
29- throw err ;
27+ showDBError ( EditionError . YamlRead , err ) ;
3028 } ) ;
3129 }
3230
@@ -84,7 +82,7 @@ class EditEngine {
8482 }
8583
8684 async function persistFrontmatter ( deletedColumn ?: string ) : Promise < void > {
87- const frontmatterGroupRegex = contentHasFrontmatter ? / ^ - - - [ \s \S ] + ?- - - \n / g : / ( ^ [ \s \S ] * $ ) / g;
85+ const frontmatterGroupRegex = contentHasFrontmatter ? / ^ - - - [ \s \S ] + ?- - - / g : / ( ^ [ \s \S ] * $ ) / g;
8886 const frontmatterFieldsText = parseFrontmatterFieldsToString ( rowFields , ddbbConfig , deletedColumn ) ;
8987 const noteObject = {
9088 action : 'replace' ,
@@ -138,7 +136,7 @@ class EditEngine {
138136 }
139137
140138 async function inlineAddColumn ( ) : Promise < void > {
141- const inlineAddRegex = contentHasFrontmatter ? new RegExp ( `(^---[\\s\\S]+?---\n )+([\\s\\S]*$)` , 'g' ) : new RegExp ( `(^[\\s\\S]*$)` , 'g' ) ;
139+ const inlineAddRegex = contentHasFrontmatter ? new RegExp ( `(^---[\\s\\S]+?---)+([\\s\\S]*$)` , 'g' ) : new RegExp ( `(^[\\s\\S]*$)` , 'g' ) ;
142140 const noteObject = {
143141 action : 'replace' ,
144142 file : file ,
@@ -168,23 +166,19 @@ class EditEngine {
168166 } ;
169167 await VaultManagerDB . editNoteContent ( noteObject ) ;
170168 }
171- try {
172- // Record of options
173- const updateOptions : Record < string , any > = { } ;
174- updateOptions [ UpdateRowOptions . COLUMN_VALUE ] = columnValue ;
175- updateOptions [ UpdateRowOptions . COLUMN_KEY ] = columnKey ;
176- updateOptions [ UpdateRowOptions . REMOVE_COLUMN ] = removeColumn ;
177- updateOptions [ UpdateRowOptions . INLINE_VALUE ] = inlineColumnEdit ;
178- // Execute action
179- if ( updateOptions [ option ] ) {
180- // Then execute the action
181- await updateOptions [ option ] ( ) ;
182- } else {
183- throw `Error: option ${ option } not supported yet` ;
184- }
185- } catch ( e ) {
186- LOGGER . error ( `${ EditionError . YamlRead } ` , e ) ;
187- new Notice ( `${ EditionError . YamlRead } : ${ e . message } ` , 6000 ) ;
169+
170+ // Record of options
171+ const updateOptions : Record < string , any > = { } ;
172+ updateOptions [ UpdateRowOptions . COLUMN_VALUE ] = columnValue ;
173+ updateOptions [ UpdateRowOptions . COLUMN_KEY ] = columnKey ;
174+ updateOptions [ UpdateRowOptions . REMOVE_COLUMN ] = removeColumn ;
175+ updateOptions [ UpdateRowOptions . INLINE_VALUE ] = inlineColumnEdit ;
176+ // Execute action
177+ if ( updateOptions [ option ] ) {
178+ // Then execute the action
179+ await updateOptions [ option ] ( ) ;
180+ } else {
181+ throw `Error: option ${ option } not supported yet` ;
188182 }
189183 LOGGER . info ( `<= updateRowFile.asociatedFilePathToCell: ${ file . path } | columnId: ${ columnId } | newValue: ${ newValue } | option: ${ option } ` ) ;
190184 }
0 commit comments