@@ -15,7 +15,8 @@ import { getPreviewSetup } from "~/utilities/codeMirrorSetup";
15
15
import { lightTheme , darkTheme } from "~/utilities/codeMirrorTheme" ;
16
16
import { CopyTextButton } from "./CopyTextButton" ;
17
17
import { useTheme } from "./ThemeProvider" ;
18
- import { usePreferences } from '~/components/PreferencesProvider'
18
+ import { usePreferences } from '~/components/PreferencesProvider' ;
19
+ import { useHotkeys } from "react-hotkeys-hook" ;
19
20
20
21
export type JsonPreviewProps = {
21
22
json : unknown ;
@@ -56,7 +57,7 @@ export function JsonPreview({ json, highlightPath }: JsonPreviewProps) {
56
57
57
58
const [ theme ] = useTheme ( ) ;
58
59
59
- const { setContainer, view } = useCodeMirror ( {
60
+ const { setContainer, view, state } = useCodeMirror ( {
60
61
container : editor . current ,
61
62
extensions,
62
63
value : jsonMapped . json ,
@@ -92,6 +93,15 @@ export function JsonPreview({ json, highlightPath }: JsonPreviewProps) {
92
93
view . dispatch ( transactionSpec ) ;
93
94
} , [ view , highlighting , jsonMapped , highlightPath ] ) ;
94
95
96
+ useHotkeys (
97
+ "ctrl+a,meta+a,command+a" ,
98
+ ( e ) => {
99
+ e . preventDefault ( ) ;
100
+ view ?. dispatch ( { selection : { anchor : 0 , head : state ?. doc . length } } ) ;
101
+ } ,
102
+ [ view , state ]
103
+ ) ;
104
+
95
105
const [ hovering , setHovering ] = useState ( false ) ;
96
106
97
107
return (
0 commit comments