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