fix(脑图): 脑图快捷键在编辑节点内容时禁用&用例脑图用例子孙节点修改不生效修复
This commit is contained in:
parent
a2f2adfbce
commit
0b00189ee1
|
@ -677,6 +677,18 @@
|
||||||
id: node.data?.id || '',
|
id: node.data?.id || '',
|
||||||
type: 'NONE',
|
type: 'NONE',
|
||||||
});
|
});
|
||||||
|
} else if (caseOffspringTags.some((e) => node.data?.resource?.includes(e))) {
|
||||||
|
// 用例下的子孙节点的移除,标记用例节点变化
|
||||||
|
const parentCase = tempMinderParams.value.updateCaseList.find((e) => e.id !== node.data?.id);
|
||||||
|
if (!parentCase) {
|
||||||
|
if (node.parent?.data?.resource?.includes(caseTag)) {
|
||||||
|
// 第二层子节点
|
||||||
|
node.parent.data.changed = true;
|
||||||
|
} else if (node.parent?.parent?.data?.resource?.includes(caseTag)) {
|
||||||
|
// 第三层子节点
|
||||||
|
node.parent.parent.data.changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (!caseOffspringTags.some((e) => node.data?.resource?.includes(e))) {
|
} else if (!caseOffspringTags.some((e) => node.data?.resource?.includes(e))) {
|
||||||
// 非用例下的子孙节点的移除,才加入删除资源队列
|
// 非用例下的子孙节点的移除,才加入删除资源队列
|
||||||
tempMinderParams.value.deleteResourceList.push({
|
tempMinderParams.value.deleteResourceList.push({
|
||||||
|
@ -859,6 +871,36 @@
|
||||||
...getNodeMoveInfo(nodeIndex, parent as MinderJsonNode),
|
...getNodeMoveInfo(nodeIndex, parent as MinderJsonNode),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
} else if (node.data.resource?.includes(caseTag)) {
|
||||||
|
// 处理用例节点(直接更改用例子孙节点可能没触发用例节点变化)
|
||||||
|
let hasChangedSubNode = false;
|
||||||
|
traverseTree(node.children, (child) => {
|
||||||
|
if (child.data?.changed === true) {
|
||||||
|
hasChangedSubNode = true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
if (hasChangedSubNode) {
|
||||||
|
const caseNodeInfo = getCaseNodeInfo(node as MinderJsonNode);
|
||||||
|
let caseBaseInfo;
|
||||||
|
if (activeCase.value.id === node.data.id) {
|
||||||
|
// 当前用例节点是打开的用例详情,获取用例详情数据
|
||||||
|
caseBaseInfo = baseInfoRef.value?.makeParams();
|
||||||
|
}
|
||||||
|
tempMinderParams.value.updateCaseList.push({
|
||||||
|
id: node.data.id,
|
||||||
|
moduleId: parent?.data.id || '',
|
||||||
|
type: 'UPDATE',
|
||||||
|
templateId: templateId.value,
|
||||||
|
tags: caseBaseInfo?.tags || [],
|
||||||
|
customFields: caseBaseInfo?.customFields || [],
|
||||||
|
name: caseBaseInfo?.name || node.data.text,
|
||||||
|
...getNodeMoveInfo(nodeIndex, parent as MinderJsonNode),
|
||||||
|
...caseNodeInfo,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return false; // 用例的子孙节点已经处理过,跳过
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
|
@ -370,8 +370,8 @@ export default function useMinderBaseApi({ hasEditPermission }: { hasEditPermiss
|
||||||
/**
|
/**
|
||||||
* 插入步骤描述
|
* 插入步骤描述
|
||||||
*/
|
*/
|
||||||
function insetStepDesc() {
|
function insetStepDesc(type: 'AppendChildNode' | 'AppendSiblingNode') {
|
||||||
insertSpecifyNode('AppendChildNode', stepTag);
|
insertSpecifyNode(type, stepTag);
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
insertSpecifyNode('AppendChildNode', stepExpectTag);
|
insertSpecifyNode('AppendChildNode', stepExpectTag);
|
||||||
});
|
});
|
||||||
|
@ -420,7 +420,7 @@ export default function useMinderBaseApi({ hasEditPermission }: { hasEditPermiss
|
||||||
insertSpecifyNode('AppendChildNode', remarkTag);
|
insertSpecifyNode('AppendChildNode', remarkTag);
|
||||||
} else if (!hasTextDesc) {
|
} else if (!hasTextDesc) {
|
||||||
// 没有文本描述,则默认添加一个步骤描述
|
// 没有文本描述,则默认添加一个步骤描述
|
||||||
insetStepDesc();
|
insetStepDesc('AppendChildNode');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (
|
} else if (
|
||||||
|
@ -468,7 +468,7 @@ export default function useMinderBaseApi({ hasEditPermission }: { hasEditPermiss
|
||||||
insertSpecifyNode('AppendSiblingNode', remarkTag);
|
insertSpecifyNode('AppendSiblingNode', remarkTag);
|
||||||
} else if (!hasTextDesc) {
|
} else if (!hasTextDesc) {
|
||||||
// 没有文本描述,则默认添加一个步骤描述
|
// 没有文本描述,则默认添加一个步骤描述
|
||||||
insetStepDesc();
|
insetStepDesc('AppendSiblingNode');
|
||||||
}
|
}
|
||||||
} else if (node.parent?.data?.resource?.includes(moduleTag) || !node.parent?.data?.resource) {
|
} else if (node.parent?.data?.resource?.includes(moduleTag) || !node.parent?.data?.resource) {
|
||||||
// 当前节点的父节点是模块或没有标签,则默认添加一个文本节点
|
// 当前节点的父节点是模块或没有标签,则默认添加一个文本节点
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import type { MinderJsonNode } from '../props';
|
||||||
import useMinderOperation, { type MinderOperationProps } from './useMinderOperation';
|
import useMinderOperation, { type MinderOperationProps } from './useMinderOperation';
|
||||||
|
|
||||||
type ShortcutKey = 'expand' | 'enter' | 'appendSiblingNode' | 'appendChildNode' | 'undo' | 'redo' | 'delete';
|
type ShortcutKey = 'expand' | 'enter' | 'appendSiblingNode' | 'appendChildNode' | 'undo' | 'redo' | 'delete';
|
||||||
|
@ -10,6 +11,20 @@ export default function useShortCut(shortcuts: Shortcuts, options: MinderOperati
|
||||||
const { minderCopy, minderCut, minderPaste } = useMinderOperation(options);
|
const { minderCopy, minderCut, minderPaste } = useMinderOperation(options);
|
||||||
|
|
||||||
const handleKeyDown = (event: KeyboardEvent) => {
|
const handleKeyDown = (event: KeyboardEvent) => {
|
||||||
|
const nodes: MinderJsonNode[] = window.minder.getSelectedNodes();
|
||||||
|
if (nodes.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const { editor } = window;
|
||||||
|
const { fsm } = editor;
|
||||||
|
const state = fsm.state();
|
||||||
|
switch (state) {
|
||||||
|
case 'input': {
|
||||||
|
// 输入状态下不响应快捷键
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
}
|
||||||
const key = event.key.toLowerCase();
|
const key = event.key.toLowerCase();
|
||||||
const isCtrlOrCmd = event.ctrlKey || event.metaKey;
|
const isCtrlOrCmd = event.ctrlKey || event.metaKey;
|
||||||
|
|
||||||
|
|
|
@ -184,6 +184,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleContentChange: (node?: MinderJsonNode) => {
|
handleContentChange: (node?: MinderJsonNode) => {
|
||||||
|
// !!!注意:这里如果是点击输入框以外的地方触发失焦,node 为 undefined,此时 node.data.changed 已标记 true
|
||||||
emit('contentChange', node);
|
emit('contentChange', node);
|
||||||
},
|
},
|
||||||
handleMinderEvent: (event) => {
|
handleMinderEvent: (event) => {
|
||||||
|
|
Loading…
Reference in New Issue