updated ids
This commit is contained in:
parent
bba2942d37
commit
b5f10b68d0
4 changed files with 10 additions and 12 deletions
|
|
@ -43,7 +43,7 @@ const TabsContextInitialValue: TabsContextType = {
|
|||
lastCopiedSelection: null,
|
||||
setLastCopiedSelection: (selection: any) => {},
|
||||
|
||||
getNodeId: () => "",
|
||||
getNodeId: (nodeType:string) => "",
|
||||
paste: (
|
||||
selection: { nodes: any; edges: any },
|
||||
position: { x: number; y: number; paneX?: number; paneY?: number }
|
||||
|
|
@ -280,8 +280,8 @@ export function TabsProvider({ children }: { children: ReactNode }) {
|
|||
});
|
||||
}
|
||||
|
||||
function getNodeId() {
|
||||
return incrementNodeId();
|
||||
function getNodeId(nodeType:string) {
|
||||
return nodeType+"-"+incrementNodeId();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -374,9 +374,9 @@ export function TabsProvider({ children }: { children: ReactNode }) {
|
|||
? { x: position.paneX + position.x, y: position.paneY + position.y }
|
||||
: reactFlowInstance.project({ x: position.x, y: position.y });
|
||||
|
||||
selectionInstance.nodes.forEach((n) => {
|
||||
selectionInstance.nodes.forEach((n:NodeType) => {
|
||||
// Generate a unique node ID
|
||||
let newId = getNodeId();
|
||||
let newId = getNodeId(n.data.type);
|
||||
idsMap[n.id] = newId;
|
||||
|
||||
// Create a new node object
|
||||
|
|
|
|||
|
|
@ -214,9 +214,7 @@ export default function Page({ flow }: { flow: FlowType }) {
|
|||
|
||||
// Generate a unique node ID
|
||||
let { type } = data;
|
||||
let newId = getNodeId();
|
||||
// add lowercase to the type
|
||||
newId = `${type.toLowerCase()}-${newId}`;
|
||||
let newId = getNodeId(type);
|
||||
let newNode: NodeType;
|
||||
|
||||
if (data.type !== "groupNode") {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ export type TabsContextType = {
|
|||
//disable CopyPaste
|
||||
disableCopyPaste: boolean;
|
||||
setDisableCopyPaste: (value: boolean) => void;
|
||||
getNodeId: () => string;
|
||||
getNodeId: (nodeType:string) => string;
|
||||
paste: (
|
||||
selection: { nodes: any; edges: any },
|
||||
position: { x: number; y: number; paneX?: number; paneY?: number }
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import {
|
|||
Bars3CenterLeftIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { Connection, Edge, Node, ReactFlowInstance } from "reactflow";
|
||||
import { FlowType } from "./types/flow";
|
||||
import { FlowType, NodeDataType, NodeType } from "./types/flow";
|
||||
import { APITemplateType } from "./types/api";
|
||||
import _ from "lodash";
|
||||
import { ChromaIcon } from "./icons/ChromaIcon";
|
||||
|
|
@ -625,9 +625,9 @@ export function checkUpperWords(str: string) {
|
|||
export function updateIds(newFlow, getNodeId) {
|
||||
let idsMap = {};
|
||||
|
||||
newFlow.nodes.forEach((n) => {
|
||||
newFlow.nodes.forEach((n:NodeType) => {
|
||||
// Generate a unique node ID
|
||||
let newId = getNodeId();
|
||||
let newId = getNodeId(n.data.type);
|
||||
idsMap[n.id] = newId;
|
||||
n.id = newId;
|
||||
n.data.id = newId;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue