added parentLookup

This commit is contained in:
peterkogo
2024-04-15 17:03:03 +02:00
parent c5f394e1f7
commit ccf6578824
7 changed files with 49 additions and 31 deletions
+3 -2
View File
@@ -127,7 +127,8 @@ export type NodeStoreOptions = {
// The user only passes in relative positions, so we need to calculate the absolute positions based on the parent nodes.
export const createNodesStore = (
nodes: Node[],
nodeLookup: NodeLookup<InternalNode>
nodeLookup: NodeLookup<InternalNode>,
parentLookup: Map<string, InternalNode[]>
): {
subscribe: (this: void, run: Subscriber<Node[]>) => Unsubscriber;
update: (this: void, updater: Updater<Node[]>) => void;
@@ -141,7 +142,7 @@ export const createNodesStore = (
let elevateNodesOnSelect = true;
const _set = (nds: Node[]): Node[] => {
adoptUserNodes(nds, nodeLookup, {
adoptUserNodes(nds, nodeLookup, parentLookup, {
elevateNodesOnSelect,
defaults,
checkEquality: false