Commit d47c7271 authored by JC Brand's avatar JC Brand

Document the button hooks

parent 824bf2ed
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
- #2275: Allow punctuation to immediately precede a mention - #2275: Allow punctuation to immediately precede a mention
- Bugfix: Connection protocol not updated based on XEP-0156 connection methods - Bugfix: Connection protocol not updated based on XEP-0156 connection methods
- Bugfix: `null` inserted by emoji picker and can't switch between skintones - Bugfix: `null` inserted by emoji picker and can't switch between skintones
- New hook: [getMessageActionButtons](https://conversejs.org/docs/html/api/-_converse.html#event:getMessageActionButtons)
- File structure reordering: All plugins are now in `./plugins` folders.
- New configuration setting: [show_tab_notifications](https://conversejs.org/docs/html/configuration.html#show-tab-notifications) - New configuration setting: [show_tab_notifications](https://conversejs.org/docs/html/configuration.html#show-tab-notifications)
### Breaking Changes ### Breaking Changes
......
...@@ -70,16 +70,16 @@ class MessageActions extends CustomElement { ...@@ -70,16 +70,16 @@ class MessageActions extends CustomElement {
* *Hook* which allows plugins to add more message action buttons * *Hook* which allows plugins to add more message action buttons
* @event _converse#getMessageActionButtons * @event _converse#getMessageActionButtons
* @example * @example
api.listen.on('getMessageActionButtons', (el, buttons) => { * api.listen.on('getMessageActionButtons', (el, buttons) => {
buttons.push({ * buttons.push({
'i18n_text': 'Foo', * 'i18n_text': 'Foo',
'handler': ev => alert('Foo!'), * 'handler': ev => alert('Foo!'),
'button_class': 'chat-msg__action-foo', * 'button_class': 'chat-msg__action-foo',
'icon_class': 'fa fa-check', * 'icon_class': 'fa fa-check',
'name': 'foo' * 'name': 'foo'
}); * });
return buttons; * return buttons;
}); * });
*/ */
return api.hook('getMessageActionButtons', this, buttons); return api.hook('getMessageActionButtons', this, buttons);
} }
......
...@@ -79,6 +79,13 @@ export class ChatToolbar extends CustomElement { ...@@ -79,6 +79,13 @@ export class ChatToolbar extends CustomElement {
/** /**
* *Hook* which allows plugins to add more buttons to a chat's toolbar * *Hook* which allows plugins to add more buttons to a chat's toolbar
* @event _converse#getToolbarButtons * @event _converse#getToolbarButtons
* @example
* api.listen.on('getToolbarButtons', (toolbar_el, buttons) {
* buttons.push(html`
* <button @click=${() => alert('Foo!')}>Foo</button>`
* );
* return buttons;
* }
*/ */
return _converse.api.hook('getToolbarButtons', this, buttons); return _converse.api.hook('getToolbarButtons', this, buttons);
} }
......
...@@ -333,6 +333,18 @@ export const ChatBoxView = View.extend({ ...@@ -333,6 +333,18 @@ export const ChatBoxView = View.extend({
/** /**
* *Hook* which allows plugins to add more buttons to a chat's heading. * *Hook* which allows plugins to add more buttons to a chat's heading.
* @event _converse#getHeadingButtons * @event _converse#getHeadingButtons
* @example
* api.listen.on('getHeadingButtons', (view, buttons) => {
* buttons.push({
* 'i18n_title': __('Foo'),
* 'i18n_text': __('Foo Bar'),
* 'handler': ev => alert('Foo!'),
* 'a_class': 'toggle-foo',
* 'icon_class': 'fa-foo',
* 'name': 'foo'
* });
* return buttons;
* });
*/ */
return _converse.api.hook('getHeadingButtons', this, buttons); return _converse.api.hook('getHeadingButtons', this, buttons);
}, },
......
...@@ -29,10 +29,10 @@ const modal_api = { ...@@ -29,10 +29,10 @@ const modal_api = {
* Will create a new instance of that class if an existing one isn't * Will create a new instance of that class if an existing one isn't
* found. * found.
* @param { Class } ModalClass * @param { Class } ModalClass
* @param { [Object] } properties - Optional properties that will be * @param { Object } [properties] - Optional properties that will be
* set on a newly created modal instance (if no pre-existing modal was * set on a newly created modal instance (if no pre-existing modal was
* found). * found).
* @param { [Event] } event - The DOM event that causes the modal to be shown. * @param { Event } [event] - The DOM event that causes the modal to be shown.
*/ */
show (ModalClass, properties, ev) { show (ModalClass, properties, ev) {
const modal = this.get(ModalClass.id) || this.create(ModalClass, properties); const modal = this.get(ModalClass.id) || this.create(ModalClass, properties);
...@@ -51,7 +51,7 @@ const modal_api = { ...@@ -51,7 +51,7 @@ const modal_api = {
/** /**
* Create a modal of the passed-in type. * Create a modal of the passed-in type.
* @param { Class } ModalClass * @param { Class } ModalClass
* @param { [Object] } properties - Optional properties that will be * @param { Object } [properties] - Optional properties that will be
* set on the modal instance. * set on the modal instance.
*/ */
create (ModalClass, properties) { create (ModalClass, properties) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment