import { Button } from "../../ui"; import { Dialog, DialogContent, DialogHeader, DialogTitle } from "../../ui"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from "../../ui"; import { useMemo } from "react"; import * as React from "react"; import { currentHotkeys, HotkeysMenuData, } from "../../lib/react-utils/use-hotkeys"; import { usePorts } from "../../flow-editor/ports"; import { isMac } from "../.."; export interface HelpBubbleProps {} function hotkeyToBpHotkey(hotkey: { key: string; menuData: HotkeysMenuData }) { return { combo: hotkey.key, label: hotkey.menuData.text, group: hotkey.menuData.group, }; } const groupsOrder = ["Viewport Controls", "Editing", "Selection"]; const mainDocItems = [ { title: "Core Concepts", link: "https://www.flyde.dev/docs/core-concepts/", }, { title: "Integrate With Existing Code", link: "https://www.flyde.dev/docs/integrate-flows/", }, { title: "Creating Custom Nodes", link: "https://www.flyde.dev/docs/custom-nodes/", }, { title: "Trouble-shooting", link: "https://www.flyde.dev/docs/troubleshooting/", }, { title: "Flowcode - Hosted API Builder", link: "https://www.getflowcode.io/?ref=help-menu", }, ]; export function HelpBubble() { const [hotkeysModalOpen, setHotkeysModalOpen] = React.useState(false); const _isMac = useMemo(isMac, []); const bpHotkeys = Array.from(currentHotkeys.entries()).map( ([_keys, menuData]) => { const keys = _keys.split(/,\s*/).find((key) => { return _isMac && key.includes("cmd") ? true : !key.includes("cmd"); }); return hotkeyToBpHotkey({ key: keys!, menuData }); } ); const groupedHotkeys = bpHotkeys.reduce((acc, hotkey) => { if (!acc[hotkey.group]) { acc[hotkey.group] = []; } acc[hotkey.group]!.push(hotkey); return acc; }, {} as { [key: string]: Array> }); const groupsArray = Object.entries(groupedHotkeys).sort((a, b) => { return groupsOrder.indexOf(b[0]) - groupsOrder.indexOf(a[0]); }); const { reportEvent } = usePorts(); return (
{mainDocItems.map((item) => ( { reportEvent("helpMenuItem", { item: item.title }); window.open(item.link, "_blank"); }} > {item.title} ))} { reportEvent("helpMenuItem", { item: "discord" }); window.open("https://discord.gg/x7t4tjZQP8", "_blank"); }} > Discord { setHotkeysModalOpen(true); reportEvent("helpMenuItem", { item: "hotkeys" }); }} > Hotkeys { reportEvent("helpMenuItem", { item: "documentation" }); window.open("https://www.flyde.dev/docs", "_blank"); }} > Full Documentation Keyboard Shortcuts
{groupsArray.map(([group, hotkeys]) => (

{group}

{hotkeys.map((hotkey) => (
{hotkey.label} {hotkey.combo}
))}
))}
); }