fix(脑图): 脑图快捷键在编辑节点内容时禁用&用例脑图用例子孙节点修改不生效修复

This commit is contained in:
baiqi 2024-08-09 17:47:42 +08:00 committed by Craftsman
parent a2f2adfbce
commit 0b00189ee1
4 changed files with 62 additions and 4 deletions

View File

@ -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;
}); });

View File

@ -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) {
// 当前节点的父节点是模块或没有标签,则默认添加一个文本节点 // 当前节点的父节点是模块或没有标签,则默认添加一个文本节点

View File

@ -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;

View File

@ -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) => {