Add BdContextMenu to the plugin API

This commit is contained in:
Samuel Elliott 2018-08-22 12:55:30 +01:00
parent 73e4e83ced
commit 237899c91a
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6
2 changed files with 21 additions and 2 deletions

View File

@ -10,7 +10,7 @@
import { EmoteModule } from 'builtin';
import { SettingsSet, SettingsCategory, Setting, SettingsScheme } from 'structs';
import { BdMenu, Modals, DOM, DOMObserver, Reflection, VueInjector, Toasts } from 'ui';
import { BdMenu, Modals, DOM, DOMObserver, Reflection, VueInjector, Toasts, BdContextMenu, DiscordContextMenu } from 'ui';
import * as CommonComponents from 'commoncomponents';
import { Utils, Filters, ClientLogger as Logger, ClientIPC, AsyncEventEmitter } from 'common';
import Settings from './settings';
@ -197,6 +197,25 @@ export default class PluginApi {
});
}
/**
* BdContextMenu
*/
showContextMenu(event, groups) {
BdContextMenu.show(event, groups);
this.activeMenu.menu = BdContextMenu.activeMenu.menu;
}
get activeMenu() {
return this._activeMenu || (this._activeMenu = { menu: null });
}
get BdContextMenu() {
return Object.defineProperty({
show: this.showContextMenu.bind(this)
}, 'activeMenu', {
get: () => this.activeMenu
});
}
/**
* CssUtils
*/

View File

@ -17,7 +17,7 @@ export class BdContextMenu {
/**
* Show a context menu
* @param {MouseEvent|Object} e MouseEvent or Object { x: 0, y: 0 }
* @param {Object[]} grops Groups of items to show in context menu
* @param {Object[]} groups Groups of items to show in context menu
*/
static show(e, groups) {
const x = e.x || e.clientX;