Merge branch 'main' into v11

This commit is contained in:
moklick
2022-07-25 15:49:48 +02:00
9 changed files with 39511 additions and 71 deletions
@@ -1,15 +1,21 @@
import { useCallback } from 'react';
import { useStore } from '../store';
import { useStore, useStoreApi } from '../store';
import { UpdateNodeInternals, ReactFlowState } from '../types';
const selector = (state: ReactFlowState) => state.updateNodeDimensions;
function useUpdateNodeInternals(): UpdateNodeInternals {
const store = useStoreApi();
const updateNodeDimensions = useStore(selector);
return useCallback<UpdateNodeInternals>((id: string) => {
const nodeElement = document.querySelector(`.react-flow__node[data-id="${id}"]`) as HTMLDivElement;
const { domNode } = store.getState();
if (!domNode) {
return;
}
const nodeElement = domNode.querySelector(`.react-flow__node[data-id="${id}"]`) as HTMLDivElement;
if (nodeElement) {
updateNodeDimensions([{ id, nodeElement, forceUpdate: true }]);