Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

1.0 KB
Raw Blame
import { toLocalFileUrl } from '@/lib/localPathResolver';
import { activateInlineLinkFromKeyboard } from './linkInteraction';
import { useFileChipContextMenu } from './useFileChipContextMenu';

/** Bare image paths in user messages use the same file actions as Markdown references. */
export function UserMessageImageLink({
  path,
  onOpen,
}: {
  path: string;
  onOpen?: (url: string) => void;
}) {
  const fileMenu = useFileChipContextMenu({ fileName: path, getAbsPath: () => path });
  const open = () => onOpen?.(toLocalFileUrl(path));
  return (
    <>
      <span
        role="button"
        tabIndex={0}
        onClick={(event) => fileMenu.onActivate(event, open)}
        onAuxClick={(event) => {
          if (event.button === 1) fileMenu.onActivate(event, open);
        }}
        onKeyDown={activateInlineLinkFromKeyboard}
        onContextMenu={fileMenu.onContextMenu}
        className="underline underline-offset-2 cursor-pointer break-all"
      >
        {path}
      </span>
      {fileMenu.menu}
    </>
  );
}