@zhongguo168a/yxeditor-common 0.0.72 → 0.0.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1134,6 +1134,23 @@ declare class MapUtil {
1134
1134
  }
1135
1135
  declare const maputil: MapUtil;
1136
1136
 
1137
+ interface CommandInfo {
1138
+ /**
1139
+ * 默认的
1140
+ */
1141
+ caller?: any;
1142
+ name: string;
1143
+ handler: Function;
1144
+ group?: string;
1145
+ global: boolean;
1146
+ }
1147
+ declare class CommandManager extends EventDispatcher {
1148
+ protected _infos: any[];
1149
+ register(info: CommandInfo): void;
1150
+ execute(name: string, ...args: any): any;
1151
+ removeGroup(group: string): void;
1152
+ }
1153
+
1137
1154
  declare enum ViewState {
1138
1155
  /**
1139
1156
  * 关闭
@@ -1199,6 +1216,7 @@ declare class RouteView extends EventDispatcher {
1199
1216
  */
1200
1217
  onStop(value: (ctx: this) => void): this;
1201
1218
  get reason(): LinkError;
1219
+ get cmdmgr(): CommandManager;
1202
1220
  node: Node;
1203
1221
  datas: MapObject;
1204
1222
  tags: MapObject;
@@ -1208,6 +1226,7 @@ declare class RouteView extends EventDispatcher {
1208
1226
  protected _controller: RouteController;
1209
1227
  protected _route: Route;
1210
1228
  protected _reason: LinkError;
1229
+ protected _cmdmgr: CommandManager;
1211
1230
  private _onOpen;
1212
1231
  private _onOpened;
1213
1232
  private _onClose;
package/dist/index.esm.js CHANGED
@@ -1237,7 +1237,7 @@ class MapUtil {
1237
1237
  if (data === undefined || data === null) {
1238
1238
  return dflt;
1239
1239
  }
1240
- return data;
1240
+ return convertutil.anyToBoolean(data);
1241
1241
  }
1242
1242
  /**
1243
1243
  * 转换成{}, 如果原值无效, 返回{}
@@ -3892,6 +3892,39 @@ class ViewRepo extends ViewDict {
3892
3892
  }
3893
3893
  const viewrepo = new ViewRepo();
3894
3894
 
3895
+ class CommandManager extends EventDispatcher {
3896
+ constructor() {
3897
+ super(...arguments);
3898
+ this._infos = [];
3899
+ }
3900
+ register(info) {
3901
+ this._infos[info.name] = info;
3902
+ if (info.global) {
3903
+ window[info.name] = info.handler;
3904
+ }
3905
+ }
3906
+ execute(name, ...args) {
3907
+ let info = this._infos[name];
3908
+ if (!info) {
3909
+ return;
3910
+ }
3911
+ let caller;
3912
+ if (!caller) {
3913
+ caller = info.caller;
3914
+ }
3915
+ return info.handler.call(caller, ...args);
3916
+ }
3917
+ removeGroup(group) {
3918
+ for (let key in this._infos) {
3919
+ let info = this._infos[key];
3920
+ if (info.group == group) {
3921
+ delete this._infos[key];
3922
+ }
3923
+ }
3924
+ }
3925
+ }
3926
+ new CommandManager();
3927
+
3895
3928
  var ViewState;
3896
3929
  (function (ViewState) {
3897
3930
  /**
@@ -3933,6 +3966,7 @@ class RouteView extends EventDispatcher {
3933
3966
  this.tags = new MapObject({});
3934
3967
  this.enableHistory = false;
3935
3968
  this.state = 0;
3969
+ this._cmdmgr = new CommandManager();
3936
3970
  this._onStop = (ctx) => {
3937
3971
  ctx.close();
3938
3972
  };
@@ -4139,6 +4173,9 @@ class RouteView extends EventDispatcher {
4139
4173
  get reason() {
4140
4174
  return this._reason;
4141
4175
  }
4176
+ get cmdmgr() {
4177
+ return this._cmdmgr;
4178
+ }
4142
4179
  }
4143
4180
 
4144
4181
  class ViewHistory extends RouteList {