mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-03-05 09:47:20 +00:00
fix: hotkey should be mounted
This commit is contained in:
parent
5d5af1db2c
commit
77fc3f2db2
@ -1018,7 +1018,7 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* TODO: replace non standard metas with standard ones.
|
||||||
*/
|
*/
|
||||||
getSuitablePlace(node: Node, ref: any): any {
|
getSuitablePlace(node: Node, ref: any): any {
|
||||||
const focusNode = this.document?.focusNode;
|
const focusNode = this.document?.focusNode;
|
||||||
|
|||||||
@ -368,7 +368,9 @@ export class Hotkey {
|
|||||||
|
|
||||||
private nextExpectedAction: boolean | string = false;
|
private nextExpectedAction: boolean | string = false;
|
||||||
|
|
||||||
constructor(readonly name: string = 'unknown') {}
|
constructor(readonly name: string = 'unknown') {
|
||||||
|
this.mount(window);
|
||||||
|
}
|
||||||
|
|
||||||
mount(window: Window) {
|
mount(window: Window) {
|
||||||
const { document } = window;
|
const { document } = window;
|
||||||
|
|||||||
@ -89,10 +89,14 @@ function getPrevForSelect(prev: any, head?: any, parent?: any): any {
|
|||||||
export const builtinHotkey = (ctx: ILowCodePluginContext) => {
|
export const builtinHotkey = (ctx: ILowCodePluginContext) => {
|
||||||
return {
|
return {
|
||||||
init() {
|
init() {
|
||||||
const { hotkey, project } = ctx;
|
const { hotkey, project, logger } = ctx;
|
||||||
// hotkey binding
|
// hotkey binding
|
||||||
hotkey.bind(['backspace', 'del'], (e: KeyboardEvent) => {
|
hotkey.bind(['backspace', 'del'], (e: KeyboardEvent, action) => {
|
||||||
if (isInLiveEditing()) return;
|
logger.info(`action ${action} is triggered`);
|
||||||
|
|
||||||
|
if (isInLiveEditing()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// TODO: use focus-tracker
|
// TODO: use focus-tracker
|
||||||
const doc = project.currentDocument;
|
const doc = project.currentDocument;
|
||||||
if (isFormEvent(e) || !doc) {
|
if (isFormEvent(e) || !doc) {
|
||||||
@ -111,9 +115,12 @@ export const builtinHotkey = (ctx: ILowCodePluginContext) => {
|
|||||||
sel.clear();
|
sel.clear();
|
||||||
});
|
});
|
||||||
|
|
||||||
hotkey.bind('escape', (e: KeyboardEvent) => {
|
hotkey.bind('escape', (e: KeyboardEvent, action) => {
|
||||||
|
logger.info(`action ${action} is triggered`);
|
||||||
// const currentFocus = focusing.current;
|
// const currentFocus = focusing.current;
|
||||||
if (isInLiveEditing()) return;
|
if (isInLiveEditing()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const sel = focusing.focusDesigner?.currentDocument?.selection;
|
const sel = focusing.focusDesigner?.currentDocument?.selection;
|
||||||
if (isFormEvent(e) || !sel) {
|
if (isFormEvent(e) || !sel) {
|
||||||
return;
|
return;
|
||||||
@ -126,7 +133,10 @@ export const builtinHotkey = (ctx: ILowCodePluginContext) => {
|
|||||||
|
|
||||||
// command + c copy command + x cut
|
// command + c copy command + x cut
|
||||||
hotkey.bind(['command+c', 'ctrl+c', 'command+x', 'ctrl+x'], (e, action) => {
|
hotkey.bind(['command+c', 'ctrl+c', 'command+x', 'ctrl+x'], (e, action) => {
|
||||||
if (isInLiveEditing()) return;
|
logger.info(`action ${action} is triggered`);
|
||||||
|
if (isInLiveEditing()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const doc = project.currentDocument;
|
const doc = project.currentDocument;
|
||||||
if (isFormEvent(e) || !doc) {
|
if (isFormEvent(e) || !doc) {
|
||||||
return;
|
return;
|
||||||
@ -161,7 +171,11 @@ export const builtinHotkey = (ctx: ILowCodePluginContext) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// command + v paste
|
// command + v paste
|
||||||
hotkey.bind(['command+v', 'ctrl+v'], (e) => {
|
hotkey.bind(['command+v', 'ctrl+v'], (e, action) => {
|
||||||
|
logger.info(`action ${action} is triggered`);
|
||||||
|
if (isInLiveEditing()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (isInLiveEditing()) return;
|
if (isInLiveEditing()) return;
|
||||||
// TODO
|
// TODO
|
||||||
const designer = focusing.focusDesigner;
|
const designer = focusing.focusDesigner;
|
||||||
@ -190,8 +204,11 @@ export const builtinHotkey = (ctx: ILowCodePluginContext) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// command + z undo
|
// command + z undo
|
||||||
hotkey.bind(['command+z', 'ctrl+z'], (e) => {
|
hotkey.bind(['command+z', 'ctrl+z'], (e, action) => {
|
||||||
if (isInLiveEditing()) return;
|
logger.info(`action ${action} is triggered`);
|
||||||
|
if (isInLiveEditing()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const history = project.currentDocument?.history;
|
const history = project.currentDocument?.history;
|
||||||
if (isFormEvent(e) || !history) {
|
if (isFormEvent(e) || !history) {
|
||||||
return;
|
return;
|
||||||
@ -205,8 +222,11 @@ export const builtinHotkey = (ctx: ILowCodePluginContext) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// command + shift + z redo
|
// command + shift + z redo
|
||||||
hotkey.bind(['command+y', 'ctrl+y', 'command+shift+z'], (e) => {
|
hotkey.bind(['command+y', 'ctrl+y', 'command+shift+z'], (e, action) => {
|
||||||
if (isInLiveEditing()) return;
|
logger.info(`action ${action} is triggered`);
|
||||||
|
if (isInLiveEditing()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const history = project.currentDocument?.history;
|
const history = project.currentDocument?.history;
|
||||||
if (isFormEvent(e) || !history) {
|
if (isFormEvent(e) || !history) {
|
||||||
return;
|
return;
|
||||||
@ -220,7 +240,10 @@ export const builtinHotkey = (ctx: ILowCodePluginContext) => {
|
|||||||
|
|
||||||
// sibling selection
|
// sibling selection
|
||||||
hotkey.bind(['left', 'right'], (e, action) => {
|
hotkey.bind(['left', 'right'], (e, action) => {
|
||||||
if (isInLiveEditing()) return;
|
logger.info(`action ${action} is triggered`);
|
||||||
|
if (isInLiveEditing()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const doc = project.currentDocument;
|
const doc = project.currentDocument;
|
||||||
if (isFormEvent(e) || !doc) {
|
if (isFormEvent(e) || !doc) {
|
||||||
return;
|
return;
|
||||||
@ -236,7 +259,10 @@ export const builtinHotkey = (ctx: ILowCodePluginContext) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
hotkey.bind(['up', 'down'], (e, action) => {
|
hotkey.bind(['up', 'down'], (e, action) => {
|
||||||
if (isInLiveEditing()) return;
|
logger.info(`action ${action} is triggered`);
|
||||||
|
if (isInLiveEditing()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const doc = project.currentDocument;
|
const doc = project.currentDocument;
|
||||||
if (isFormEvent(e) || !doc) {
|
if (isFormEvent(e) || !doc) {
|
||||||
return;
|
return;
|
||||||
@ -258,7 +284,10 @@ export const builtinHotkey = (ctx: ILowCodePluginContext) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
hotkey.bind(['option+left', 'option+right'], (e, action) => {
|
hotkey.bind(['option+left', 'option+right'], (e, action) => {
|
||||||
if (isInLiveEditing()) return;
|
logger.info(`action ${action} is triggered`);
|
||||||
|
if (isInLiveEditing()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const doc = project.currentDocument;
|
const doc = project.currentDocument;
|
||||||
if (isFormEvent(e) || !doc) {
|
if (isFormEvent(e) || !doc) {
|
||||||
return;
|
return;
|
||||||
@ -288,8 +317,11 @@ export const builtinHotkey = (ctx: ILowCodePluginContext) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
hotkey.bind(['option+up'], (e) => {
|
hotkey.bind(['option+up'], (e, action) => {
|
||||||
if (isInLiveEditing()) return;
|
logger.info(`action ${action} is triggered`);
|
||||||
|
if (isInLiveEditing()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const doc = project.currentDocument;
|
const doc = project.currentDocument;
|
||||||
if (isFormEvent(e) || !doc) {
|
if (isFormEvent(e) || !doc) {
|
||||||
return;
|
return;
|
||||||
@ -326,8 +358,11 @@ export const builtinHotkey = (ctx: ILowCodePluginContext) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
hotkey.bind(['option+down'], (e) => {
|
hotkey.bind(['option+down'], (e, action) => {
|
||||||
if (isInLiveEditing()) return;
|
logger.info(`action ${action} is triggered`);
|
||||||
|
if (isInLiveEditing()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const doc = project.getCurrentDocument();
|
const doc = project.getCurrentDocument();
|
||||||
if (isFormEvent(e) || !doc) {
|
if (isFormEvent(e) || !doc) {
|
||||||
return;
|
return;
|
||||||
@ -337,7 +372,7 @@ export const builtinHotkey = (ctx: ILowCodePluginContext) => {
|
|||||||
if (!selected || selected.length < 1) {
|
if (!selected || selected.length < 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// TODO: 此处需要增加判断当前节点是否可被操作移动,原ve里是用 node.canOperating()来判断
|
// TODO: 此处需要增加判断当前节点是否可被操作移动,原 ve 里是用 node.canOperating() 来判断
|
||||||
// TODO: 移动逻辑也需要重新梳理,对于移动目标位置的选择,是否可以移入,需要增加判断
|
// TODO: 移动逻辑也需要重新梳理,对于移动目标位置的选择,是否可以移入,需要增加判断
|
||||||
|
|
||||||
const firstNode = selected[0];
|
const firstNode = selected[0];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user