@@ -26,12 +26,12 @@ import {
2626import {
2727 DBFolderAPI
2828} from 'api/plugin-api' ;
29- import { DatabaseSettings } from 'cdm/SettingsModel' ;
29+ import { DatabaseSettings , LocalSettings } from 'cdm/SettingsModel' ;
3030
3131import StateManager from 'StateManager' ;
3232import { around } from 'monkey-around' ;
3333import { LOGGER } from 'services/Logger' ;
34- import { DatabaseCore , DatabaseFrontmatterOptions , DEFAULT_SETTINGS } from 'helpers/Constants' ;
34+ import { DatabaseCore , DatabaseFrontmatterOptions , DEFAULT_SETTINGS , YAML_INDENT } from 'helpers/Constants' ;
3535import { PreviewDatabaseModeService } from 'services/MarkdownPostProcessorService' ;
3636
3737export default class DBFolderPlugin extends Plugin {
@@ -195,13 +195,13 @@ export default class DBFolderPlugin extends Plugin {
195195 this . app . fileManager as any
196196 ) . createNewMarkdownFile ( targetFolder , 'Untitled database' ) ;
197197
198- await this . app . vault . modify (
198+ await app . vault . modify (
199199 database ,
200200 DatabaseFrontmatterOptions . BASIC
201201 . concat ( '\n' )
202202 . concat ( this . defaultConfiguration ( ) )
203203 ) ;
204- await this . app . workspace . activeLeaf . setViewState ( {
204+ await app . workspace . getMostRecentLeaf ( ) . setViewState ( {
205205 type : DatabaseCore . FRONTMATTER_KEY ,
206206 state : { file : database . path } ,
207207 } ) ;
@@ -215,20 +215,16 @@ export default class DBFolderPlugin extends Plugin {
215215 */
216216 defaultConfiguration ( ) : string {
217217 const local_settings = this . settings . local_settings ;
218- return [
219- `config:` ,
220- ` enable_show_state: ${ local_settings . enable_show_state } ` ,
221- ` group_folder_column: ` ,
222- ` remove_field_when_delete_column: ${ local_settings . remove_field_when_delete_column } ` ,
223- ` cell_size: ${ local_settings . cell_size } ` ,
224- ` sticky_first_column: ${ local_settings . sticky_first_column } ` ,
225- ` show_metadata_created: ${ local_settings . show_metadata_created } ` ,
226- ` show_metadata_modified: ${ local_settings . show_metadata_modified } ` ,
227- ` source_data: ${ local_settings . source_data } ` ,
228- ` source_form_result: ${ local_settings . source_form_result } ` ,
229- `%%>`
230- ] . join ( '\n' ) ;
218+ const defaultConfig = [ ] ;
219+ defaultConfig . push ( "config:" ) ;
220+ Object . entries ( DEFAULT_SETTINGS . local_settings ) . forEach ( ( [ key , value ] ) => {
221+ const defaultValue = local_settings [ key as keyof LocalSettings ] !== undefined ? local_settings [ key as keyof LocalSettings ] : value ;
222+ defaultConfig . push ( `${ YAML_INDENT } ${ key } : ${ defaultValue } ` ) ;
223+ } ) ;
224+ defaultConfig . push ( "%%>" ) ;
225+ return defaultConfig . join ( '\n' ) ;
231226 }
227+
232228 registerEvents ( ) {
233229 this . registerEvent (
234230 this . app . workspace . on ( 'file-menu' , ( menu , file : TFile ) => {
@@ -253,7 +249,7 @@ export default class DBFolderPlugin extends Plugin {
253249 this . registerMarkdownPostProcessor ( previewMode . markdownPostProcessor ) ;
254250
255251 // internal-link quick preview
256- this . registerEvent ( this . app . workspace . on ( "quick-preview" , previewMode . hoverEvent ) ) ;
252+ this . registerEvent ( app . workspace . on ( "quick-preview" , previewMode . hoverEvent ) ) ;
257253
258254 //monitoring for div.popover.hover-popover.file-embed.is-loaded to be added to the DOM tree
259255 // this.observer = observer;
@@ -268,10 +264,10 @@ export default class DBFolderPlugin extends Plugin {
268264
269265 this . app . workspace . onLayoutReady ( ( ) => {
270266 this . register (
271- around ( ( this . app as any ) . commands , {
267+ around ( ( app as any ) . commands , {
272268 executeCommandById ( next ) {
273269 return function ( command : string ) {
274- const view = self . app . workspace . getActiveViewOfType ( DatabaseView ) ;
270+ const view = app . workspace . getActiveViewOfType ( DatabaseView ) ;
275271
276272 if ( view ) {
277273 //view.emitter.emit('hotkey', command);
@@ -337,7 +333,7 @@ export default class DBFolderPlugin extends Plugin {
337333 // Add a menu item to go back to database view
338334 this . register (
339335 around ( MarkdownView . prototype , {
340- onMoreOptionsMenu ( next ) {
336+ onPaneMenu ( next ) {
341337 return function ( menu : Menu ) {
342338 const file = this . file ;
343339 const cache = file
0 commit comments