@@ -47,7 +47,14 @@ import {
4747import { mediaFileReference } from "@t3tools/client-runtime/media-reference" ;
4848import { FolderTree , Globe2 , WrapTextIcon } from "lucide-react" ;
4949import * as Schema from "effect/Schema" ;
50- import { lazy , Suspense , useEffect , useRef , useState } from "react" ;
50+ import {
51+ lazy ,
52+ Suspense ,
53+ useEffect ,
54+ useRef ,
55+ useState ,
56+ type KeyboardEvent as ReactKeyboardEvent ,
57+ } from "react" ;
5158
5259import { isBrowserPreviewFile , openFileInPreview } from "~/browser/openFileInPreview" ;
5360import { useAssetUrlRefresh , useAssetUrlState } from "~/assets/assetUrls" ;
@@ -61,7 +68,7 @@ import { useStableCallback } from "~/hooks/useStableCallback";
6168import { getLocalStorageItem , setLocalStorageItem , useLocalStorage } from "~/hooks/useLocalStorage" ;
6269import { resolveDiffThemeName } from "~/lib/diffRendering" ;
6370import { PREFERRED_HIGHLIGHTER } from "~/lib/syntaxHighlighting" ;
64- import { cn } from "~/lib/utils" ;
71+ import { cn , isMacPlatform } from "~/lib/utils" ;
6572import { requestWorkspaceFocus } from "~/lib/workspaceFocus" ;
6673import type { ChatFileAttachment } from "~/types" ;
6774import { isHostPath } from "@t3tools/shared/path" ;
@@ -933,6 +940,25 @@ function EditableFileSurface({
933940 ) ;
934941}
935942
943+ function selectRenderedContentOnSelectAll ( event : ReactKeyboardEvent < HTMLElement > ) {
944+ const mac = isMacPlatform ( navigator . platform ) ;
945+ const selectAll =
946+ event . key . toLowerCase ( ) === "a" &&
947+ ( mac ? event . metaKey && ! event . ctrlKey : event . ctrlKey && ! event . metaKey ) &&
948+ ! event . shiftKey &&
949+ ! event . altKey ;
950+ // React bubbles keys from portaled children (the image dialog) through this surface.
951+ if (
952+ ! selectAll ||
953+ ! ( event . target instanceof Node ) ||
954+ ! event . currentTarget . contains ( event . target )
955+ ) {
956+ return ;
957+ }
958+ event . preventDefault ( ) ;
959+ window . getSelection ( ) ?. selectAllChildren ( event . currentTarget ) ;
960+ }
961+
936962function RenderedMarkdownSurface ( {
937963 environmentId,
938964 cwd,
@@ -960,7 +986,7 @@ function RenderedMarkdownSurface({
960986 useFileSaveSession ( saveTarget , onPendingChange ) ;
961987
962988 return (
963- < ScrollArea className = "min-h-0 flex-1" >
989+ < ScrollArea className = "min-h-0 flex-1" onKeyDown = { selectRenderedContentOnSelectAll } >
964990 < FileMarkdownPreview
965991 text = { contents }
966992 cwd = { cwd }
0 commit comments