Skip to content

Commit

Permalink
🔧 fix: menu delete
Browse files Browse the repository at this point in the history
  • Loading branch information
deepkolos committed Oct 7, 2023
1 parent 6ced5b5 commit c277b3d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
- 函数节点内容不方便编辑 先提供个方便编辑的地方
- 参数更新复用老参数配置
- 链接稍微困难, 需要增大识别区域 ✅
- 右键未触发节点选择 导致删除可能误删
- 右键未触发节点选择 导致删除可能误删, 先增加提示+顺序调整规避 ✅
- 右键菜单二级菜单无法显示 ✅

# 赞助
Expand Down
12 changes: 7 additions & 5 deletions src/view/popups/EditorMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,11 @@ const EditorContextMenu: FC<MenuProps> = ({ editor, connection, node, popupAdd,
},
];

const hideDeleteNode = (!node || node.meta.undeleteable) && selectedCloneableNodes.length === 0;
const hideDeleteConnection = !connection || (connection.data as any).fixed;
const deleteNode = (node || selectedCloneableNodes.length) && [
{
name: '删除',
name: '删除' + (hideDeleteConnection ? '' : '节点'),
onclick: () => {
try {
if (node && !editor.selected.contains(node)) editor.removeNode(node);
Expand All @@ -196,13 +198,13 @@ const EditorContextMenu: FC<MenuProps> = ({ editor, connection, node, popupAdd,
view.hide();
}
},
disabled: (!node || node.meta.undeleteable) && selectedCloneableNodes.length === 0,
disabled: hideDeleteNode,
},
];

const deleteConnection = connection && [
{
name: '删除',
name: '删除' + (hideDeleteNode ? '' : '连线'),
onclick: () => {
try {
editor.removeConnection(connection!);
Expand All @@ -212,7 +214,7 @@ const EditorContextMenu: FC<MenuProps> = ({ editor, connection, node, popupAdd,
view.hide();
}
},
disabled: !connection || (connection.data as any).fixed,
disabled: hideDeleteConnection,
},
];

Expand Down Expand Up @@ -249,8 +251,8 @@ const EditorContextMenu: FC<MenuProps> = ({ editor, connection, node, popupAdd,
copyShaderLink,
addNode,
copyPasteCut,
deleteNode,
deleteConnection,
deleteNode,
// !connection && [{ name: '克隆', onclick: () => {}, disabled: true }],
selectUnusedNode,
].filter(i => !!i) as MenuListProps['items']
Expand Down

0 comments on commit c277b3d

Please sign in to comment.