TextNode.tsx 905 B

12345678910111213141516171819202122232425262728293031323334
  1. import React from "react";
  2. import { ConditionalWrapper, CustomNodeProps } from "src/components/CustomNode";
  3. import useConfig from "src/hooks/store/useConfig";
  4. import * as Styled from "./styles";
  5. const TextNode: React.FC<CustomNodeProps<string>> = ({
  6. width,
  7. height,
  8. value,
  9. isParent = false,
  10. x,
  11. y,
  12. }) => {
  13. const performance = useConfig((state) => state.settings.performance);
  14. return (
  15. <Styled.StyledForeignObject width={width} height={height} x={0} y={0}>
  16. <ConditionalWrapper condition={performance}>
  17. <Styled.StyledText width={width} height={height}>
  18. <Styled.StyledKey
  19. data-x={x}
  20. data-y={y}
  21. data-key={value}
  22. parent={isParent}
  23. >
  24. {value}
  25. </Styled.StyledKey>
  26. </Styled.StyledText>
  27. </ConditionalWrapper>
  28. </Styled.StyledForeignObject>
  29. );
  30. };
  31. export default TextNode;