|
|
|
@ -1,6 +1,6 @@
|
|
|
|
import React, { useState, useEffect } from 'react';
|
|
|
|
import React, { useState, useEffect, useRef } from 'react';
|
|
|
|
import { Node } from '@xyflow/react';
|
|
|
|
import { Node } from '@xyflow/react';
|
|
|
|
import { Modal } from '@arco-design/web-react';
|
|
|
|
import { Drawer, ResizeBox } from '@arco-design/web-react';
|
|
|
|
import { getNodeEditorByType } from '../nodeEditors';
|
|
|
|
import { getNodeEditorByType } from '../nodeEditors';
|
|
|
|
|
|
|
|
|
|
|
|
interface NodeData {
|
|
|
|
interface NodeData {
|
|
|
|
@ -13,6 +13,7 @@ interface NodeData {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
interface NodeEditModalProps {
|
|
|
|
interface NodeEditModalProps {
|
|
|
|
|
|
|
|
popupContainer: any;
|
|
|
|
node: Node<NodeData>;
|
|
|
|
node: Node<NodeData>;
|
|
|
|
isOpen: boolean;
|
|
|
|
isOpen: boolean;
|
|
|
|
onSave: (data: any) => void;
|
|
|
|
onSave: (data: any) => void;
|
|
|
|
@ -20,6 +21,7 @@ interface NodeEditModalProps {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const NodeEditModal: React.FC<NodeEditModalProps> = ({
|
|
|
|
const NodeEditModal: React.FC<NodeEditModalProps> = ({
|
|
|
|
|
|
|
|
popupContainer,
|
|
|
|
node,
|
|
|
|
node,
|
|
|
|
isOpen,
|
|
|
|
isOpen,
|
|
|
|
onSave,
|
|
|
|
onSave,
|
|
|
|
@ -49,7 +51,6 @@ const NodeEditModal: React.FC<NodeEditModalProps> = ({
|
|
|
|
setVisible(false);
|
|
|
|
setVisible(false);
|
|
|
|
onClose();
|
|
|
|
onClose();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 更新节点数据的通用函数
|
|
|
|
// 更新节点数据的通用函数
|
|
|
|
const updateNodeData = (key: string, value: any) => {
|
|
|
|
const updateNodeData = (key: string, value: any) => {
|
|
|
|
setNodeData(prev => ({
|
|
|
|
setNodeData(prev => ({
|
|
|
|
@ -79,17 +80,23 @@ const NodeEditModal: React.FC<NodeEditModalProps> = ({
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<Modal
|
|
|
|
<Drawer
|
|
|
|
|
|
|
|
style={{
|
|
|
|
|
|
|
|
boxShadow: '0 5px 15px rgba(0, 0, 0, 0.2)'
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
width={500}
|
|
|
|
title={`编辑节点: ${nodeData.title || node?.type || '未知类型'}`}
|
|
|
|
title={`编辑节点: ${nodeData.title || node?.type || '未知类型'}`}
|
|
|
|
visible={visible}
|
|
|
|
visible={visible}
|
|
|
|
|
|
|
|
placement="left"
|
|
|
|
|
|
|
|
mask={false}
|
|
|
|
|
|
|
|
maskClosable={false}
|
|
|
|
|
|
|
|
footer={null}
|
|
|
|
|
|
|
|
getPopupContainer={() => popupContainer?.current || document.body}
|
|
|
|
onOk={handleSave}
|
|
|
|
onOk={handleSave}
|
|
|
|
onCancel={handleClose}
|
|
|
|
onCancel={handleSave}
|
|
|
|
autoFocus={false}
|
|
|
|
|
|
|
|
focusLock={true}
|
|
|
|
|
|
|
|
style={{ width: '45%' }}
|
|
|
|
|
|
|
|
>
|
|
|
|
>
|
|
|
|
{getNodeEditor()}
|
|
|
|
{getNodeEditor()}
|
|
|
|
</Modal>
|
|
|
|
</Drawer>
|
|
|
|
);
|
|
|
|
);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|