11import { MarkdownRenderChild , TFile } from 'obsidian' ;
22import MetaBindPlugin from './main' ;
3- import { Logger } from './utils/Logger' ;
43import { AbstractInputField } from './inputFields/AbstractInputField' ;
54import { InputFieldFactory } from './inputFields/InputFieldFactory' ;
65import { InputFieldArgumentType , InputFieldDeclaration , InputFieldDeclarationParser } from './parsers/InputFieldDeclarationParser' ;
@@ -113,12 +112,14 @@ export class InputFieldMarkdownRenderChild extends MarkdownRenderChild {
113112 // use this interval to reduce writing operations
114113 async applyValueUpdateQueues ( ) : Promise < void > {
115114 if ( this . metadataValueUpdateQueue . length !== 0 ) {
115+ console . debug ( `meta-bind | applying to metadataUpdateQueue to field ${ this . uid } ` ) ;
116116 await this . applyMetadataValueUpdateQueue ( ) ;
117117 this . cleanUpUpdateQueues ( ) ;
118118 return ;
119119 }
120120
121121 if ( this . inputFieldValueUpdateQueue . length !== 0 ) {
122+ console . debug ( `meta-bind | applying to inputFieldValueUpdateQueue to field ${ this . uid } ` ) ;
122123 await this . applyInputFieldValueUpdateQueue ( ) ;
123124 this . cleanUpUpdateQueues ( ) ;
124125 return ;
@@ -158,7 +159,6 @@ export class InputFieldMarkdownRenderChild extends MarkdownRenderChild {
158159 value = this . inputField . getDefaultValue ( ) ;
159160 }
160161
161- Logger . logDebug ( `updating input field ${ this . uid } to` , value ) ;
162162 this . inputField . setValue ( value ) ;
163163 } else {
164164 throw new MetaBindInternalError ( `cannot apply inputFieldValueUpdateQueue to inputField ${ this . uid } , inputFieldValueUpdateQueue is empty` ) ;
@@ -172,19 +172,23 @@ export class InputFieldMarkdownRenderChild extends MarkdownRenderChild {
172172
173173 pushToMetadataValueUpdateQueue ( value : any ) : void {
174174 if ( this . inputFieldDeclaration ?. isBound ) {
175+ console . debug ( `meta-bind | pushed value ${ value } (typeof ${ typeof value } ) to metadataUpdateQueue on field ${ this . uid } ` ) ;
175176 this . metadataValueUpdateQueue . push ( value ) ;
176177 }
177178 }
178179
179180 pushToInputFieldValueUpdateQueue ( value : any ) : void {
180181 if ( ! this . inputField ?. isEqualValue ( value ) ) {
182+ console . debug ( `meta-bind | pushed value ${ value } (typeof ${ typeof value } ) to inputFieldValueUpdateQueue on field ${ this . uid } ` ) ;
181183 this . inputFieldValueUpdateQueue . push ( value ) ;
182184 }
183185 }
184186
185187 getInitialValue ( ) : any | undefined {
186188 if ( this . inputFieldDeclaration ?. isBound && this . bindTargetMetadataField ) {
187- return traverseObject ( this . bindTargetMetadataField , this . metaData ) ?? this . inputField ?. getDefaultValue ( ) ;
189+ const value = traverseObject ( this . bindTargetMetadataField , this . metaData ) ;
190+ console . debug ( `meta-bind | setting initial value to ${ value } (typeof ${ typeof value } ) for input field ${ this . uid } ` ) ;
191+ return value ?? this . inputField ?. getDefaultValue ( ) ;
188192 }
189193 }
190194
@@ -201,7 +205,7 @@ export class InputFieldMarkdownRenderChild extends MarkdownRenderChild {
201205 }
202206
203207 async onload ( ) : Promise < void > {
204- Logger . logDebug ( ' load', this ) ;
208+ console . debug ( 'meta-bind | load inputFieldMarkdownRenderChild ', this ) ;
205209
206210 this . metaData = await this . metaData ;
207211
@@ -241,13 +245,12 @@ export class InputFieldMarkdownRenderChild extends MarkdownRenderChild {
241245 }
242246
243247 onunload ( ) : void {
244- Logger . logDebug ( ' unload', this ) ;
248+ console . debug ( 'meta-bind | unload inputFieldMarkdownRenderChild ', this ) ;
245249
246250 this . plugin . unregisterInputFieldMarkdownRenderChild ( this ) ;
247251
248252 super . onunload ( ) ;
249253
250- //console.log('unload', this);
251254 window . clearInterval ( this . limitInterval ) ;
252255 }
253256}
0 commit comments