// import { memo, useMemo } from 'react'; import { type MarkerProps, createMarkerIds } from '@xyflow/system'; import { useStore } from '../../hooks/useStore'; import { useMarkerSymbol } from './MarkerSymbols'; import { For, Show, mergeProps } from 'solid-js'; import { Dynamic } from 'solid-js/web'; type MarkerDefinitionsProps = { defaultColor: string; rfId?: string; }; const Marker = (_p: MarkerProps) => { // id, // type, // color, // width = 12.5, // height = 12.5, // markerUnits = 'strokeWidth', // strokeWidth, // orient = 'auto-start-reverse', // }: MarkerProps) => { const p = mergeProps({ width: 12.5, height: 12.5, markerUnits: 'strokeWidth', orient: 'auto-start-reverse' }, _p); const SymbolComp = useMarkerSymbol(() => p.type); // if (!symbol) { // return null; // } return ( {(symbol) => { return ( ); }} ); }; // when you have multiple flows on a page and you hide the first one, the other ones have no markers anymore // when they do have markers with the same ids. To prevent this the user can pass a unique id to the react flow wrapper // that we can then use for creating our unique marker ids const MarkerDefinitions = (p: MarkerDefinitionsProps) => { console.log('MarkerDefinitions', p); // { defaultColor, rfId }: MarkerDefinitionsProps) => { const edges = useStore((s) => s.edges); const defaultEdgeOptions = useStore((s) => () => s.defaultEdgeOptions); const markers = () => { const markers = createMarkerIds(edges.get(), { id: p.rfId, defaultColor: p.defaultColor, defaultMarkerStart: defaultEdgeOptions()?.markerStart, defaultMarkerEnd: defaultEdgeOptions()?.markerEnd, }); console.log('edges and markers', edges.get(), markers); return markers; }; // if (!markers.length) { // return null; // } return ( {(marker) => { return ( ); }} ); }; MarkerDefinitions.displayName = 'MarkerDefinitions'; export default MarkerDefinitions;