@@ -142,14 +142,22 @@ export abstract class API<Plugin extends IPlugin> {
142142 this . syntaxHighlighting = overrides ?. syntaxHighlighting ?? new SyntaxHighlightingAPI ( plugin ) ;
143143 }
144144
145+ /**
146+ * Creates a field of a given type.
147+ *
148+ * @param type
149+ * @param filePath
150+ * @param options
151+ * @param honorExcludedSetting
152+ */
145153 public createField < Type extends FieldType > (
146154 type : Type ,
147155 filePath : string ,
148156 options : FieldOptionMap [ Type ] ,
149157 honorExcludedSetting : boolean = true ,
150158 ) : FieldBase {
151159 if ( this . plugin . internal . isFilePathExcluded ( filePath ) && honorExcludedSetting ) {
152- return this . createExcludedBase ( filePath , undefined ) ;
160+ return this . createExcludedBase ( filePath ) ;
153161 }
154162
155163 if ( type === FieldType . INPUT_FIELD ) {
@@ -165,7 +173,7 @@ export abstract class API<Plugin extends IPlugin> {
165173 } else if ( type === FieldType . EMBED ) {
166174 return this . createEmbedBase ( filePath , options as FieldOptionMap [ FieldType . EMBED ] ) ;
167175 } else if ( type === FieldType . EXCLUDED ) {
168- return this . createExcludedBase ( filePath , options as FieldOptionMap [ FieldType . EXCLUDED ] ) ;
176+ return this . createExcludedBase ( filePath ) ;
169177 }
170178
171179 expectType < never > ( type ) ;
@@ -174,10 +182,21 @@ export abstract class API<Plugin extends IPlugin> {
174182 throw new Error ( `Unknown field type: ${ type } ` ) ;
175183 }
176184
185+ /**
186+ * Creates an inline field from a string.
187+ * Will throw an error if the string is not a valid declaration.
188+ *
189+ * @param fieldString
190+ * @param filePath
191+ * @param scope
192+ * @param renderChildType
193+ * @param honorExcludedSetting
194+ */
177195 public createInlineFieldFromString (
178- filePath : string ,
179196 fieldString : string ,
197+ filePath : string ,
180198 scope : BindTargetScope | undefined ,
199+ renderChildType : RenderChildType = RenderChildType . INLINE ,
181200 honorExcludedSetting : boolean = true ,
182201 ) : FieldBase {
183202 const fieldType = this . isInlineFieldDeclarationAndGetType ( fieldString ) ;
@@ -189,38 +208,57 @@ export abstract class API<Plugin extends IPlugin> {
189208 } ) ;
190209 }
191210
192- return this . createInlineFieldOfTypeFromString ( fieldType , filePath , fieldString , scope , honorExcludedSetting ) ;
211+ return this . createInlineFieldOfTypeFromString (
212+ fieldType ,
213+ fieldString ,
214+ filePath ,
215+ scope ,
216+ renderChildType ,
217+ honorExcludedSetting ,
218+ ) ;
193219 }
194220
221+ /**
222+ * Creates an inline field of a given type and string.
223+ * Will throw an error if the string is not a valid inline field type.
224+ *
225+ * @param type
226+ * @param filePath
227+ * @param declaration
228+ * @param scope
229+ * @param renderChildType
230+ * @param honorExcludedSetting
231+ */
195232 public createInlineFieldOfTypeFromString (
196233 type : InlineFieldType ,
234+ declaration : string ,
197235 filePath : string ,
198- fieldString : string ,
199236 scope : BindTargetScope | undefined ,
237+ renderChildType : RenderChildType = RenderChildType . INLINE ,
200238 honorExcludedSetting : boolean = true ,
201239 ) : FieldBase {
202240 if ( this . plugin . internal . isFilePathExcluded ( filePath ) && honorExcludedSetting ) {
203- return this . createExcludedBase ( filePath , undefined ) ;
241+ return this . createExcludedBase ( filePath ) ;
204242 }
205243
206244 if ( type === FieldType . INPUT_FIELD ) {
207245 return this . createInputFieldBase ( filePath , {
208- renderChildType : RenderChildType . INLINE ,
209- declaration : fieldString ,
246+ renderChildType : renderChildType ,
247+ declaration : declaration ,
210248 scope : scope ,
211249 } ) ;
212250 }
213251
214252 if ( type === FieldType . VIEW_FIELD ) {
215253 return this . createViewFieldBase ( filePath , {
216- renderChildType : RenderChildType . INLINE ,
217- declaration : fieldString ,
254+ renderChildType : renderChildType ,
255+ declaration : declaration ,
218256 scope : scope ,
219257 } ) ;
220258 }
221259
222260 if ( type === FieldType . INLINE_BUTTON ) {
223- return this . createInlineButtonBase ( filePath , { declaration : fieldString } ) ;
261+ return this . createInlineButtonBase ( filePath , { declaration : declaration } ) ;
224262 }
225263
226264 expectType < never > ( type ) ;
@@ -232,7 +270,7 @@ export abstract class API<Plugin extends IPlugin> {
232270 } ) ;
233271 }
234272
235- public createInputFieldBase ( filePath : string , options : FieldOptionMap [ FieldType . INPUT_FIELD ] ) : InputFieldBase {
273+ public createInputFieldBase ( filePath : string , options : InputFieldOptions ) : InputFieldBase {
236274 const uuid = getUUID ( ) ;
237275
238276 let declaration : InputFieldDeclaration ;
@@ -249,7 +287,7 @@ export abstract class API<Plugin extends IPlugin> {
249287 return new InputFieldBase ( this . plugin , uuid , filePath , options . renderChildType , declaration ) ;
250288 }
251289
252- public createViewFieldBase ( filePath : string , options : FieldOptionMap [ FieldType . VIEW_FIELD ] ) : ViewFieldBase {
290+ public createViewFieldBase ( filePath : string , options : ViewFieldOptions ) : ViewFieldBase {
253291 const uuid = getUUID ( ) ;
254292
255293 let declaration : ViewFieldDeclaration ;
@@ -266,7 +304,7 @@ export abstract class API<Plugin extends IPlugin> {
266304 return new ViewFieldBase ( this . plugin , uuid , filePath , options . renderChildType , declaration ) ;
267305 }
268306
269- public createJsViewFieldBase ( filePath : string , options : FieldOptionMap [ FieldType . JS_VIEW_FIELD ] ) : JsViewField {
307+ public createJsViewFieldBase ( filePath : string , options : JsViewFieldOptions ) : JsViewField {
270308 const uuid = getUUID ( ) ;
271309
272310 let declaration : JsViewFieldDeclaration ;
@@ -279,10 +317,7 @@ export abstract class API<Plugin extends IPlugin> {
279317 return new JsViewField ( this . plugin , uuid , filePath , declaration ) ;
280318 }
281319
282- public createInlineButtonBase (
283- filePath : string ,
284- options : FieldOptionMap [ FieldType . INLINE_BUTTON ] ,
285- ) : InlineButtonBase {
320+ public createInlineButtonBase ( filePath : string , options : InlineButtonOptions ) : InlineButtonBase {
286321 const uuid = getUUID ( ) ;
287322
288323 let declaration : InlineButtonDeclaration ;
@@ -295,7 +330,7 @@ export abstract class API<Plugin extends IPlugin> {
295330 return new InlineButtonBase ( this . plugin , uuid , filePath , declaration ) ;
296331 }
297332
298- public createButtonBase ( filePath : string , options : FieldOptionMap [ FieldType . BUTTON ] ) : ButtonBase {
333+ public createButtonBase ( filePath : string , options : ButtonOptions ) : ButtonBase {
299334 const uuid = getUUID ( ) ;
300335
301336 let declaration : ButtonDeclaration ;
@@ -308,12 +343,12 @@ export abstract class API<Plugin extends IPlugin> {
308343 return new ButtonBase ( this . plugin , uuid , filePath , declaration , options . isPreview ) ;
309344 }
310345
311- public createEmbedBase ( filePath : string , options : FieldOptionMap [ FieldType . EMBED ] ) : EmbedBase {
346+ public createEmbedBase ( filePath : string , options : EmbedOptions ) : EmbedBase {
312347 const uuid = getUUID ( ) ;
313348 return new EmbedBase ( this . plugin , uuid , filePath , options . depth , options . content ) ;
314349 }
315350
316- public createExcludedBase ( filePath : string , _options : FieldOptionMap [ FieldType . EXCLUDED ] ) : ExcludedBase {
351+ public createExcludedBase ( filePath : string ) : ExcludedBase {
317352 const uuid = getUUID ( ) ;
318353 return new ExcludedBase ( this . plugin , uuid , filePath ) ;
319354 }
0 commit comments