@turbox3d/command-manager
Version:
Large-scale productivity application command management library
61 lines • 1.63 kB
JavaScript
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import { create } from './create';
import { compose } from './compose';
import { manager } from './manager';
import { install } from './install';
export var CommandManager = /*#__PURE__*/function () {
function CommandManager() {
_classCallCheck(this, CommandManager);
}
return _createClass(CommandManager, [{
key: "installed",
value: function installed() {
//
}
}, {
key: "toggleCommand",
value: function toggleCommand(command) {
this.activeCommand = command;
}
}, {
key: "clearCommand",
value: function clearCommand() {
this.activeCommand = undefined;
}
/**
* 判断当前激活的 Command 是否为入参 command
* @param command
*/
}, {
key: "isCommandActive",
value: function isCommandActive(command) {
return this.activeCommand === command;
}
}, {
key: "distributeEvent",
value: function distributeEvent(eventType, ev, event, tools) {
if (this.activeCommand) {
this.activeCommand.distributeEvent(eventType, ev, event, tools);
}
}
}]);
}();
/**
* 构建一个 Command 基类
*
* 范型类型为激活时的函数参数
*/
CommandManager.create = create;
/**
* 构建一个组合了其他 Command 的结构(本质依然是一个 Command)
*/
CommandManager.compose = compose;
/**
* 构建一个 CommandManager 基类
*/
CommandManager.manager = manager;
/**
* 安装声明一系列指令集
*/
CommandManager.install = install;