Skip to content

Commit

Permalink
fix: 修复静默模式切换后快捷键和拖拽节点状态不更新问题 (#1491)
Browse files Browse the repository at this point in the history
* fix: 修复stopMoveGraph从true置为false后画布仍无法移动问题

* fix: 修复静默模式切换后快捷键和拖拽节点状态不更新问题

* fix: 优化代码

---------

Co-authored-by: liuziqi <account email>
Co-authored-by: 你说呢? <boyongjiong@users.noreply.github.com>
  • Loading branch information
DymoneLewis and boyongjiong authored Jan 31, 2024
1 parent b805f17 commit 926f33e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
15 changes: 8 additions & 7 deletions packages/core/src/LogicFlow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,11 @@ export default class LogicFlow {
this.snaplineModel = new SnaplineModel(this.graphModel);
snaplineTool(this.graphModel.eventCenter, this.snaplineModel);
}
if (!this.options.isSilentMode) {
// 先初始化默认内置快捷键
initDefaultShortcut(this, this.graphModel);
// 然后再初始化自定义快捷键,自定义快捷键可以覆盖默认快捷键.
// 插件最后初始化。方便插件强制覆盖内置快捷键
this.keyboard.initShortcuts();
}
// 先初始化默认内置快捷键
initDefaultShortcut(this, this.graphModel);
// 然后再初始化自定义快捷键,自定义快捷键可以覆盖默认快捷键.
// 插件最后初始化。方便插件强制覆盖内置快捷键
this.keyboard.initShortcuts();
// init 放到最后
this.defaultRegister();
this.installPlugins(options.disabledPlugins);
Expand Down Expand Up @@ -793,6 +791,9 @@ export default class LogicFlow {
if (config?.stopMoveGraph !== undefined) {
transformModel.updateTranslateLimits(config.stopMoveGraph);
}

// 静默模式切换时,修改快捷键的启用状态
config?.isSilentMode ? this.keyboard.disable() : this.keyboard.enable(true);
}
/**
* 获取流程图当前编辑相关设置
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/keyboard/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ class Keyboard {
const { lf } = options;
this.target = lf.container;
this.mousetrap = new Mousetrap(this.target);
if (options.keyboard.enabled) {
// 默认开启快捷键,且不是静默模式时enable
if (options.keyboard.enabled && !lf.options.isSilentMode) {
this.enable(true);
}
}
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/view/behavior/DnD.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export default class Dnd {
}

startDrag(nodeConfig: NewNodeConfig) {
if (!this.lf.options.isSilentMode) {
const { editConfigModel } = this.lf.graphModel;
if (!editConfigModel?.isSilentMode) {
this.nodeConfig = nodeConfig;
window.document.addEventListener('mouseup', this.stopDrag);
}
Expand Down

0 comments on commit 926f33e

Please sign in to comment.