feat(removeButton) : add remove button from toolbar option (#4408)

This commit is contained in:
Ceciliadrc 2024-10-17 15:40:53 +02:00 committed by GitHub
parent e254e7bb3d
commit e8f9345b93
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 0 deletions

View File

@ -112,6 +112,17 @@ export default class ToolbarService extends PubSubService {
unsubscriptions.forEach(unsub => this._serviceSubscriptions.push(unsub));
}
/**
* Removes buttons from the toolbar.
* @param buttonId - The button to be removed.
*/
public removeButton(buttonId : string ){
if(this.state.buttons[buttonId]) delete this.state.buttons[buttonId]
this._broadcastEvent(this.EVENTS.TOOL_BAR_MODIFIED, {
...this.state,
});
}
/**
* Adds buttons to the toolbar.
* @param buttons - The buttons to be added.

View File

@ -27,6 +27,8 @@ The `ToolBarService` is a straightforward service designed to handle the toolbar
- `addButtons`: add the button definition to the service.
[See below for button definition](#button-definitions).
- `removeButton(key)` : remove a button from the toolbar.
- `setButtons`: sets the buttons defined in the service. It overrides all the
previous buttons