@tmagic/editor 1.3.0-alpha.6 → 1.3.0-alpha.7

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.
@@ -1,11 +1,19 @@
1
+ import { KeyBindingItem } from '../type';
1
2
  import BaseService from './BaseService';
2
3
  declare class Keybinding extends BaseService {
3
- private keycon;
4
- private ctrlKey;
5
- constructor();
4
+ ctrlKey: string;
5
+ private controllers;
6
+ private bindingList;
7
+ private commands;
8
+ registeCommand(command: string, handler: (e: KeyboardEvent) => void | Promise<void>): void;
9
+ unregisteCommand(command: string): void;
10
+ registeEl(name: string, el?: HTMLElement): void;
11
+ unregisteEl(name: string): void;
12
+ registe(maps: KeyBindingItem[]): void;
13
+ reset(): void;
6
14
  destroy(): void;
7
- private isDisabledKeyEvent;
8
- private removeNode;
15
+ private bind;
16
+ private getKeyconKeys;
9
17
  }
10
18
  export type KeybindingService = Keybinding;
11
19
  declare const _default: Keybinding;
package/types/type.d.ts CHANGED
@@ -18,6 +18,7 @@ import type { UndoRedo } from './utils/undo-redo';
18
18
  export type BeforeAdd = (config: MNode, parent: MContainer) => Promise<MNode> | MNode;
19
19
  export type GetConfig = (config: FormConfig) => Promise<FormConfig> | FormConfig;
20
20
  export interface InstallOptions {
21
+ parseDSL: (dsl: string) => MApp;
21
22
  [key: string]: any;
22
23
  }
23
24
  export interface Services {
@@ -346,3 +347,55 @@ export interface EventSelectConfig {
346
347
  /** 联动代码配置 */
347
348
  codeActionConfig?: FormItem;
348
349
  }
350
+ export declare enum KeyBindingCommand {
351
+ /** 复制 */
352
+ COPY_NODE = "tmagic-system-copy-node",
353
+ /** 粘贴 */
354
+ PASTE_NODE = "tmagic-system-paste-node",
355
+ /** 删除 */
356
+ DELETE_NODE = "tmagic-system-delete-node",
357
+ /** 剪切 */
358
+ CUT_NODE = "tmagic-system-cut-node",
359
+ /** 撤销 */
360
+ UNDO = "tmagic-system-undo",
361
+ /** 重做 */
362
+ REDO = "tmagic-system-redo",
363
+ /** 放大 */
364
+ ZOOM_IN = "tmagic-system-zoom-in",
365
+ /** 缩小 */
366
+ ZOOM_OUT = "tmagic-system-zoom-out",
367
+ /** 缩放到实际大小 */
368
+ ZOOM_RESET = "tmagic-system-zoom-reset",
369
+ /** 缩放以适应 */
370
+ ZOOM_FIT = "tmagic-system-zoom-fit",
371
+ /** 向上移动1px */
372
+ MOVE_UP_1 = "tmagic-system-move-up-1",
373
+ /** 向下移动1px */
374
+ MOVE_DOWN_1 = "tmagic-system-move-down-1",
375
+ /** 向左移动1px */
376
+ MOVE_LEFT_1 = "tmagic-system-move-left-1",
377
+ /** 向右移动1px */
378
+ MOVE_RIGHT_1 = "tmagic-system-move-right-1",
379
+ /** 向上移动10px */
380
+ MOVE_UP_10 = "tmagic-system-move-up-10",
381
+ /** 向下移动10px */
382
+ MOVE_DOWN_10 = "tmagic-system-move-down-10",
383
+ /** 向左移动10px */
384
+ MOVE_LEFT_10 = "tmagic-system-move-left-10",
385
+ /** 向右移动10px */
386
+ MOVE_RIGHT_10 = "tmagic-system-move-right-10",
387
+ /** 切换组件 */
388
+ SWITCH_NODE = "tmagic-system-switch-node"
389
+ }
390
+ export interface KeyBindingItem {
391
+ command: KeyBindingCommand | string;
392
+ keybinding?: string | string[];
393
+ when: [string, 'keyup' | 'keydown'][];
394
+ }
395
+ export interface KeyBindingCacheItem {
396
+ type: string;
397
+ command: KeyBindingCommand | string;
398
+ keybinding?: string | string[];
399
+ eventType: 'keyup' | 'keydown';
400
+ binded: boolean;
401
+ }
@@ -1,4 +1,4 @@
1
1
  import { InstallOptions } from '../type';
2
2
  declare const setConfig: (option: InstallOptions) => void;
3
- declare const getConfig: (key: keyof InstallOptions) => unknown;
3
+ declare const getConfig: <K extends keyof InstallOptions>(key: K) => InstallOptions[K];
4
4
  export { getConfig, setConfig };
@@ -0,0 +1,3 @@
1
+ import { KeyBindingItem } from '../type';
2
+ declare const _default: KeyBindingItem[];
3
+ export default _default;