mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-03-07 10:57:19 +00:00
fix: 原地编辑功能异常, 编辑时需要禁掉快捷键
This commit is contained in:
parent
9d19860807
commit
0a2cf99ee0
@ -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 { isFormEvent } from '@ali/lowcode-utils';
|
||||||
import { focusing } from './focusing';
|
import { focusing } from './focusing';
|
||||||
import { insertChildren, TransformStage } from '../document';
|
import { insertChildren, TransformStage } from '../document';
|
||||||
import clipboard from './clipboard';
|
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 {
|
function getNextForSelect(next: any, head?: any, parent?: any): any {
|
||||||
if (next) {
|
if (next) {
|
||||||
if (!head) {
|
if (!head) {
|
||||||
@ -66,6 +73,7 @@ function getPrevForSelect(prev: any, head?: any, parent?: any): any {
|
|||||||
|
|
||||||
// hotkey binding
|
// hotkey binding
|
||||||
hotkey.bind(['backspace', 'del'], (e: KeyboardEvent) => {
|
hotkey.bind(['backspace', 'del'], (e: KeyboardEvent) => {
|
||||||
|
if (isInLiveEditing()) return;
|
||||||
// TODO: use focus-tracker
|
// TODO: use focus-tracker
|
||||||
const doc = focusing.focusDesigner?.currentDocument;
|
const doc = focusing.focusDesigner?.currentDocument;
|
||||||
if (isFormEvent(e) || !doc) {
|
if (isFormEvent(e) || !doc) {
|
||||||
@ -86,6 +94,7 @@ hotkey.bind(['backspace', 'del'], (e: KeyboardEvent) => {
|
|||||||
|
|
||||||
hotkey.bind('escape', (e: KeyboardEvent) => {
|
hotkey.bind('escape', (e: KeyboardEvent) => {
|
||||||
// const currentFocus = focusing.current;
|
// const currentFocus = focusing.current;
|
||||||
|
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;
|
||||||
@ -98,6 +107,7 @@ hotkey.bind('escape', (e: KeyboardEvent) => {
|
|||||||
|
|
||||||
// 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;
|
||||||
const doc = focusing.focusDesigner?.currentDocument;
|
const doc = focusing.focusDesigner?.currentDocument;
|
||||||
if (isFormEvent(e) || !doc) {
|
if (isFormEvent(e) || !doc) {
|
||||||
return;
|
return;
|
||||||
@ -133,6 +143,7 @@ hotkey.bind(['command+c', 'ctrl+c', 'command+x', 'ctrl+x'], (e, action) => {
|
|||||||
|
|
||||||
// command + v paste
|
// command + v paste
|
||||||
hotkey.bind(['command+v', 'ctrl+v'], (e) => {
|
hotkey.bind(['command+v', 'ctrl+v'], (e) => {
|
||||||
|
if (isInLiveEditing()) return;
|
||||||
const designer = focusing.focusDesigner;
|
const designer = focusing.focusDesigner;
|
||||||
const doc = designer?.currentDocument;
|
const doc = designer?.currentDocument;
|
||||||
if (isFormEvent(e) || !designer || !doc) {
|
if (isFormEvent(e) || !designer || !doc) {
|
||||||
@ -155,6 +166,7 @@ hotkey.bind(['command+v', 'ctrl+v'], (e) => {
|
|||||||
|
|
||||||
// command + z undo
|
// command + z undo
|
||||||
hotkey.bind(['command+z', 'ctrl+z'], (e) => {
|
hotkey.bind(['command+z', 'ctrl+z'], (e) => {
|
||||||
|
if (isInLiveEditing()) return;
|
||||||
const his = focusing.focusDesigner?.currentHistory;
|
const his = focusing.focusDesigner?.currentHistory;
|
||||||
if (isFormEvent(e) || !his) {
|
if (isFormEvent(e) || !his) {
|
||||||
return;
|
return;
|
||||||
@ -166,6 +178,7 @@ hotkey.bind(['command+z', 'ctrl+z'], (e) => {
|
|||||||
|
|
||||||
// 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) => {
|
||||||
|
if (isInLiveEditing()) return;
|
||||||
const his = focusing.focusDesigner?.currentHistory;
|
const his = focusing.focusDesigner?.currentHistory;
|
||||||
if (isFormEvent(e) || !his) {
|
if (isFormEvent(e) || !his) {
|
||||||
return;
|
return;
|
||||||
@ -177,6 +190,7 @@ hotkey.bind(['command+y', 'ctrl+y', 'command+shift+z'], (e) => {
|
|||||||
|
|
||||||
// sibling selection
|
// sibling selection
|
||||||
hotkey.bind(['left', 'right'], (e, action) => {
|
hotkey.bind(['left', 'right'], (e, action) => {
|
||||||
|
if (isInLiveEditing()) return;
|
||||||
const designer = focusing.focusDesigner;
|
const designer = focusing.focusDesigner;
|
||||||
const doc = designer?.currentDocument;
|
const doc = designer?.currentDocument;
|
||||||
if (isFormEvent(e) || !doc) {
|
if (isFormEvent(e) || !doc) {
|
||||||
@ -193,6 +207,7 @@ hotkey.bind(['left', 'right'], (e, action) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
hotkey.bind(['up', 'down'], (e, action) => {
|
hotkey.bind(['up', 'down'], (e, action) => {
|
||||||
|
if (isInLiveEditing()) return;
|
||||||
const designer = focusing.focusDesigner;
|
const designer = focusing.focusDesigner;
|
||||||
const doc = designer?.currentDocument;
|
const doc = designer?.currentDocument;
|
||||||
if (isFormEvent(e) || !doc) {
|
if (isFormEvent(e) || !doc) {
|
||||||
@ -215,6 +230,7 @@ hotkey.bind(['up', 'down'], (e, action) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
hotkey.bind(['option+left', 'option+right'], (e, action) => {
|
hotkey.bind(['option+left', 'option+right'], (e, action) => {
|
||||||
|
if (isInLiveEditing()) return;
|
||||||
const designer = focusing.focusDesigner;
|
const designer = focusing.focusDesigner;
|
||||||
const doc = designer?.currentDocument;
|
const doc = designer?.currentDocument;
|
||||||
if (isFormEvent(e) || !doc) {
|
if (isFormEvent(e) || !doc) {
|
||||||
@ -246,6 +262,7 @@ hotkey.bind(['option+left', 'option+right'], (e, action) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
hotkey.bind(['option+up'], (e) => {
|
hotkey.bind(['option+up'], (e) => {
|
||||||
|
if (isInLiveEditing()) return;
|
||||||
const designer = focusing.focusDesigner;
|
const designer = focusing.focusDesigner;
|
||||||
const doc = designer?.currentDocument;
|
const doc = designer?.currentDocument;
|
||||||
if (isFormEvent(e) || !doc) {
|
if (isFormEvent(e) || !doc) {
|
||||||
@ -284,6 +301,7 @@ hotkey.bind(['option+up'], (e) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
hotkey.bind(['option+down'], (e) => {
|
hotkey.bind(['option+down'], (e) => {
|
||||||
|
if (isInLiveEditing()) return;
|
||||||
const designer = focusing.focusDesigner;
|
const designer = focusing.focusDesigner;
|
||||||
const doc = designer?.currentDocument;
|
const doc = designer?.currentDocument;
|
||||||
if (isFormEvent(e) || !doc) {
|
if (isFormEvent(e) || !doc) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user