✨ Innovative and open-source visualization application that transforms various data formats, such as JSON, YAML, XML and CSV into interactive graphs.
feat: improve graph view ux
AykutSarac1cf5b09d1a3e
diff --git a/src/features/editor/Toolbar/OptionsMenu.tsx b/src/features/editor/Toolbar/OptionsMenu.tsxdeleted file mode 100644index 31b777c3..00000000--- a/src/features/editor/Toolbar/OptionsMenu.tsx+++ /dev/null@@ -1,91 +0,0 @@-import React from "react";-import { Menu, Text, Flex } from "@mantine/core";-import { event as gaEvent } from "nextjs-google-analytics";-import { BsCheck2 } from "react-icons/bs";-import { MdSettings } from "react-icons/md";-import useConfig from "../../../store/useConfig";-import { StyledToolElement } from "./styles";--export const OptionsMenu = () => {- const toggleGestures = useConfig(state => state.toggleGestures);- const toggleChildrenCount = useConfig(state => state.toggleChildrenCount);- const toggleDarkMode = useConfig(state => state.toggleDarkMode);- const toggleRulers = useConfig(state => state.toggleRulers);- const toggleCollapseButton = useConfig(state => state.toggleCollapseButton);- const toggleImagePreview = useConfig(state => state.toggleImagePreview);-- const gesturesEnabled = useConfig(state => state.gesturesEnabled);- const childrenCountVisible = useConfig(state => state.childrenCountVisible);- const darkmodeEnabled = useConfig(state => state.darkmodeEnabled);- const rulersEnabled = useConfig(state => state.rulersEnabled);- const collapseButtonVisible = useConfig(state => state.collapseButtonVisible);- const imagePreviewEnabled = useConfig(state => state.imagePreviewEnabled);-- return (- <Menu shadow="md" trigger="click" closeOnItemClick={false} withArrow>- <Menu.Target>- <StyledToolElement>- <Flex gap={4}>- <MdSettings size="18" />- </Flex>- </StyledToolElement>- </Menu.Target>- <Menu.Dropdown>- <Menu.Item- leftSection={<BsCheck2 opacity={rulersEnabled ? 100 : 0} />}- onClick={() => {- toggleRulers(!rulersEnabled);- gaEvent("toggle_rulers", { label: rulersEnabled ? "on" : "off" });- }}- >- <Text size="xs">Rulers</Text>- </Menu.Item>- <Menu.Item- leftSection={<BsCheck2 opacity={gesturesEnabled ? 100 : 0} />}- onClick={() => {- toggleGestures(!gesturesEnabled);- gaEvent("toggle_gestures", { label: gesturesEnabled ? "on" : "off" });- }}- >- <Text size="xs">Trackpad Gestures</Text>- </Menu.Item>- <Menu.Item- leftSection={<BsCheck2 opacity={childrenCountVisible ? 100 : 0} />}- onClick={() => {- toggleChildrenCount(!childrenCountVisible);- gaEvent("toggle_children_count", { label: childrenCountVisible ? "on" : "off" });- }}- >- <Text size="xs">Item Count</Text>- </Menu.Item>- <Menu.Item- leftSection={<BsCheck2 opacity={imagePreviewEnabled ? 100 : 0} />}- onClick={() => {- toggleImagePreview(!imagePreviewEnabled);- gaEvent("toggle_image_preview", { label: imagePreviewEnabled ? "on" : "off" });- }}- >- <Text size="xs">Image Link Preview</Text>- </Menu.Item>- <Menu.Item- leftSection={<BsCheck2 opacity={collapseButtonVisible ? 100 : 0} />}- onClick={() => {- toggleCollapseButton(!collapseButtonVisible);- gaEvent("toggle_expand_collapse", { label: collapseButtonVisible ? "on" : "off" });- }}- >- <Text size="xs">Show Expand/Collapse</Text>- </Menu.Item>- <Menu.Item- leftSection={<BsCheck2 opacity={darkmodeEnabled ? 100 : 0} />}- onClick={() => {- toggleDarkMode(!darkmodeEnabled);- gaEvent("toggle_dark_mode", { label: darkmodeEnabled ? "on" : "off" });- }}- >- <Text size="xs">Dark Mode</Text>- </Menu.Item>- </Menu.Dropdown>- </Menu>- );-};diff --git a/src/features/editor/Toolbar/SearchInput.tsx b/src/features/editor/Toolbar/SearchInput.tsxindex 3cbe3449..054fb8eb 100644--- a/src/features/editor/Toolbar/SearchInput.tsx+++ b/src/features/editor/Toolbar/SearchInput.tsx@@ -9,6 +9,7 @@ export const SearchInput = () => {return (<TextInput+ variant="unstyled"type="search"size="xs"id="search-node"@@ -29,6 +30,7 @@ export const SearchInput = () => {</Flex>)}+ style={{ borderBottom: "1px solid gray" }}/>);};diff --git a/src/features/editor/Toolbar/ViewMenu.tsx b/src/features/editor/Toolbar/ViewMenu.tsxindex 48a777ec..946efe6a 100644--- a/src/features/editor/Toolbar/ViewMenu.tsx+++ b/src/features/editor/Toolbar/ViewMenu.tsx@@ -1,81 +1,21 @@import React from "react";-import { Menu, Flex, Text, SegmentedControl } from "@mantine/core";-import { useHotkeys, useSessionStorage } from "@mantine/hooks";-import styled from "styled-components";+import { Menu, Flex, SegmentedControl, Text } from "@mantine/core";+import { useSessionStorage } from "@mantine/hooks";import { event as gaEvent } from "nextjs-google-analytics";-import toast from "react-hot-toast";+import { BsCheck2 } from "react-icons/bs";import { CgChevronDown } from "react-icons/cg";-import { TiFlowMerge } from "react-icons/ti";-import { VscExpandAll, VscCollapseAll, VscTarget } from "react-icons/vsc";import { ViewMode } from "../../../enums/viewMode.enum";-import useToggleHide from "../../../hooks/useToggleHide";-import type { LayoutDirection } from "../../../types/graph";-import useGraph from "../views/GraphView/stores/useGraph";+import useConfig from "../../../store/useConfig";import { StyledToolElement } from "./styles";-const StyledFlowIcon = styled(TiFlowMerge)<{ rotate: number }>`- transform: rotate(${({ rotate }) => `${rotate}deg`});-`;--const getNextDirection = (direction: LayoutDirection) => {- if (direction === "RIGHT") return "DOWN";- if (direction === "DOWN") return "LEFT";- if (direction === "LEFT") return "UP";- return "RIGHT";-};--const rotateLayout = (direction: LayoutDirection) => {- if (direction === "LEFT") return 90;- if (direction === "UP") return 180;- if (direction === "RIGHT") return 270;- return 360;-};-export const ViewMenu = () => {- const { validateHiddenNodes } = useToggleHide();- const [coreKey, setCoreKey] = React.useState("CTRL");- const setDirection = useGraph(state => state.setDirection);- const direction = useGraph(state => state.direction);- const expandGraph = useGraph(state => state.expandGraph);- const collapseGraph = useGraph(state => state.collapseGraph);- const focusFirstNode = useGraph(state => state.focusFirstNode);- const graphCollapsed = useGraph(state => state.graphCollapsed);+ const darkmodeEnabled = useConfig(state => state.darkmodeEnabled);+ const toggleDarkMode = useConfig(state => state.toggleDarkMode);const [viewMode, setViewMode] = useSessionStorage({key: "viewMode",defaultValue: ViewMode.Graph,});- const toggleDirection = () => {- const nextDirection = getNextDirection(direction || "RIGHT");- if (setDirection) setDirection(nextDirection);- };-- const toggleExpandCollapseGraph = () => {- if (graphCollapsed) expandGraph();- else collapseGraph();-- validateHiddenNodes();- toast(`${graphCollapsed ? "Expanded" : "Collapsed"} graph.`);- };-- useHotkeys([- ["mod+shift+d", toggleDirection],- ["mod+shift+c", toggleExpandCollapseGraph],- [- "mod+f",- () => {- const input = document.querySelector("#search-node") as HTMLInputElement;- input.focus();- },- ],- ]);-- React.useEffect(() => {- if (typeof window !== "undefined") {- setCoreKey(navigator.userAgent.indexOf("Mac OS X") ? "⌘" : "CTRL");- }- }, []);-return (<Menu shadow="md" closeOnItemClick={false} withArrow><Menu.Target>@@ -87,8 +27,9 @@ export const ViewMenu = () => {</Menu.Target><Menu.Dropdown><SegmentedControl- miw={205}size="xs"+ miw="120"+ w="100%"value={viewMode}onChange={e => {setViewMode(e as ViewMode);@@ -99,45 +40,18 @@ export const ViewMenu = () => {{ value: ViewMode.Tree, label: "Tree" },]}fullWidth+ mb="4"/>- {viewMode === ViewMode.Graph && (- <>- <Menu.Item- mt="xs"- fz={12}- onClick={() => {- toggleDirection();- gaEvent("rotate_layout", { label: direction });- }}- leftSection={<StyledFlowIcon rotate={rotateLayout(direction || "RIGHT")} />}- rightSection={- <Text ml="md" fz={10} c="dimmed">- {coreKey} Shift D- </Text>- }- >- Rotate Layout- </Menu.Item>- <Menu.Item- fz={12}- onClick={() => {- toggleExpandCollapseGraph();- gaEvent("expand_collapse_graph", { label: graphCollapsed ? "expand" : "collapse" });- }}- leftSection={graphCollapsed ? <VscExpandAll /> : <VscCollapseAll />}- rightSection={- <Text ml="md" fz={10} c="dimmed">- {coreKey} Shift C- </Text>- }- >- {graphCollapsed ? "Expand" : "Collapse"} Graph- </Menu.Item>- <Menu.Item fz={12} onClick={focusFirstNode} leftSection={<VscTarget />}>- Focus to First Node- </Menu.Item>- </>- )}+ <Menu.Divider />+ <Menu.Item+ leftSection={<BsCheck2 opacity={darkmodeEnabled ? 100 : 0} />}+ onClick={() => {+ toggleDarkMode(!darkmodeEnabled);+ gaEvent("toggle_dark_mode", { label: darkmodeEnabled ? "on" : "off" });+ }}+ >+ <Text size="xs">Dark Mode</Text>+ </Menu.Item></Menu.Dropdown></Menu>);diff --git a/src/features/editor/Toolbar/ZoomMenu.tsx b/src/features/editor/Toolbar/ZoomMenu.tsxdeleted file mode 100644index b8815e54..00000000--- a/src/features/editor/Toolbar/ZoomMenu.tsx+++ /dev/null@@ -1,103 +0,0 @@-import React from "react";-import { Menu, Flex, Input, Text } from "@mantine/core";-import { getHotkeyHandler, useHotkeys } from "@mantine/hooks";-import { event as gaEvent } from "nextjs-google-analytics";-import { CgChevronDown } from "react-icons/cg";-import useGraph from "../views/GraphView/stores/useGraph";-import { StyledToolElement } from "./styles";--export const ZoomMenu = () => {- const zoomIn = useGraph(state => state.zoomIn);- const zoomOut = useGraph(state => state.zoomOut);- const centerView = useGraph(state => state.centerView);- const setZoomFactor = useGraph(state => state.setZoomFactor);-- const zoomFactor = useGraph(state => state.viewPort?.zoomFactor || 1);- const [tempZoomValue, setTempZoomValue] = React.useState(zoomFactor);-- React.useEffect(() => {- if (!Number.isNaN(zoomFactor)) setTempZoomValue(zoomFactor);- }, [zoomFactor]);-- useHotkeys([- ["shift+Digit0", () => setZoomFactor(100 / 100)],- ["shift+Digit1", centerView],- ]);-- return (- <Menu shadow="md" trigger="click" closeOnItemClick={false} withArrow>- <Menu.Target>- <StyledToolElement onClick={() => gaEvent("show_zoom_menu")}>- <Flex gap={4} align="center" justify="center" miw="50">- {Math.round(zoomFactor * 100)}%- <CgChevronDown />- </Flex>- </StyledToolElement>- </Menu.Target>- <Menu.Dropdown>- <Menu.Item>- <Input- type="number"- value={Math.round(tempZoomValue * 100)}- onChange={e => setTempZoomValue(e.currentTarget.valueAsNumber / 100)}- onKeyDown={getHotkeyHandler([["Enter", () => setZoomFactor(tempZoomValue)]])}- size="xs"- rightSection="%"- />- </Menu.Item>- <Menu.Item- rightSection="+"- onClick={() => {- zoomIn();- gaEvent("zoom_in");- }}- >- <Text size="xs">Zoom in</Text>- </Menu.Item>- <Menu.Item- rightSection="-"- onClick={() => {- zoomOut();- gaEvent("zoom_out");- }}- >- <Text size="xs">Zoom out</Text>- </Menu.Item>- <Menu.Item- rightSection="⇧ 1"- onClick={() => {- centerView();- gaEvent("center_view");- }}- >- <Text size="xs">Zoom to fit</Text>- </Menu.Item>- <Menu.Item- onClick={() => {- setZoomFactor(50 / 100);- gaEvent("zoom_50%");- }}- >- <Text size="xs">Zoom to %50</Text>- </Menu.Item>- <Menu.Item- rightSection="⇧ 0"- onClick={() => {- setZoomFactor(100 / 100);- gaEvent("zoom_100%");- }}- >- <Text size="xs">Zoom to %100</Text>- </Menu.Item>- <Menu.Item- onClick={() => {- setZoomFactor(200 / 100);- gaEvent("zoom_200%");- }}- >- <Text size="xs">Zoom to %200</Text>- </Menu.Item>- </Menu.Dropdown>- </Menu>- );-};diff --git a/src/features/editor/Toolbar/index.tsx b/src/features/editor/Toolbar/index.tsxindex 8c5d8d60..5814f0ec 100644--- a/src/features/editor/Toolbar/index.tsx+++ b/src/features/editor/Toolbar/index.tsx@@ -5,18 +5,14 @@ import styled from "styled-components";import toast from "react-hot-toast";import { AiOutlineFullscreen } from "react-icons/ai";import { FaGithub } from "react-icons/fa6";-import { FiDownload } from "react-icons/fi";import { type FileFormat, formats } from "../../../enums/file.enum";import { JSONCrackLogo } from "../../../layout/JsonCrackLogo";import useFile from "../../../store/useFile";import useModal from "../../../store/useModal";import { FileMenu } from "./FileMenu";import { Logo } from "./Logo";-import { OptionsMenu } from "./OptionsMenu";-import { SearchInput } from "./SearchInput";import { ToolsMenu } from "./ToolsMenu";import { ViewMenu } from "./ViewMenu";-import { ZoomMenu } from "./ZoomMenu";import { StyledToolElement } from "./styles";const StyledTools = styled.div`@@ -87,37 +83,26 @@ export const Toolbar = ({ isWidget = false }: ToolbarProps) => {<Group gap="6" justify="right" w="100%" style={{ flexWrap: "nowrap" }}>{!isWidget && (<Button- variant="light"- color="gray"+ variant="default"size="compact-sm"fz="12"fw="600"- mr="6"onClick={() => setVisible("UpgradeModal", true)}>JSON Crack v2.0 🔥</Button>)}- <SearchInput />{!isWidget && (- <>- <StyledToolElement- title="Save as Image"- onClick={() => setVisible("DownloadModal", true)}- >- <FiDownload size="18" />+ <Link href="https://github.com/AykutSarac/jsoncrack.com" rel="noopener" target="_blank">+ <StyledToolElement title="GitHub">+ <FaGithub size="18" /></StyledToolElement>- <ZoomMenu />- <Link href="https://github.com/AykutSarac/jsoncrack.com" rel="noopener" target="_blank">- <StyledToolElement title="GitHub">- <FaGithub size="18" />- </StyledToolElement>- </Link>- <OptionsMenu />- <StyledToolElement title="Fullscreen" $hide={isWidget} onClick={fullscreenBrowser}>- <AiOutlineFullscreen size="18" />- </StyledToolElement>- </>+ </Link>+ )}+ {!isWidget && (+ <StyledToolElement title="Fullscreen" $hide={isWidget} onClick={fullscreenBrowser}>+ <AiOutlineFullscreen size="18" />+ </StyledToolElement>)}</Group></StyledTools>diff --git a/src/features/editor/views/GraphView/OptionsMenu.tsx b/src/features/editor/views/GraphView/OptionsMenu.tsxnew file mode 100644index 00000000..8d85e356--- /dev/null+++ b/src/features/editor/views/GraphView/OptionsMenu.tsx@@ -0,0 +1,218 @@+import React from "react";+import { ActionIcon, Button, Flex, Menu, Text } from "@mantine/core";+import { useHotkeys } from "@mantine/hooks";+import styled from "styled-components";+import { event as gaEvent } from "nextjs-google-analytics";+import { BsCheck2 } from "react-icons/bs";+import { LuChevronRight, LuImageDown, LuMenu } from "react-icons/lu";+import { TiFlowMerge } from "react-icons/ti";+import { VscExpandAll, VscCollapseAll } from "react-icons/vsc";+import useToggleHide from "../../../../hooks/useToggleHide";+import useConfig from "../../../../store/useConfig";+import useModal from "../../../../store/useModal";+import type { LayoutDirection } from "../../../../types/graph";+import { SearchInput } from "../../Toolbar/SearchInput";+import useGraph from "./stores/useGraph";++const StyledFlowIcon = styled(TiFlowMerge)<{ rotate: number }>`+ transform: rotate(${({ rotate }) => `${rotate}deg`});+`;++const getNextDirection = (direction: LayoutDirection) => {+ if (direction === "RIGHT") return "DOWN";+ if (direction === "DOWN") return "LEFT";+ if (direction === "LEFT") return "UP";+ return "RIGHT";+};++const rotateLayout = (direction: LayoutDirection) => {+ if (direction === "LEFT") return 90;+ if (direction === "UP") return 180;+ if (direction === "RIGHT") return 270;+ return 360;+};++export const OptionsMenu = ({ isWidget = false }) => {+ const toggleGestures = useConfig(state => state.toggleGestures);+ const toggleChildrenCount = useConfig(state => state.toggleChildrenCount);+ const toggleRulers = useConfig(state => state.toggleRulers);+ const toggleCollapseButton = useConfig(state => state.toggleCollapseButton);+ const toggleImagePreview = useConfig(state => state.toggleImagePreview);+ const gesturesEnabled = useConfig(state => state.gesturesEnabled);+ const childrenCountVisible = useConfig(state => state.childrenCountVisible);+ const rulersEnabled = useConfig(state => state.rulersEnabled);+ const collapseButtonVisible = useConfig(state => state.collapseButtonVisible);+ const imagePreviewEnabled = useConfig(state => state.imagePreviewEnabled);+ const { validateHiddenNodes } = useToggleHide();+ const setDirection = useGraph(state => state.setDirection);+ const direction = useGraph(state => state.direction);+ const expandGraph = useGraph(state => state.expandGraph);+ const collapseGraph = useGraph(state => state.collapseGraph);+ const graphCollapsed = useGraph(state => state.graphCollapsed);+ const setVisible = useModal(state => state.setVisible);+ const [coreKey, setCoreKey] = React.useState("CTRL");++ const toggleDirection = () => {+ const nextDirection = getNextDirection(direction || "RIGHT");+ if (setDirection) setDirection(nextDirection);+ };++ const toggleExpandCollapseGraph = () => {+ if (graphCollapsed) expandGraph();+ else collapseGraph();++ validateHiddenNodes();+ };++ useHotkeys(+ [+ ["mod+shift+d", toggleDirection],+ ["mod+shift+c", toggleExpandCollapseGraph],+ [+ "mod+f",+ () => {+ const input = document.querySelector("#search-node") as HTMLInputElement;+ input.focus();+ },+ ],+ ],+ []+ );++ React.useEffect(() => {+ if (typeof window !== "undefined") {+ setCoreKey(navigator.userAgent.indexOf("Mac OS X") ? "⌘" : "CTRL");+ }+ }, []);++ return (+ <Flex+ gap="xs"+ align="center"+ style={{+ position: "absolute",+ bottom: "10px",+ left: "10px",+ zIndex: 100,+ }}+ >+ <Menu withArrow>+ <Menu.Target>+ <ActionIcon variant="light" color="gray">+ <LuMenu />+ </ActionIcon>+ </Menu.Target>+ <Menu.Dropdown>+ <Menu.Item+ leftSection={<LuImageDown color="gray" />}+ onClick={() => setVisible("DownloadModal", true)}+ >+ <Flex fz="xs" justify="space-between" gap="md">+ <Text fz="xs">Export as image</Text>+ <Text ml="md" fz={10} c="dimmed">+ {coreKey} + S+ </Text>+ </Flex>+ </Menu.Item>+ <Menu.Item+ fz={12}+ onClick={() => {+ toggleDirection();+ gaEvent("rotate_layout", { label: direction });+ }}+ leftSection={<StyledFlowIcon rotate={rotateLayout(direction || "RIGHT")} />}+ rightSection={+ <Text ml="md" fz={10} c="dimmed">+ {coreKey} Shift D+ </Text>+ }+ closeMenuOnClick={false}+ >+ Rotate Layout+ </Menu.Item>+ <Menu.Item+ fz={12}+ onClick={() => {+ toggleExpandCollapseGraph();+ gaEvent("expand_collapse_graph", { label: graphCollapsed ? "expand" : "collapse" });+ }}+ leftSection={graphCollapsed ? <VscExpandAll /> : <VscCollapseAll />}+ rightSection={+ <Text ml="md" fz={10} c="dimmed">+ {coreKey} Shift C+ </Text>+ }+ >+ {graphCollapsed ? "Expand" : "Collapse"} Graph+ </Menu.Item>+ <Menu.Divider />+ <Menu position="right" trigger="hover" offset={0}>+ <Menu.Target>+ <Button+ variant="subtle"+ size="xs"+ color="text"+ fullWidth+ fw="400"+ rightSection={<LuChevronRight />}+ styles={{ root: { paddingInline: 11 }, inner: { justifyContent: "space-between" } }}+ >+ View Options+ </Button>+ </Menu.Target>+ <Menu.Dropdown>+ <Menu.Item+ leftSection={<BsCheck2 opacity={rulersEnabled ? 100 : 0} />}+ onClick={() => {+ toggleRulers(!rulersEnabled);+ gaEvent("toggle_rulers", { label: rulersEnabled ? "on" : "off" });+ }}+ >+ <Text size="xs">Rulers</Text>+ </Menu.Item>+ <Menu.Item+ leftSection={<BsCheck2 opacity={gesturesEnabled ? 100 : 0} />}+ onClick={() => {+ toggleGestures(!gesturesEnabled);+ gaEvent("toggle_gestures", { label: gesturesEnabled ? "on" : "off" });+ }}+ >+ <Text size="xs">Trackpad Gestures</Text>+ </Menu.Item>+ <Menu.Item+ leftSection={<BsCheck2 opacity={childrenCountVisible ? 100 : 0} />}+ onClick={() => {+ toggleChildrenCount(!childrenCountVisible);+ gaEvent("toggle_children_count", { label: childrenCountVisible ? "on" : "off" });+ }}+ >+ <Text size="xs">Item Count</Text>+ </Menu.Item>+ <Menu.Item+ leftSection={<BsCheck2 opacity={imagePreviewEnabled ? 100 : 0} />}+ onClick={() => {+ toggleImagePreview(!imagePreviewEnabled);+ gaEvent("toggle_image_preview", { label: imagePreviewEnabled ? "on" : "off" });+ }}+ >+ <Text size="xs">Image Link Preview</Text>+ </Menu.Item>+ <Menu.Item+ leftSection={<BsCheck2 opacity={collapseButtonVisible ? 100 : 0} />}+ onClick={() => {+ toggleCollapseButton(!collapseButtonVisible);+ gaEvent("toggle_expand_collapse", {+ label: collapseButtonVisible ? "on" : "off",+ });+ }}+ >+ <Text size="xs">Show Expand/Collapse</Text>+ </Menu.Item>+ </Menu.Dropdown>+ </Menu>+ </Menu.Dropdown>+ </Menu>+ {!isWidget && <SearchInput />}+ </Flex>+ );+};diff --git a/src/features/editor/views/GraphView/ZoomControl.tsx b/src/features/editor/views/GraphView/ZoomControl.tsxnew file mode 100644index 00000000..3e6aa0de--- /dev/null+++ b/src/features/editor/views/GraphView/ZoomControl.tsx@@ -0,0 +1,75 @@+import React from "react";+import { ActionIcon, Flex } from "@mantine/core";+import { useHotkeys } from "@mantine/hooks";+import { event as gaEvent } from "nextjs-google-analytics";+import { LuFocus, LuMaximize, LuMinus, LuPlus } from "react-icons/lu";+import useGraph from "./stores/useGraph";++export const ZoomControl = () => {+ const zoomIn = useGraph(state => state.zoomIn);+ const zoomOut = useGraph(state => state.zoomOut);+ const centerView = useGraph(state => state.centerView);+ const focusFirstNode = useGraph(state => state.focusFirstNode);++ useHotkeys(+ [+ ["mod+[plus]", () => zoomIn],+ ["mod+[minus]", () => zoomOut],+ ["shift+Digit1", centerView],+ ],+ []+ );++ return (+ <Flex+ align="center"+ gap="xs"+ style={{+ position: "absolute",+ bottom: "10px",+ right: "10px",+ alignItems: "start",+ zIndex: 100,+ }}+ >+ <ActionIcon+ variant="default"+ onClick={() => {+ focusFirstNode();+ gaEvent("focus_first_node");+ }}+ >+ <LuFocus />+ </ActionIcon>+ <ActionIcon+ variant="default"+ onClick={() => {+ centerView();+ gaEvent("center_view");+ }}+ >+ <LuMaximize />+ </ActionIcon>+ <ActionIcon.Group borderWidth={0}>+ <ActionIcon+ variant="default"+ onClick={() => {+ zoomOut();+ gaEvent("zoom_out");+ }}+ >+ <LuMinus />+ </ActionIcon>+ <ActionIcon+ variant="default"+ onClick={() => {+ zoomIn();+ gaEvent("zoom_in");+ }}+ >+ <LuPlus />+ </ActionIcon>+ </ActionIcon.Group>+ </Flex>+ );+};diff --git a/src/features/editor/views/GraphView/index.tsx b/src/features/editor/views/GraphView/index.tsxindex f847e439..7861d3f2 100644--- a/src/features/editor/views/GraphView/index.tsx+++ b/src/features/editor/views/GraphView/index.tsx@@ -11,6 +11,8 @@ import useConfig from "../../../../store/useConfig";import { CustomEdge } from "./CustomEdge";import { CustomNode } from "./CustomNode";import { NotSupported } from "./NotSupported";+import { OptionsMenu } from "./OptionsMenu";+import { ZoomControl } from "./ZoomControl";import useGraph from "./stores/useGraph";const StyledEditorWrapper = styled.div<{ $widget: boolean; $showRulers: boolean }>`@@ -174,6 +176,8 @@ export const GraphView = ({ isWidget = false }: GraphProps) => {return (<><LoadingOverlay visible={loading} />+ <OptionsMenu isWidget={isWidget} />+ <ZoomControl /><StyledEditorWrapper$widget={isWidget}onContextMenu={e => e.preventDefault()}