✨ Innovative and open-source visualization application that transforms various data formats, such as JSON, YAML, XML and CSV into interactive graphs.
feat: refactor SearchInput component and implement Toolbar with enhanced functionality
AykutSarac5f4f34184c9f
diff --git a/apps/www/src/features/editor/Toolbar/SearchInput.tsx b/apps/www/src/features/editor/Toolbar/SearchInput.tsxindex cbda77fc..7b131097 100644--- a/apps/www/src/features/editor/Toolbar/SearchInput.tsx+++ b/apps/www/src/features/editor/Toolbar/SearchInput.tsx@@ -1,40 +1,201 @@import React from "react";-import { Flex, Text, TextInput } from "@mantine/core";-import { getHotkeyHandler } from "@mantine/hooks";-import { useOs } from "@mantine/hooks";+import { ActionIcon, Text, TextInput, Tooltip } from "@mantine/core";+import { getHotkeyHandler, useOs } from "@mantine/hooks";+import styled from "styled-components";import { AiOutlineSearch } from "react-icons/ai";+import { LuChevronDown, LuChevronUp, LuX } from "react-icons/lu";import { useFocusNode } from "../../../hooks/useFocusNode";-export const SearchInput = () => {- const [searchValue, setValue, skip, nodeCount, currentNode] = useFocusNode();+interface SearchInputProps {+ onClose?: () => void;+}++const Wrapper = styled.div`+ display: flex;+ flex-direction: column;+ gap: 6px;+ min-width: 320px;+`;++const Row = styled.div`+ display: flex;+ align-items: center;+ gap: 4px;+ padding: 2px 4px 2px 8px;+ border-radius: 8px;+ background: ${({ theme }) =>+ theme.BACKGROUND_SECONDARY === "#f2f3f5"+ ? "rgba(15, 23, 42, 0.04)"+ : "rgba(255, 255, 255, 0.05)"};+ border: 1px solid+ ${({ theme }) =>+ theme.BACKGROUND_SECONDARY === "#f2f3f5"+ ? "rgba(15, 23, 42, 0.08)"+ : "rgba(255, 255, 255, 0.08)"};+ transition: border-color 120ms ease;++ &:focus-within {+ border-color: ${({ theme }) =>+ theme.BACKGROUND_SECONDARY === "#f2f3f5"+ ? "rgba(59, 130, 246, 0.6)"+ : "rgba(96, 165, 250, 0.6)"};+ }+`;++const Counter = styled.div<{ $none?: boolean }>`+ font-size: 11px;+ font-weight: 500;+ color: ${({ theme, $none }) =>+ $none+ ? theme.BACKGROUND_SECONDARY === "#f2f3f5"+ ? "#dc2626"+ : "#f87171"+ : theme.BACKGROUND_SECONDARY === "#f2f3f5"+ ? "rgba(15, 23, 42, 0.55)"+ : "rgba(255, 255, 255, 0.55)"};+ white-space: nowrap;+ padding: 0 4px;+ letter-spacing: 0.2px;+`;++const Hint = styled.div`+ display: flex;+ justify-content: space-between;+ font-size: 10.5px;+ color: ${({ theme }) =>+ theme.BACKGROUND_SECONDARY === "#f2f3f5"+ ? "rgba(15, 23, 42, 0.5)"+ : "rgba(255, 255, 255, 0.45)"};+ padding: 0 2px;+ letter-spacing: 0.2px;++ kbd {+ display: inline-block;+ padding: 1px 5px;+ margin: 0 2px;+ font-size: 10px;+ font-family: inherit;+ color: inherit;+ background: ${({ theme }) =>+ theme.BACKGROUND_SECONDARY === "#f2f3f5"+ ? "rgba(15, 23, 42, 0.06)"+ : "rgba(255, 255, 255, 0.08)"};+ border: 1px solid+ ${({ theme }) =>+ theme.BACKGROUND_SECONDARY === "#f2f3f5"+ ? "rgba(15, 23, 42, 0.1)"+ : "rgba(255, 255, 255, 0.08)"};+ border-radius: 3px;+ line-height: 1;+ }+`;++export const SearchInput = ({ onClose }: SearchInputProps) => {+ const { value, setValue, next, prev, clear, nodeCount, selectedNode } = useFocusNode();const os = useOs();+ const inputRef = React.useRef<HTMLInputElement>(null);const coreKey = os === "macos" ? "⌘" : "Ctrl";+ const hasValue = value.length > 0;+ const hasMatches = nodeCount > 0;+ const noResults = hasValue && !hasMatches;++ React.useEffect(() => {+ inputRef.current?.focus();+ }, []);++ const handleClear = () => {+ clear();+ inputRef.current?.focus();+ };++ const handleEscape = () => {+ if (hasValue) {+ clear();+ return;+ }+ onClose?.();+ };return (- <TextInput- variant="unstyled"- type="search"- size="xs"- id="search-node"- w={180}- value={searchValue}- onChange={e => setValue(e.currentTarget.value)}- placeholder={`Search Node (${coreKey} + F)`}- autoComplete="off"- autoCorrect="off"- onKeyDown={getHotkeyHandler([["Enter", skip]])}- leftSection={<AiOutlineSearch />}- rightSection={- searchValue && (- <Flex h={30} align="center">- <Text size="xs" c="dimmed" pr="md">- {searchValue && `${nodeCount}/${nodeCount > 0 ? currentNode + 1 : "0"}`}- </Text>- </Flex>- )- }- style={{ borderBottom: "1px solid gray" }}- />+ <Wrapper>+ <Row>+ <AiOutlineSearch size={14} opacity={0.6} />+ <TextInput+ ref={inputRef}+ variant="unstyled"+ type="search"+ size="xs"+ id="search-node"+ flex={1}+ value={value}+ onChange={e => setValue(e.currentTarget.value)}+ placeholder={`Search nodes (${coreKey}+F)`}+ autoComplete="off"+ autoCorrect="off"+ spellCheck={false}+ onKeyDown={getHotkeyHandler([+ ["Enter", next],+ ["shift+Enter", prev],+ ["Escape", handleEscape],+ ])}+ styles={{+ input: { minHeight: 26, height: 26, padding: "0 4px" },+ }}+ />+ {hasValue && (+ <Counter $none={noResults}>+ {noResults ? "No matches" : `${selectedNode + 1} / ${nodeCount}`}+ </Counter>+ )}+ <Tooltip label="Previous (⇧⏎)" position="top" withArrow openDelay={500}>+ <ActionIcon+ aria-label="previous match"+ size="sm"+ radius="sm"+ variant="subtle"+ color="gray"+ onClick={prev}+ disabled={!hasMatches}+ >+ <LuChevronUp size={14} />+ </ActionIcon>+ </Tooltip>+ <Tooltip label="Next (⏎)" position="top" withArrow openDelay={500}>+ <ActionIcon+ aria-label="next match"+ size="sm"+ radius="sm"+ variant="subtle"+ color="gray"+ onClick={next}+ disabled={!hasMatches}+ >+ <LuChevronDown size={14} />+ </ActionIcon>+ </Tooltip>+ <Tooltip label="Clear (Esc)" position="top" withArrow openDelay={500}>+ <ActionIcon+ aria-label="clear search"+ size="sm"+ radius="sm"+ variant="subtle"+ color="gray"+ onClick={handleClear}+ disabled={!hasValue}+ >+ <LuX size={14} />+ </ActionIcon>+ </Tooltip>+ </Row>+ <Hint>+ <Text component="span" inherit>+ <kbd>↵</kbd> next <kbd>⇧ ↵</kbd> prev+ </Text>+ <Text component="span" inherit>+ <kbd>Esc</kbd> close+ </Text>+ </Hint>+ </Wrapper>);};diff --git a/apps/www/src/features/editor/views/GraphView/OptionsMenu.tsx b/apps/www/src/features/editor/views/GraphView/OptionsMenu.tsxdeleted file mode 100644index eb799cdd..00000000--- a/apps/www/src/features/editor/views/GraphView/OptionsMenu.tsx+++ /dev/null@@ -1,148 +0,0 @@-import React from "react";-import { ActionIcon, Flex, Menu, Text } from "@mantine/core";-import { useHotkeys } from "@mantine/hooks";-import styled from "styled-components";-import type { LayoutDirection } from "jsoncrack-react";-import { event as gaEvent } from "nextjs-google-analytics";-import { BsCheck2 } from "react-icons/bs";-import { LuImageDown, LuMenu } from "react-icons/lu";-import { TiFlowMerge } from "react-icons/ti";-import useConfig from "../../../../store/useConfig";-import { useModal } from "../../../../store/useModal";-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 = () => {- const toggleGestures = useConfig(state => state.toggleGestures);- const toggleRulers = useConfig(state => state.toggleRulers);- const gesturesEnabled = useConfig(state => state.gesturesEnabled);- const rulersEnabled = useConfig(state => state.rulersEnabled);- const setDirection = useGraph(state => state.setDirection);- const direction = useGraph(state => state.direction);- const setVisible = useModal(state => state.setVisible);- const [coreKey, setCoreKey] = React.useState("CTRL");-- const toggleDirection = () => {- const nextDirection = getNextDirection(direction || "RIGHT");- if (setDirection) setDirection(nextDirection);- };-- useHotkeys(- [- ["mod+shift+d", toggleDirection],- [- "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",- top: "10px",- left: "10px",- zIndex: 100,- }}- >- <Menu withArrow>- <Menu.Target>- <ActionIcon aria-label="actions" size="lg" color="gray" variant="light">- <LuMenu size="18" />- </ActionIcon>- </Menu.Target>- <Menu.Dropdown>- <Menu.Item- fz="sm"- leftSection={<LuImageDown color="gray" />}- onClick={() => setVisible("DownloadModal", true)}- >- <Flex justify="space-between" gap="md">- <Text inherit>Export</Text>- <Text fz="xs" ml="md" c="dimmed">- {coreKey} + S- </Text>- </Flex>- </Menu.Item>- <Menu.Item- fz="sm"- onClick={() => {- toggleDirection();- gaEvent("rotate_layout", { label: direction });- }}- leftSection={- <StyledFlowIcon color="gray" rotate={rotateLayout(direction || "RIGHT")} />- }- rightSection={- <Text fz="xs" ml="md" c="dimmed">- {coreKey} Shift D- </Text>- }- closeMenuOnClick={false}- >- Rotate- </Menu.Item>- <Menu.Divider />- <Menu.Sub position="right" offset={0}>- <Menu.Sub.Target>- <Menu.Sub.Item fz="sm">View Options</Menu.Sub.Item>- </Menu.Sub.Target>- <Menu.Sub.Dropdown>- <Menu.Item- fz="sm"- leftSection={<BsCheck2 opacity={rulersEnabled ? 100 : 0} />}- onClick={() => {- toggleRulers(!rulersEnabled);- gaEvent("toggle_rulers", { label: rulersEnabled ? "on" : "off" });- }}- closeMenuOnClick={false}- >- Rulers- </Menu.Item>- <Menu.Item- fz="sm"- leftSection={<BsCheck2 opacity={gesturesEnabled ? 100 : 0} />}- onClick={() => {- toggleGestures(!gesturesEnabled);- gaEvent("toggle_gestures", { label: gesturesEnabled ? "on" : "off" });- }}- >- Zoom on Scroll- </Menu.Item>- </Menu.Sub.Dropdown>- </Menu.Sub>- </Menu.Dropdown>- </Menu>- </Flex>- );-};diff --git a/apps/www/src/features/editor/views/GraphView/SecureInfo.tsx b/apps/www/src/features/editor/views/GraphView/SecureInfo.tsxindex 85289e3d..9307558b 100644--- a/apps/www/src/features/editor/views/GraphView/SecureInfo.tsx+++ b/apps/www/src/features/editor/views/GraphView/SecureInfo.tsx@@ -15,16 +15,18 @@ export const SecureInfo = () => {<ThemeIconvariant="light"color="teal"- size="36"+ size="32"style={{position: "absolute",- bottom: "10px",- right: "10px",- zIndex: 100,+ bottom: "14px",+ right: "14px",+ zIndex: 3,+ backdropFilter: "blur(12px)",+ boxShadow: "0 2px 8px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(20, 184, 166, 0.15)",}}radius="xl">- <LuShieldCheck size="22" />+ <LuShieldCheck size="18" /></ThemeIcon></Tooltip>);diff --git a/apps/www/src/features/editor/views/GraphView/Toolbar/index.tsx b/apps/www/src/features/editor/views/GraphView/Toolbar/index.tsxnew file mode 100644index 00000000..8a99567c--- /dev/null+++ b/apps/www/src/features/editor/views/GraphView/Toolbar/index.tsx@@ -0,0 +1,296 @@+import React from "react";+import { ActionIcon, Divider, Flex, Menu, Popover, Tooltip } from "@mantine/core";+import { useHotkeys } from "@mantine/hooks";+import styled from "styled-components";+import type { LayoutDirection } from "jsoncrack-react";+import { event as gaEvent } from "nextjs-google-analytics";+import { BsCheck2 } from "react-icons/bs";+import { FaMoon, FaSun } from "react-icons/fa6";+import { LuImageDown, LuMinus, LuPlus, LuSearch, LuSettings2 } from "react-icons/lu";+import { MdFullscreen, MdOutlineCenterFocusStrong } from "react-icons/md";+import { TbArrowsLeftRight } from "react-icons/tb";+import useConfig from "../../../../../store/useConfig";+import { useModal } from "../../../../../store/useModal";+import { SearchInput } from "../../../Toolbar/SearchInput";+import useGraph from "../stores/useGraph";++const StyledToolbar = styled.div`+ position: absolute;+ bottom: 12px;+ left: 50%;+ transform: translateX(-50%);+ z-index: 3;+ display: flex;+ align-items: center;+ padding: 5px;+ border-radius: 14px;+ background: ${({ theme }) =>+ theme.BACKGROUND_SECONDARY === "#f2f3f5"+ ? "rgba(255, 255, 255, 0.72)"+ : "rgba(28, 28, 30, 0.72)"};+ backdrop-filter: blur(20px) saturate(180%);+ -webkit-backdrop-filter: blur(20px) saturate(180%);+ border: 1px solid+ ${({ theme }) =>+ theme.BACKGROUND_SECONDARY === "#f2f3f5"+ ? "rgba(0, 0, 0, 0.06)"+ : "rgba(255, 255, 255, 0.08)"};+ box-shadow:+ ${({ theme }) =>+ theme.BACKGROUND_SECONDARY === "#f2f3f5"+ ? "inset 0 1px 0 rgba(255, 255, 255, 0.9)"+ : "inset 0 1px 0 rgba(255, 255, 255, 0.06)"},+ 0 1px 2px+ ${({ theme }) =>+ theme.BACKGROUND_SECONDARY === "#f2f3f5" ? "rgba(0, 0, 0, 0.04)" : "rgba(0, 0, 0, 0.25)"},+ 0 8px 24px -4px+ ${({ theme }) =>+ theme.BACKGROUND_SECONDARY === "#f2f3f5"+ ? "rgba(15, 23, 42, 0.12)"+ : "rgba(0, 0, 0, 0.45)"};++ [data-mantine-divider] {+ border-color: ${({ theme }) =>+ theme.BACKGROUND_SECONDARY === "#f2f3f5"+ ? "rgba(15, 23, 42, 0.1)"+ : "rgba(255, 255, 255, 0.08)"};+ height: 18px;+ align-self: center;+ }+`;++const getNextDirection = (direction: LayoutDirection): LayoutDirection => {+ if (direction === "RIGHT") return "DOWN";+ if (direction === "DOWN") return "LEFT";+ if (direction === "LEFT") return "UP";+ return "RIGHT";+};++export const Toolbar = () => {+ const zoomIn = useGraph(state => state.zoomIn);+ const zoomOut = useGraph(state => state.zoomOut);+ const centerView = useGraph(state => state.centerView);+ const focusFirstNode = useGraph(state => state.focusFirstNode);+ const direction = useGraph(state => state.direction);+ const setDirection = useGraph(state => state.setDirection);+ const setVisible = useModal(state => state.setVisible);+ const darkmodeEnabled = useConfig(state => state.darkmodeEnabled);+ const toggleDarkMode = useConfig(state => state.toggleDarkMode);+ const gesturesEnabled = useConfig(state => state.gesturesEnabled);+ const toggleGestures = useConfig(state => state.toggleGestures);+ const rulersEnabled = useConfig(state => state.rulersEnabled);+ const toggleRulers = useConfig(state => state.toggleRulers);++ const [searchOpen, setSearchOpen] = React.useState(false);+ const [coreKey, setCoreKey] = React.useState("CTRL");++ React.useEffect(() => {+ if (typeof window !== "undefined") {+ setCoreKey(navigator.userAgent.indexOf("Mac OS X") !== -1 ? "⌘" : "CTRL");+ }+ }, []);++ const handleSearchClick = () => {+ setSearchOpen(true);+ requestAnimationFrame(() => {+ const input = document.querySelector("#search-node") as HTMLInputElement | null;+ input?.focus();+ });+ };++ const toggleDirection = () => {+ setDirection(getNextDirection(direction || "RIGHT"));+ gaEvent("rotate_layout", { label: direction });+ };++ useHotkeys(+ [+ ["mod+[plus]", zoomIn, { usePhysicalKeys: true }],+ ["mod+[minus]", zoomOut, { usePhysicalKeys: true }],+ ["shift+Digit1", focusFirstNode, { usePhysicalKeys: true }],+ ["shift+Digit2", centerView, { usePhysicalKeys: true }],+ ["mod+f", handleSearchClick],+ ["mod+s", () => setVisible("DownloadModal", true)],+ ["mod+shift+d", toggleDirection],+ ],+ []+ );++ return (+ <StyledToolbar>+ <Flex gap={4} align="center">+ <Tooltip label="Center first item (⇧1)" position="top" withArrow openDelay={750}>+ <ActionIcon+ aria-label="center first item"+ size="lg"+ radius="md"+ variant="subtle"+ color="gray"+ onClick={() => {+ focusFirstNode();+ gaEvent("focus_first_node");+ }}+ >+ <MdOutlineCenterFocusStrong size={18} />+ </ActionIcon>+ </Tooltip>++ <Tooltip label="Fit to center (⇧2)" position="top" withArrow openDelay={750}>+ <ActionIcon+ aria-label="fit to center"+ size="lg"+ radius="md"+ variant="subtle"+ color="gray"+ onClick={() => {+ centerView();+ gaEvent("center_view");+ }}+ >+ <MdFullscreen size={20} />+ </ActionIcon>+ </Tooltip>++ <ActionIcon+ aria-label="zoom out"+ size="lg"+ radius="md"+ variant="subtle"+ color="gray"+ onClick={() => {+ zoomOut();+ gaEvent("zoom_out");+ }}+ >+ <LuMinus size={16} />+ </ActionIcon>++ <ActionIcon+ aria-label="zoom in"+ size="lg"+ radius="md"+ variant="subtle"+ color="gray"+ onClick={() => {+ zoomIn();+ gaEvent("zoom_in");+ }}+ >+ <LuPlus size={16} />+ </ActionIcon>++ <Divider orientation="vertical" mx={2} />++ <Tooltip label={`Export (${coreKey}+S)`} position="top" withArrow openDelay={750}>+ <ActionIcon+ aria-label="export"+ size="lg"+ radius="md"+ variant="subtle"+ color="gray"+ onClick={() => setVisible("DownloadModal", true)}+ >+ <LuImageDown size={18} />+ </ActionIcon>+ </Tooltip>++ <Popover+ opened={searchOpen}+ onChange={setSearchOpen}+ position="top"+ withArrow+ shadow="md"+ trapFocus={false}+ closeOnClickOutside+ >+ <Popover.Target>+ <Tooltip label={`Search (${coreKey}+F)`} position="top" withArrow openDelay={750}>+ <ActionIcon+ aria-label="search"+ size="lg"+ radius="md"+ variant="subtle"+ color="gray"+ onClick={() => {+ if (searchOpen) {+ setSearchOpen(false);+ } else {+ handleSearchClick();+ }+ }}+ >+ <LuSearch size={18} />+ </ActionIcon>+ </Tooltip>+ </Popover.Target>+ <Popover.Dropdown p={8}>+ <SearchInput onClose={() => setSearchOpen(false)} />+ </Popover.Dropdown>+ </Popover>++ <Tooltip label="Rotate layout" position="top" withArrow openDelay={750}>+ <ActionIcon+ aria-label="rotate layout"+ size="lg"+ radius="md"+ variant="subtle"+ color="gray"+ onClick={toggleDirection}+ >+ <TbArrowsLeftRight size={18} />+ </ActionIcon>+ </Tooltip>++ <Divider orientation="vertical" mx={2} />++ <Menu trigger="click" position="top-end">+ <Menu.Target>+ <Tooltip label="Preferences" position="top" withArrow openDelay={750}>+ <ActionIcon+ aria-label="preferences"+ size="lg"+ radius="md"+ variant="subtle"+ color="gray"+ >+ <LuSettings2 size={18} />+ </ActionIcon>+ </Tooltip>+ </Menu.Target>+ <Menu.Dropdown>+ <Menu.Item+ fz="sm"+ leftSection={darkmodeEnabled ? <FaSun /> : <FaMoon />}+ onClick={() => toggleDarkMode(!darkmodeEnabled)}+ closeMenuOnClick={false}+ >+ {darkmodeEnabled ? "Light Mode" : "Dark Mode"}+ </Menu.Item>+ <Menu.Item+ fz="sm"+ rightSection={<BsCheck2 display={gesturesEnabled ? "initial" : "none"} />}+ onClick={() => {+ toggleGestures(!gesturesEnabled);+ gaEvent("toggle_gestures", { label: gesturesEnabled ? "on" : "off" });+ }}+ closeMenuOnClick={false}+ >+ Zoom on Scroll+ </Menu.Item>+ <Menu.Item+ fz="sm"+ rightSection={<BsCheck2 display={rulersEnabled ? "initial" : "none"} />}+ onClick={() => {+ toggleRulers(!rulersEnabled);+ gaEvent("toggle_rulers", { label: rulersEnabled ? "on" : "off" });+ }}+ closeMenuOnClick={false}+ >+ Rulers+ </Menu.Item>+ </Menu.Dropdown>+ </Menu>+ </Flex>+ </StyledToolbar>+ );+};diff --git a/apps/www/src/features/editor/views/GraphView/ZoomControl.tsx b/apps/www/src/features/editor/views/GraphView/ZoomControl.tsxdeleted file mode 100644index 084c4ade..00000000--- a/apps/www/src/features/editor/views/GraphView/ZoomControl.tsx+++ /dev/null@@ -1,110 +0,0 @@-import React from "react";-import { ActionIcon, Flex, Tooltip, Text } 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 { SearchInput } from "../../Toolbar/SearchInput";-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, { usePhysicalKeys: true }],- ["mod+[minus]", zoomOut, { usePhysicalKeys: true }],- ["shift+Digit1", focusFirstNode, { usePhysicalKeys: true }],- ["shift+Digit2", centerView, { usePhysicalKeys: true }],- ],- []- );-- return (- <Flex- align="center"- gap="xs"- style={{- position: "absolute",- bottom: "10px",- left: "10px",- alignItems: "start",- zIndex: 100,- }}- >- <ActionIcon.Group borderWidth={0}>- <Tooltip- label={- <Flex fz="xs" gap="md">- <Text fz="xs">Center first item</Text>- <Text fz="xs" c="dimmed">- ⇧ 1- </Text>- </Flex>- }- withArrow- >- <ActionIcon- size="lg"- variant="light"- color="gray"- onClick={() => {- focusFirstNode();- gaEvent("focus_first_node");- }}- >- <LuFocus />- </ActionIcon>- </Tooltip>- <Tooltip- label={- <Flex fz="xs" gap="md">- <Text fz="xs">Fit to center</Text>- <Text fz="xs" c="dimmed">- ⇧ 2- </Text>- </Flex>- }- withArrow- >- <ActionIcon- size="lg"- variant="light"- color="gray"- onClick={() => {- centerView();- gaEvent("center_view");- }}- >- <LuMaximize />- </ActionIcon>- </Tooltip>- <ActionIcon- size="lg"- variant="light"- color="gray"- onClick={() => {- zoomOut();- gaEvent("zoom_out");- }}- >- <LuMinus />- </ActionIcon>- <ActionIcon- size="lg"- variant="light"- color="gray"- onClick={() => {- zoomIn();- gaEvent("zoom_in");- }}- >- <LuPlus />- </ActionIcon>- </ActionIcon.Group>- <SearchInput />- </Flex>- );-};diff --git a/apps/www/src/features/editor/views/GraphView/index.tsx b/apps/www/src/features/editor/views/GraphView/index.tsxindex bda40b81..53e7a560 100644--- a/apps/www/src/features/editor/views/GraphView/index.tsx+++ b/apps/www/src/features/editor/views/GraphView/index.tsx@@ -8,9 +8,8 @@ import useConfig from "../../../../store/useConfig";import useJson from "../../../../store/useJson";import { useModal } from "../../../../store/useModal";import { NotSupported } from "./NotSupported";-import { OptionsMenu } from "./OptionsMenu";import { SecureInfo } from "./SecureInfo";-import { ZoomControl } from "./ZoomControl";+import { Toolbar } from "./Toolbar";import useGraph from "./stores/useGraph";const StyledEditorWrapper = styled.div<{ $widget: boolean }>`@@ -64,9 +63,8 @@ export const GraphView = ({ isWidget = false }: GraphProps) => {return (<Box pos="relative" h="100%" w="100%">- {!isWidget && <OptionsMenu />}{!isWidget && <SecureInfo />}- <ZoomControl />+ {!isWidget && <Toolbar />}<StyledEditorWrapper$widget={isWidget}onContextMenu={event => event.preventDefault()}diff --git a/apps/www/src/hooks/useFocusNode.ts b/apps/www/src/hooks/useFocusNode.tsindex efddeda0..39358201 100644--- a/apps/www/src/hooks/useFocusNode.ts+++ b/apps/www/src/hooks/useFocusNode.ts@@ -9,9 +9,22 @@ export const useFocusNode = () => {const [selectedNode, setSelectedNode] = React.useState(0);const [nodeCount, setNodeCount] = React.useState(0);const [value, setValue] = React.useState("");- const [debouncedValue] = useDebouncedValue(value, 600);+ const [debouncedValue] = useDebouncedValue(value, 300);- const skip = () => setSelectedNode(current => (current + 1) % nodeCount);+ const next = React.useCallback(() => {+ setSelectedNode(current => (nodeCount > 0 ? (current + 1) % nodeCount : 0));+ }, [nodeCount]);++ const prev = React.useCallback(() => {+ setSelectedNode(current => (nodeCount > 0 ? (current - 1 + nodeCount) % nodeCount : 0));+ }, [nodeCount]);++ const clear = React.useCallback(() => {+ setValue("");+ setSelectedNode(0);+ setNodeCount(0);+ cleanupHighlight();+ }, []);React.useEffect(() => {if (!value) {@@ -42,5 +55,5 @@ export const useFocusNode = () => {gaEvent("search_graph");}, [selectedNode, debouncedValue, value, viewPort]);- return [value, setValue, skip, nodeCount, selectedNode] as const;+ return { value, setValue, next, prev, clear, nodeCount, selectedNode };};