@@ -1294,67 +1294,81 @@ const updateVueFlowNodeId = (oldId, newId) => {
12941294// FormGenerator integration
12951295const snapshotYamlContent = () => cloneDeep(yamlContent.value ?? null)
12961296
1297- // Build YAML without specific node
1297+ // Build YAML without specific node (shallow clone path to avoid full deep-clone on editor open)
12981298const buildYamlWithoutNode = (nodeId) => {
1299- const snapshot = snapshotYamlContent()
1300- if (!snapshot?.graph?.nodes || !Array.isArray(snapshot.graph.nodes)) {
1301- return snapshot
1299+ const source = yamlContent.value
1300+ if (!source?.graph?.nodes || !Array.isArray(source.graph.nodes)) {
1301+ return source
1302+ }
1303+ return {
1304+ ...source,
1305+ graph: {
1306+ ...source.graph,
1307+ nodes: source.graph.nodes.filter(node => node?.id !== nodeId)
1308+ }
13021309 }
1303- snapshot.graph.nodes = snapshot.graph.nodes.filter(node => node?.id !== nodeId)
1304- return snapshot
13051310}
13061311
13071312const buildYamlWithoutEdge = (fromId, toId) => {
1308- const snapshot = snapshotYamlContent()
1309- if (!snapshot ?.graph?.edges || !Array.isArray(snapshot .graph.edges)) {
1310- return snapshot
1313+ const source = yamlContent.value
1314+ if (!source ?.graph?.edges || !Array.isArray(source .graph.edges)) {
1315+ return source
13111316 }
13121317 let removed = false
1313- snapshot.graph.edges = snapshot .graph.edges.filter(edge => {
1318+ const filteredEdges = source .graph.edges.filter(edge => {
13141319 if (!removed && edge?.from === fromId && edge?.to === toId) {
13151320 removed = true
13161321 return false
13171322 }
13181323 return true
13191324 })
1320- return snapshot
1325+ return {
1326+ ...source,
1327+ graph: {
1328+ ...source.graph,
1329+ edges: filteredEdges
1330+ }
1331+ }
13211332}
13221333
13231334const buildYamlWithoutVars = () => {
1324- const snapshot = snapshotYamlContent()
1325- if (!snapshot || typeof snapshot !== 'object') {
1326- return snapshot
1335+ const source = yamlContent.value
1336+ if (!source || typeof source !== 'object') {
1337+ return source
13271338 }
1328- if (!Object.prototype.hasOwnProperty.call(snapshot , 'vars')) {
1329- return snapshot
1339+ if (!Object.prototype.hasOwnProperty.call(source , 'vars')) {
1340+ return source
13301341 }
1331- const sanitized = { ...snapshot }
1342+ const sanitized = { ...source }
13321343 delete sanitized.vars
13331344 return sanitized
13341345}
13351346
13361347const buildYamlWithoutMemory = () => {
1337- const snapshot = snapshotYamlContent()
1338- if (!snapshot ?.graph) {
1339- return snapshot
1348+ const source = yamlContent.value
1349+ if (!source ?.graph) {
1350+ return source
13401351 }
1341- if (Object.prototype.hasOwnProperty.call(snapshot .graph, 'memory')) {
1342- const newGraph = { ...snapshot .graph }
1352+ if (Object.prototype.hasOwnProperty.call(source .graph, 'memory')) {
1353+ const newGraph = { ...source .graph }
13431354 delete newGraph.memory
1344- snapshot.graph = newGraph
1355+ return {
1356+ ...source,
1357+ graph: newGraph
1358+ }
13451359 }
1346- return snapshot
1360+ return source
13471361}
13481362
13491363const buildYamlWithoutGraph = () => {
1350- const snapshot = snapshotYamlContent()
1351- if (!snapshot || typeof snapshot !== 'object') {
1352- return snapshot
1364+ const source = yamlContent.value
1365+ if (!source || typeof source !== 'object') {
1366+ return source
13531367 }
1354- if (!Object.prototype.hasOwnProperty.call(snapshot , 'graph')) {
1355- return snapshot
1368+ if (!Object.prototype.hasOwnProperty.call(source , 'graph')) {
1369+ return source
13561370 }
1357- const sanitized = { ...snapshot }
1371+ const sanitized = { ...source }
13581372 delete sanitized.graph
13591373 return sanitized
13601374}
@@ -1398,12 +1412,10 @@ const openDynamicFormGenerator = (type, options = {}) => {
13981412
13991413 const hasCustomYaml = Object.prototype.hasOwnProperty.call(options, 'initialYaml')
14001414 const yamlSource = hasCustomYaml ? options.initialYaml : yamlContent.value
1401- formGeneratorInitialYaml.value = yamlSource ? cloneDeep(yamlSource) : null
1415+ formGeneratorInitialYaml.value = yamlSource || null
14021416
14031417 if (Object.prototype.hasOwnProperty.call(options, 'initialFormData')) {
1404- formGeneratorInitialFormData.value = options.initialFormData
1405- ? cloneDeep(options.initialFormData)
1406- : null
1418+ formGeneratorInitialFormData.value = options.initialFormData || null
14071419 } else {
14081420 formGeneratorInitialFormData.value = null
14091421 }
0 commit comments