diff --git a/packages/core/src/config/ButtonConfig.ts b/packages/core/src/config/ButtonConfig.ts index 1f847b63..4b76a90d 100644 --- a/packages/core/src/config/ButtonConfig.ts +++ b/packages/core/src/config/ButtonConfig.ts @@ -202,6 +202,7 @@ export interface ButtonContext { position: LinePosition | undefined; isInGroup: boolean; isInline: boolean; + parentId?: String | undefined; } /** diff --git a/packages/core/src/fields/button/ButtonField.ts b/packages/core/src/fields/button/ButtonField.ts index 6618c885..6b97f3f5 100644 --- a/packages/core/src/fields/button/ButtonField.ts +++ b/packages/core/src/fields/button/ButtonField.ts @@ -76,7 +76,7 @@ export class ButtonField extends Mountable { await this.mb.buttonActionRunner.runButtonActions( this.config, this.filePath, - this.getContext(), + this.getContext(targetEl), ButtonClickContext.fromMouseEvent(event, ButtonClickType.LEFT), ); }, @@ -84,7 +84,7 @@ export class ButtonField extends Mountable { await this.mb.buttonActionRunner.runButtonActions( this.config, this.filePath, - this.getContext(), + this.getContext(targetEl), ButtonClickContext.fromMouseEvent(event, ButtonClickType.LEFT), ); }, @@ -92,11 +92,16 @@ export class ButtonField extends Mountable { }); } - public getContext(): ButtonContext { + public getContext(target: HTMLElement): ButtonContext { + let parent = target.parentElement; + if (parent && this.isInline) { + parent = parent.parentElement; + } return { position: this.position?.getPosition(), isInGroup: this.isInGroup, isInline: this.isInline, + parentId: parent ? parent.id : "", }; }