|
@@ -2,13 +2,16 @@ import hotkeys from "hotkeys-js";
|
|
|
import { ModuleControl } from "queenjs";
|
|
|
import { EditorModule } from "../../module";
|
|
|
|
|
|
-type IHotKeyItem = { hotKey: string; action: (this: EditorModule, key:string) => void };
|
|
|
+type IHotKeyItem = {
|
|
|
+ hotKey: string;
|
|
|
+ action: (this: EditorModule, key: string) => void;
|
|
|
+};
|
|
|
|
|
|
export class HotKeyCtrl extends ModuleControl<EditorModule> {
|
|
|
// 热键配置
|
|
|
hotKeys = this.defineHotKeys([
|
|
|
- // 取消选中
|
|
|
- {
|
|
|
+ // 取消选中
|
|
|
+ {
|
|
|
hotKey: "esc",
|
|
|
action() {
|
|
|
this.actions.pickComp("");
|
|
@@ -24,20 +27,19 @@ export class HotKeyCtrl extends ModuleControl<EditorModule> {
|
|
|
// 删除当前组件
|
|
|
{
|
|
|
hotKey: "Backspace,del",
|
|
|
- action(key:string) {
|
|
|
+ action() {
|
|
|
this.actions.removeComp(this.store.currCompId);
|
|
|
},
|
|
|
},
|
|
|
|
|
|
{
|
|
|
hotKey: "q,w,a,s,d,e",
|
|
|
- action(key:string) {
|
|
|
+ action(key) {
|
|
|
// this.actions.removeComp(this.store.currCompId);
|
|
|
// console.log("image hot key down", key);
|
|
|
- this.actions.handleImageHotKey(key)
|
|
|
+ this.actions.handleImageHotKey(key);
|
|
|
},
|
|
|
},
|
|
|
-
|
|
|
]);
|
|
|
|
|
|
init() {
|
|
@@ -48,7 +50,7 @@ export class HotKeyCtrl extends ModuleControl<EditorModule> {
|
|
|
module.moduleName,
|
|
|
function (event, handler) {
|
|
|
event.preventDefault();
|
|
|
-
|
|
|
+
|
|
|
const hotAct = hotKeys.find((d) =>
|
|
|
d.hotKey.split(",").includes(handler.key)
|
|
|
);
|