* feat(ui): 完善 UI 布局系统和编辑器可视化工具 * refactor: 移除 ModuleRegistry,统一使用 PluginManager 插件系统 * fix: 修复 CodeQL 警告并提升测试覆盖率 * refactor: 分离运行时入口点,解决 runtime bundle 包含 React 的问题 * fix(ci): 添加 editor-core 和 editor-runtime 到 CI 依赖构建步骤 * docs: 完善 ServiceContainer 文档,新增 Symbol.for 模式和 @InjectProperty 说明 * fix(ci): 修复 type-check 失败问题 * fix(ci): 修复类型检查失败问题 * fix(ci): 修复类型检查失败问题 * fix(ci): behavior-tree 构建添加 @tauri-apps 外部依赖 * fix(ci): behavior-tree 添加 @tauri-apps/plugin-fs 类型依赖 * fix(ci): platform-web 添加缺失的 behavior-tree 依赖 * fix(lint): 移除正则表达式中不必要的转义字符
96 lines
3.1 KiB
TypeScript
96 lines
3.1 KiB
TypeScript
import { React, Icons } from '@esengine/editor-runtime';
|
|
|
|
const { Trash2, Replace, Plus } = Icons;
|
|
|
|
interface NodeContextMenuProps {
|
|
visible: boolean;
|
|
position: { x: number; y: number };
|
|
nodeId: string | null;
|
|
isBlackboardVariable?: boolean;
|
|
onReplaceNode?: () => void;
|
|
onDeleteNode?: () => void;
|
|
onCreateNode?: () => void;
|
|
}
|
|
|
|
export const NodeContextMenu: React.FC<NodeContextMenuProps> = ({
|
|
visible,
|
|
position,
|
|
nodeId,
|
|
isBlackboardVariable = false,
|
|
onReplaceNode,
|
|
onDeleteNode,
|
|
onCreateNode
|
|
}) => {
|
|
if (!visible) return null;
|
|
|
|
const menuItemStyle = {
|
|
padding: '8px 16px',
|
|
cursor: 'pointer',
|
|
color: '#cccccc',
|
|
fontSize: '13px',
|
|
transition: 'background-color 0.15s',
|
|
display: 'flex',
|
|
alignItems: 'center',
|
|
gap: '8px'
|
|
};
|
|
|
|
return (
|
|
<div
|
|
style={{
|
|
position: 'fixed',
|
|
left: position.x,
|
|
top: position.y,
|
|
backgroundColor: '#2d2d30',
|
|
border: '1px solid #454545',
|
|
borderRadius: '4px',
|
|
boxShadow: '0 4px 16px rgba(0, 0, 0, 0.5)',
|
|
zIndex: 10000,
|
|
minWidth: '150px',
|
|
padding: '4px 0'
|
|
}}
|
|
onClick={(e) => e.stopPropagation()}
|
|
>
|
|
{nodeId ? (
|
|
<>
|
|
{onReplaceNode && (
|
|
<div
|
|
onClick={onReplaceNode}
|
|
style={menuItemStyle}
|
|
onMouseEnter={(e) => e.currentTarget.style.backgroundColor = '#094771'}
|
|
onMouseLeave={(e) => e.currentTarget.style.backgroundColor = 'transparent'}
|
|
>
|
|
<Replace size={14} />
|
|
替换节点
|
|
</div>
|
|
)}
|
|
{onDeleteNode && (
|
|
<div
|
|
onClick={onDeleteNode}
|
|
style={{ ...menuItemStyle, color: '#f48771' }}
|
|
onMouseEnter={(e) => e.currentTarget.style.backgroundColor = '#5a1a1a'}
|
|
onMouseLeave={(e) => e.currentTarget.style.backgroundColor = 'transparent'}
|
|
>
|
|
<Trash2 size={14} />
|
|
删除节点
|
|
</div>
|
|
)}
|
|
</>
|
|
) : (
|
|
<>
|
|
{onCreateNode && (
|
|
<div
|
|
onClick={onCreateNode}
|
|
style={menuItemStyle}
|
|
onMouseEnter={(e) => e.currentTarget.style.backgroundColor = '#094771'}
|
|
onMouseLeave={(e) => e.currentTarget.style.backgroundColor = 'transparent'}
|
|
>
|
|
<Plus size={14} />
|
|
新建节点
|
|
</div>
|
|
)}
|
|
</>
|
|
)}
|
|
</div>
|
|
);
|
|
};
|