Add BdContextMenu to the plugin API
This commit is contained in:
parent
73e4e83ced
commit
237899c91a
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue