From 3c000decb5dc3bcf621beb8f5ea4531bb8472df1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8A=9B=E7=9A=93?= Date: Wed, 2 Dec 2020 19:57:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8E=9F=E5=9C=B0=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=BC=82=E5=B8=B8,=20=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E6=97=B6=E9=9C=80=E8=A6=81=E7=A6=81=E6=8E=89=E5=BF=AB=E6=8D=B7?= =?UTF-8?q?=E9=94=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../designer/src/designer/builtin-hotkey.ts | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/packages/designer/src/designer/builtin-hotkey.ts b/packages/designer/src/designer/builtin-hotkey.ts index bc8a698df..07fa4ad56 100644 --- a/packages/designer/src/designer/builtin-hotkey.ts +++ b/packages/designer/src/designer/builtin-hotkey.ts @@ -1,9 +1,16 @@ -import { hotkey } from '@ali/lowcode-editor-core'; +import { hotkey, Editor, globalContext } from '@ali/lowcode-editor-core'; import { isFormEvent } from '@ali/lowcode-utils'; import { focusing } from './focusing'; import { insertChildren, TransformStage } from '../document'; import clipboard from './clipboard'; +function isInLiveEditing() { + if (globalContext.has(Editor)) { + return Boolean(globalContext.get(Editor).get('designer')?.project?.simulator?.liveEditing?.editing); + } + return false; +} + function getNextForSelect(next: any, head?: any, parent?: any): any { if (next) { if (!head) { @@ -66,6 +73,7 @@ function getPrevForSelect(prev: any, head?: any, parent?: any): any { // hotkey binding hotkey.bind(['backspace', 'del'], (e: KeyboardEvent) => { + if (isInLiveEditing()) return; // TODO: use focus-tracker const doc = focusing.focusDesigner?.currentDocument; if (isFormEvent(e) || !doc) { @@ -86,6 +94,7 @@ hotkey.bind(['backspace', 'del'], (e: KeyboardEvent) => { hotkey.bind('escape', (e: KeyboardEvent) => { // const currentFocus = focusing.current; + if (isInLiveEditing()) return; const sel = focusing.focusDesigner?.currentDocument?.selection; if (isFormEvent(e) || !sel) { return; @@ -98,6 +107,7 @@ hotkey.bind('escape', (e: KeyboardEvent) => { // command + c copy command + x cut hotkey.bind(['command+c', 'ctrl+c', 'command+x', 'ctrl+x'], (e, action) => { + if (isInLiveEditing()) return; const doc = focusing.focusDesigner?.currentDocument; if (isFormEvent(e) || !doc) { return; @@ -133,6 +143,7 @@ hotkey.bind(['command+c', 'ctrl+c', 'command+x', 'ctrl+x'], (e, action) => { // command + v paste hotkey.bind(['command+v', 'ctrl+v'], (e) => { + if (isInLiveEditing()) return; const designer = focusing.focusDesigner; const doc = designer?.currentDocument; if (isFormEvent(e) || !designer || !doc) { @@ -155,6 +166,7 @@ hotkey.bind(['command+v', 'ctrl+v'], (e) => { // command + z undo hotkey.bind(['command+z', 'ctrl+z'], (e) => { + if (isInLiveEditing()) return; const his = focusing.focusDesigner?.currentHistory; if (isFormEvent(e) || !his) { return; @@ -166,6 +178,7 @@ hotkey.bind(['command+z', 'ctrl+z'], (e) => { // command + shift + z redo hotkey.bind(['command+y', 'ctrl+y', 'command+shift+z'], (e) => { + if (isInLiveEditing()) return; const his = focusing.focusDesigner?.currentHistory; if (isFormEvent(e) || !his) { return; @@ -177,6 +190,7 @@ hotkey.bind(['command+y', 'ctrl+y', 'command+shift+z'], (e) => { // sibling selection hotkey.bind(['left', 'right'], (e, action) => { + if (isInLiveEditing()) return; const designer = focusing.focusDesigner; const doc = designer?.currentDocument; if (isFormEvent(e) || !doc) { @@ -193,6 +207,7 @@ hotkey.bind(['left', 'right'], (e, action) => { }); hotkey.bind(['up', 'down'], (e, action) => { + if (isInLiveEditing()) return; const designer = focusing.focusDesigner; const doc = designer?.currentDocument; if (isFormEvent(e) || !doc) { @@ -215,6 +230,7 @@ hotkey.bind(['up', 'down'], (e, action) => { }); hotkey.bind(['option+left', 'option+right'], (e, action) => { + if (isInLiveEditing()) return; const designer = focusing.focusDesigner; const doc = designer?.currentDocument; if (isFormEvent(e) || !doc) { @@ -246,6 +262,7 @@ hotkey.bind(['option+left', 'option+right'], (e, action) => { }); hotkey.bind(['option+up'], (e) => { + if (isInLiveEditing()) return; const designer = focusing.focusDesigner; const doc = designer?.currentDocument; if (isFormEvent(e) || !doc) { @@ -284,6 +301,7 @@ hotkey.bind(['option+up'], (e) => { }); hotkey.bind(['option+down'], (e) => { + if (isInLiveEditing()) return; const designer = focusing.focusDesigner; const doc = designer?.currentDocument; if (isFormEvent(e) || !doc) {