UNPKG

mj-context-menu

Version:
31 lines 863 B
import { AbstractItem } from './abstract_item.js'; import * as MenuUtil from './menu_util.js'; export class Command extends AbstractItem { static fromJson(_factory, { content: content, action: action, id: id }, menu) { return new this(menu, content, action, id); } constructor(menu, content, command, id) { super(menu, 'command', content, id); this.command = command; } mousedown(event) { this.stop(event); } mouseup(event) { this.press(); this.stop(event); } executeAction() { try { this.command(MenuUtil.getActiveElement(this)); } catch (e) { MenuUtil.error(e, 'Illegal command callback.'); } MenuUtil.close(this); } toJson() { return { type: '' }; } } //# sourceMappingURL=item_command.js.map