fix(用例脑图): 全部用例节点不可复制不可剪切

This commit is contained in:
baiqi 2024-08-15 17:04:24 +08:00 committed by 刘瑞斌
parent bb5cc4bce5
commit 0c022fdecd
1 changed files with 15 additions and 9 deletions

View File

@ -54,19 +54,23 @@ export default function useMinderOperation(options: MinderOperationProps) {
*
*/
const minderCopy = async (e?: ClipboardEvent) => {
if ((!options.canShowMoreMenu || !options.canShowMoreMenuNodeOperation) && options.canShowBatchCopy === false) {
const { editor } = window;
const { minder, fsm } = editor;
const selectedNodes: MinderJsonNode[] = minder.getSelectedNodes();
if (
!options.canShowMoreMenu ||
!options.canShowMoreMenuNodeOperation ||
(selectedNodes.length > 1 && options.canShowBatchCopy === false)
) {
e?.preventDefault();
return;
}
const { editor } = window;
const { minder, fsm } = editor;
const state = fsm.state();
switch (state) {
case 'input': {
break;
}
case 'normal': {
const selectedNodes = minder.getSelectedNodes();
minderStore.dispatchEvent(MinderEventName.COPY_NODE, undefined, undefined, undefined, selectedNodes);
if (e?.clipboardData) {
e.clipboardData.setData('text/plain', encode(selectedNodes));
@ -87,15 +91,18 @@ export default function useMinderOperation(options: MinderOperationProps) {
*
*/
const minderCut = async (e?: ClipboardEvent) => {
const { editor } = window;
const { minder, fsm } = editor;
const selectedNodes: MinderJsonNode[] = minder.getSelectedNodes();
if (
(options.disabled || !options.canShowMoreMenu || !options.canShowMoreMenuNodeOperation) &&
options.canShowBatchCut === false
options.disabled ||
!options.canShowMoreMenu ||
!options.canShowMoreMenuNodeOperation ||
(selectedNodes.length > 1 && options.canShowBatchCut === false)
) {
e?.preventDefault();
return;
}
const { editor } = window;
const { minder, fsm } = editor;
if (minder.getStatus() !== 'normal') {
e?.preventDefault();
return;
@ -107,7 +114,6 @@ export default function useMinderOperation(options: MinderOperationProps) {
}
case 'normal': {
markDeleteNode(minder);
const selectedNodes: MinderJsonNode[] = minder.getSelectedNodes();
if (selectedNodes.length) {
const newNodes = selectedNodes.map((node) => ({
...node,