Skip to content

Commit

Permalink
Merge pull request #1112 from swanson/swanson/invoke-action-pass-element
Browse files Browse the repository at this point in the history
Pass invoking element as event data
  • Loading branch information
Alberto Fernández-Capel authored Dec 14, 2023
2 parents bceee69 + e64d0d7 commit ca59588
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/trix/controllers/editor_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,8 @@ export default class EditorController extends Controller {
}
}

toolbarDidInvokeAction(actionName) {
return this.invokeAction(actionName)
toolbarDidInvokeAction(actionName, invokingElement) {
return this.invokeAction(actionName, invokingElement)
}

toolbarDidToggleAttribute(attributeName) {
Expand Down Expand Up @@ -448,9 +448,9 @@ export default class EditorController extends Controller {
}
}

invokeAction(actionName) {
invokeAction(actionName, invokingElement) {
if (this.actionIsExternal(actionName)) {
return this.notifyEditorElement("action-invoke", { actionName })
return this.notifyEditorElement("action-invoke", { actionName, invokingElement })
} else {
return this.actions[actionName]?.perform?.call(this)
}
Expand Down
2 changes: 1 addition & 1 deletion src/trix/controllers/toolbar_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default class ToolbarController extends BasicObject {
if (this.getDialog(actionName)) {
return this.toggleDialog(actionName)
} else {
return this.delegate?.toolbarDidInvokeAction(actionName)
return this.delegate?.toolbarDidInvokeAction(actionName, element)
}
}

Expand Down

0 comments on commit ca59588

Please sign in to comment.