'use client'; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog"; import { Separator } from "@/components/ui/separator"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/components/ui/table"; import clsx from "clsx"; import Link from "next/link"; import { useCallback, useRef } from "react"; import { useHotkeys } from "react-hotkeys-hook"; import { useSyntaxGuide } from "../[domain]/components/syntaxGuideProvider"; const LINGUIST_LINK = "https://github.com/github-linguist/linguist/blob/main/lib/linguist/languages.yml"; const CTAGS_LINK = "https://ctags.io/"; export const SyntaxReferenceGuide = () => { const { isOpen, onOpenChanged } = useSyntaxGuide(); const previousFocusedElement = useRef(null); const openDialog = useCallback(() => { previousFocusedElement.current = document.activeElement as HTMLElement; onOpenChanged(true); }, [onOpenChanged]); const closeDialog = useCallback(() => { onOpenChanged(false); // @note: Without requestAnimationFrame, focus was not being returned // to codemirror elements for some reason. requestAnimationFrame(() => { previousFocusedElement.current?.focus(); }); }, [onOpenChanged]); const handleOpenChange = useCallback((isOpen: boolean) => { if (isOpen) { openDialog(); } else { closeDialog(); } }, [closeDialog, openDialog]); useHotkeys("mod+/", (event) => { event.preventDefault(); handleOpenChange(!isOpen); }, { enableOnFormTags: true, enableOnContentEditable: true, description: "Open Syntax Reference Guide", }); return ( Syntax Reference Guide Queries consist of space-seperated regular expressions. Wrapping expressions in {`""`} combines them. By default, a file must have at least one match for each expression to be included. Example Explanation foo Match files with regex /foo/ foo bar Match files with regex /foo/ and /bar/ {`"foo bar"`} Match files with regex /foo bar/

{`Multiple expressions can be or'd together with `}or, negated with -, or grouped with ().

Example Explanation foo or bar Match files with regex /foo/ or /bar/ foo -bar Match files with regex /foo/ but not /bar/ foo (bar or baz) Match files with regex /foo/ and either /bar/ or /baz/

Expressions can be prefixed with certain keywords to modify search behavior. Some keywords can be negated using the - prefix.

Prefix Description Example file: Filter results from filepaths that match the regex. By default all files are searched.
file:README file:{`"my file"`} -file:test\.ts$
repo: Filter results from repos that match the regex. By default all repos are searched.
repo:linux -repo:^web/.*
rev: Filter results from a specific branch or tag. By default only the default branch is searched.
rev:beta
lang: Filter results by language (as defined by linguist). By default all languages are searched.
lang:TypeScript -lang:YAML
sym: Match symbol definitions created by universal ctags at index time.
sym:\bmain\b
) } const Code = ({ children, className, title }: { children: React.ReactNode, className?: string, title?: string }) => { return ( {children} ) } const Highlight = ({ children }: { children: React.ReactNode }) => { return ( {children} ) }