@@ -5,7 +5,7 @@ import { type FieldBase } from 'packages/core/src/fields/FieldBase';
55import { ButtonActionRunner } from 'packages/core/src/fields/button/ButtonActionRunner' ;
66import { ButtonBase } from 'packages/core/src/fields/button/ButtonBase' ;
77import { ButtonManager } from 'packages/core/src/fields/button/ButtonManager' ;
8- import { InlineButtonBase } from 'packages/core/src/fields/button/InlineButtonBase ' ;
8+ import { ButtonGroupBase } from 'packages/core/src/fields/button/ButtonGroupBase ' ;
99import { InputFieldBase } from 'packages/core/src/fields/inputFields/InputFieldBase' ;
1010import { InputFieldFactory } from 'packages/core/src/fields/inputFields/InputFieldFactory' ;
1111import { JsViewField } from 'packages/core/src/fields/viewFields/JsViewField' ;
@@ -32,9 +32,9 @@ import {
3232import { type ButtonConfig } from 'packages/core/src/config/ButtonConfig' ;
3333import {
3434 type ButtonDeclaration ,
35+ type ButtonGroupDeclaration ,
3536 ButtonParser ,
36- type InlineButtonDeclaration ,
37- type SimpleInlineButtonDeclaration ,
37+ type SimpleButtonGroupDeclaration ,
3838} from 'packages/core/src/parsers/ButtonParser' ;
3939import { JsViewFieldParser } from 'packages/core/src/parsers/viewFieldParser/JsViewFieldParser' ;
4040import { Signal } from 'packages/core/src/utils/Signal' ;
@@ -61,7 +61,7 @@ export enum FieldType {
6161 INPUT_FIELD = 'INPUT_FIELD' ,
6262 VIEW_FIELD = 'VIEW_FIELD' ,
6363 JS_VIEW_FIELD = 'JS_VIEW_FIELD' ,
64- INLINE_BUTTON = 'INLINE_BUTTON ' ,
64+ BUTTON_GROUP = 'BUTTON_GROUP ' ,
6565 BUTTON = 'BUTTON' ,
6666 EMBED = 'EMBED' ,
6767 EXCLUDED = 'EXCLUDED' ,
@@ -83,8 +83,10 @@ export interface JsViewFieldOptions {
8383 declaration : SimpleJsViewFieldDeclaration | string ;
8484}
8585
86- export interface InlineButtonOptions {
87- declaration : SimpleInlineButtonDeclaration | string ;
86+ export interface ButtonGroupOptions {
87+ renderChildType : RenderChildType ;
88+ declaration : SimpleButtonGroupDeclaration | string ;
89+ position ?: NotePosition | undefined ;
8890}
8991
9092export interface ButtonOptions {
@@ -107,16 +109,16 @@ export interface FieldOptionMap {
107109 [ FieldType . INPUT_FIELD ] : InputFieldOptions ;
108110 [ FieldType . VIEW_FIELD ] : ViewFieldOptions ;
109111 [ FieldType . JS_VIEW_FIELD ] : JsViewFieldOptions ;
110- [ FieldType . INLINE_BUTTON ] : InlineButtonOptions ;
112+ [ FieldType . BUTTON_GROUP ] : ButtonGroupOptions ;
111113 [ FieldType . BUTTON ] : ButtonOptions ;
112114 [ FieldType . EMBED ] : EmbedOptions ;
113115 [ FieldType . EXCLUDED ] : undefined ;
114116}
115117
116- export type InlineFieldType = FieldType . INPUT_FIELD | FieldType . VIEW_FIELD | FieldType . INLINE_BUTTON ;
118+ export type InlineFieldType = FieldType . INPUT_FIELD | FieldType . VIEW_FIELD | FieldType . BUTTON_GROUP ;
117119
118120export function isFieldTypeAllowedInline ( type : FieldType ) : type is InlineFieldType {
119- return type === FieldType . INPUT_FIELD || type === FieldType . VIEW_FIELD || type === FieldType . INLINE_BUTTON ;
121+ return type === FieldType . INPUT_FIELD || type === FieldType . VIEW_FIELD || type === FieldType . BUTTON_GROUP ;
120122}
121123
122124export interface APIFieldOverrides {
@@ -206,8 +208,8 @@ export abstract class API<Plugin extends IPlugin> {
206208 return this . createViewFieldBase ( filePath , options as FieldOptionMap [ FieldType . VIEW_FIELD ] ) ;
207209 } else if ( type === FieldType . JS_VIEW_FIELD ) {
208210 return this . createJsViewFieldBase ( filePath , options as FieldOptionMap [ FieldType . JS_VIEW_FIELD ] ) ;
209- } else if ( type === FieldType . INLINE_BUTTON ) {
210- return this . createInlineButtonBase ( filePath , options as FieldOptionMap [ FieldType . INLINE_BUTTON ] ) ;
211+ } else if ( type === FieldType . BUTTON_GROUP ) {
212+ return this . createButtonGroupBase ( filePath , options as FieldOptionMap [ FieldType . BUTTON_GROUP ] ) ;
211213 } else if ( type === FieldType . BUTTON ) {
212214 return this . createButtonBase ( filePath , options as FieldOptionMap [ FieldType . BUTTON ] ) ;
213215 } else if ( type === FieldType . EMBED ) {
@@ -230,13 +232,15 @@ export abstract class API<Plugin extends IPlugin> {
230232 * @param filePath
231233 * @param scope
232234 * @param renderChildType
235+ * @param position
233236 * @param honorExcludedSetting
234237 */
235238 public createInlineFieldFromString (
236239 fieldString : string ,
237240 filePath : string ,
238241 scope : BindTargetScope | undefined ,
239242 renderChildType : RenderChildType = RenderChildType . INLINE ,
243+ position ?: NotePosition | undefined ,
240244 honorExcludedSetting : boolean = true ,
241245 ) : FieldBase {
242246 validate (
@@ -271,6 +275,7 @@ export abstract class API<Plugin extends IPlugin> {
271275 filePath ,
272276 scope ,
273277 renderChildType ,
278+ position ,
274279 honorExcludedSetting ,
275280 ) ;
276281 }
@@ -284,6 +289,7 @@ export abstract class API<Plugin extends IPlugin> {
284289 * @param declaration
285290 * @param scope
286291 * @param renderChildType
292+ * @param position
287293 * @param honorExcludedSetting
288294 */
289295 public createInlineFieldOfTypeFromString (
@@ -292,6 +298,7 @@ export abstract class API<Plugin extends IPlugin> {
292298 filePath : string ,
293299 scope : BindTargetScope | undefined ,
294300 renderChildType : RenderChildType = RenderChildType . INLINE ,
301+ position ?: NotePosition | undefined ,
295302 honorExcludedSetting : boolean = true ,
296303 ) : FieldBase {
297304 validate (
@@ -333,8 +340,12 @@ export abstract class API<Plugin extends IPlugin> {
333340 } ) ;
334341 }
335342
336- if ( type === FieldType . INLINE_BUTTON ) {
337- return this . createInlineButtonBase ( filePath , { declaration : declaration } ) ;
343+ if ( type === FieldType . BUTTON_GROUP ) {
344+ return this . createButtonGroupBase ( filePath , {
345+ renderChildType : renderChildType ,
346+ declaration : declaration ,
347+ position : position ,
348+ } ) ;
338349 }
339350
340351 expectType < never > ( type ) ;
@@ -426,7 +437,7 @@ export abstract class API<Plugin extends IPlugin> {
426437 return new JsViewField ( this . plugin , uuid , filePath , declaration ) ;
427438 }
428439
429- public createInlineButtonBase ( filePath : string , options : InlineButtonOptions ) : InlineButtonBase {
440+ public createButtonGroupBase ( filePath : string , options : ButtonGroupOptions ) : ButtonGroupBase {
430441 validate (
431442 z . object ( {
432443 filePath : V_FilePath ,
@@ -440,14 +451,14 @@ export abstract class API<Plugin extends IPlugin> {
440451
441452 const uuid = getUUID ( ) ;
442453
443- let declaration : InlineButtonDeclaration ;
454+ let declaration : ButtonGroupDeclaration ;
444455 if ( typeof options . declaration === 'string' ) {
445- declaration = this . buttonParser . parseInlineString ( options . declaration ) ;
456+ declaration = this . buttonParser . fromGroupString ( options . declaration ) ;
446457 } else {
447- declaration = this . buttonParser . validateSimpleInlineDeclaration ( options . declaration ) ;
458+ declaration = this . buttonParser . validateGroup ( options . declaration ) ;
448459 }
449460
450- return new InlineButtonBase ( this . plugin , uuid , filePath , declaration ) ;
461+ return new ButtonGroupBase ( this . plugin , uuid , filePath , declaration , options . renderChildType , options . position ) ;
451462 }
452463
453464 public createButtonBase ( filePath : string , options : ButtonOptions ) : ButtonBase {
@@ -466,9 +477,9 @@ export abstract class API<Plugin extends IPlugin> {
466477
467478 let declaration : ButtonDeclaration ;
468479 if ( typeof options . declaration === 'string' ) {
469- declaration = this . buttonParser . parseButtonString ( options . declaration ) ;
480+ declaration = this . buttonParser . fromString ( options . declaration ) ;
470481 } else {
471- declaration = this . buttonParser . validateSimpleButtonConfig ( options . declaration ) ;
482+ declaration = this . buttonParser . validate ( options . declaration ) ;
472483 }
473484
474485 return new ButtonBase ( this . plugin , uuid , filePath , declaration , options . position , options . isPreview ) ;
@@ -523,7 +534,7 @@ export abstract class API<Plugin extends IPlugin> {
523534 return 'INPUT' ;
524535 } else if ( fieldType === FieldType . VIEW_FIELD ) {
525536 return 'VIEW' ;
526- } else if ( fieldType === FieldType . INLINE_BUTTON ) {
537+ } else if ( fieldType === FieldType . BUTTON_GROUP ) {
527538 return 'BUTTON' ;
528539 }
529540
@@ -678,6 +689,7 @@ export abstract class API<Plugin extends IPlugin> {
678689
679690 this . plugin . metadataManager . write ( value , bindTarget ) ;
680691 }
692+
681693 /**
682694 * Reads a property from meta binds metadata cache.
683695 * If the value is not present in the cache, it will check the underlying source. E.g. Obsidians metadata cache.
0 commit comments