// Context menus (design system): the browser's own menu never shows. ContextMenuProvider (main.tsx) prevents every // native `contextmenu`, opens a small Cut / Copy / Paste / Select all menu on text fields and a Copy menu on selected // text, and turns Shift+F10 / the Menu key into a context menu on the focused element. Screens attach menus with // `useContextMenu()`: `
[...entries])}>`. Keyboard: arrows, Home / End, Enter / Space, Esc, // ArrowRight / ArrowLeft for submenus, type-ahead. Logic (placement, moves, type-ahead) in menu-logic.ts. import { createContext, type KeyboardEvent as ReactKeyboardEvent, type MouseEvent as ReactMouseEvent, type ReactNode, useCallback, useContext, useEffect, useLayoutEffect, useId, useRef, useState } from 'react'; import { createPortal } from 'react-dom'; import { t } from '../i18n'; import { copyText } from '../lib/crash'; import { Icon } from './icons'; import { MOD } from './kit'; import { enabled, first, isEditable, isItem, last, type MenuEntry, type MenuInput, type MenuItem, move, placeAt, placeBeside, tidy, typeahead } from './menu-logic'; export type { MenuEntry, MenuInput, MenuItem } from './menu-logic'; interface Open { x: number; y: number; items: MenuEntry[]; from: Element | null; keyboard: boolean } type OpenFn = (x: number, y: number, input: MenuInput, opts?: { from?: Element | null; keyboard?: boolean }) => void; const Ctx = createContext(null); /** Marks a native event a menu handled, so the global fallback leaves it alone. */ const HANDLED = '__sbMenu'; /** Marks the contextmenu event Shift+F10 / the Menu key sent (the menu starts on its first item). */ const BY_KEY = '__sbKey'; /** Props that attach a menu to an element: `