import React, { useRef } from 'react'; import { Tinyflow, TinyflowHandle } from '@tinyflow-ai/react'; import '@tinyflow-ai/react/dist/index.css'; const App = () => { const tinyflowRef = useRef(null); const handleGetData = () => { if (tinyflowRef.current) { const data = tinyflowRef.current.getData(); console.log('Flow Data:', data); } }; const customNodes = { 'custom-node': { title: '自定义节点', description: '这是一个测试的自定义节点', icon: '', sortNo: 2, render: (parent, node, flowInstance) => { parent.innerHTML = ``; parent.querySelector('select') ?.addEventListener('change', (e) => { console.log('select change: ', e); flowInstance.updateNodeData(node.id, { test: e.target.value }); }) ; console.log('render: ', node, flowInstance); }, onUpdate: (parent, node) => { console.log('onUpdate: ', node); } }, 'test-node': { title: '测试节点', description: '这是一个测试的自定义节点', icon: '', sortNo: 310, group: 'tools', forms: [ { type: 'heading', label: '测试节点' }, { type: 'input', name: 'test', label: '测试', placeholder: '请输入测试内容' }, { type: 'select', name: 'test2', label: '测试2', placeholder: '请选择测试内容', defaultValue: '1', options: [ { label: '选项1', value: '1' }, { label: '选项2', value: '2' }, { label: '选项3', value: '3' } ] } ] } }; return (

Tinyflow React Example

); }; export default App;