@@ -81,6 +81,10 @@ const DnDFlow = () => {
8181 // Global variables state
8282 const [ globalVariables , setGlobalVariables ] = useState ( [ ] ) ;
8383 const [ events , setEvents ] = useState ( [ ] ) ;
84+
85+ // Python code editor state
86+ const [ pythonCode , setPythonCode ] = useState ( "# Define your Python variables and functions here\n# Example:\n# my_variable = 42\n# def my_function(x):\n# return x * 2\n" ) ;
87+
8488 const [ defaultValues , setDefaultValues ] = useState ( { } ) ;
8589 const [ isEditingLabel , setIsEditingLabel ] = useState ( false ) ;
8690 const [ tempLabel , setTempLabel ] = useState ( '' ) ;
@@ -223,7 +227,8 @@ const DnDFlow = () => {
223227 nodeCounter,
224228 solverParams,
225229 globalVariables,
226- events
230+ events,
231+ pythonCode
227232 } ;
228233
229234 // Check if File System Access API is supported
@@ -303,7 +308,15 @@ const DnDFlow = () => {
303308 }
304309
305310 // Load the graph data
306- const { nodes : loadedNodes , edges : loadedEdges , nodeCounter : loadedNodeCounter , solverParams : loadedSolverParams , globalVariables : loadedGlobalVariables , events : loadedEvents } = graphData ;
311+ const {
312+ nodes : loadedNodes ,
313+ edges : loadedEdges ,
314+ nodeCounter : loadedNodeCounter ,
315+ solverParams : loadedSolverParams ,
316+ globalVariables : loadedGlobalVariables ,
317+ events : loadedEvents ,
318+ pythonCode : loadedPythonCode
319+ } = graphData ;
307320 setNodes ( loadedNodes || [ ] ) ;
308321 setEdges ( loadedEdges || [ ] ) ;
309322 setSelectedNode ( null ) ;
@@ -321,6 +334,7 @@ const DnDFlow = () => {
321334 } ) ;
322335 setGlobalVariables ( loadedGlobalVariables ?? [ ] ) ;
323336 setEvents ( loadedEvents ?? [ ] ) ;
337+ setPythonCode ( loadedPythonCode ?? "# Define your Python variables and functions here\n# Example:\n# my_variable = 42\n# def my_function(x):\n# return x * 2\n" ) ;
324338
325339 alert ( 'Graph loaded successfully!' ) ;
326340 } catch ( error ) {
@@ -355,7 +369,15 @@ const DnDFlow = () => {
355369 return ;
356370 }
357371
358- const { nodes : loadedNodes , edges : loadedEdges , nodeCounter : loadedNodeCounter , solverParams : loadedSolverParams , globalVariables : loadedGlobalVariables , events : loadedEvents } = graphData ;
372+ const {
373+ nodes : loadedNodes ,
374+ edges : loadedEdges ,
375+ nodeCounter : loadedNodeCounter ,
376+ solverParams : loadedSolverParams ,
377+ globalVariables : loadedGlobalVariables ,
378+ events : loadedEvents ,
379+ pythonCode : loadedPythonCode
380+ } = graphData ;
359381 setNodes ( loadedNodes || [ ] ) ;
360382 setEdges ( loadedEdges || [ ] ) ;
361383 setSelectedNode ( null ) ;
@@ -373,6 +395,7 @@ const DnDFlow = () => {
373395 } ) ;
374396 setGlobalVariables ( loadedGlobalVariables ?? [ ] ) ;
375397 setEvents ( loadedEvents ?? [ ] ) ;
398+ setPythonCode ( loadedPythonCode ?? "# Define your Python variables and functions here\n# Example:\n# my_variable = 42\n# def my_function(x):\n# return x * 2\n" ) ;
376399
377400 alert ( 'Graph loaded successfully!' ) ;
378401 } catch ( error ) {
@@ -1620,6 +1643,8 @@ const DnDFlow = () => {
16201643 globalVariables = { globalVariables }
16211644 setGlobalVariables = { setGlobalVariables }
16221645 setActiveTab = { setActiveTab }
1646+ pythonCode = { pythonCode }
1647+ setPythonCode = { setPythonCode }
16231648 />
16241649 ) }
16251650
0 commit comments