File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 175175 "date-fns" : " ^2.30.0" ,
176176 "es-module-lexer" : " ^1.4.1" ,
177177 "react-diff-viewer-continued" : " ^3.3.1" ,
178+ "react-hotkeys-hook" : " ^4.5.0" ,
178179 "tailwind-merge" : " ^1.14.0" ,
179180 "uuid" : " ^9.0.1" ,
180181 "zod" : " ^3.22.4"
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ import { useAttachBodyListener } from "./hooks/useAttachListener.js";
2727import { useDebounce } from "./hooks/useDebounce.js" ;
2828import { useListenToRouteChange } from "./hooks/detached/useListenToRouteChange.js" ;
2929import { RdtPlugin } from "../index.js" ;
30+ import { useHotkeys } from "react-hotkeys-hook" ;
3031
3132const DevTools = ( { plugins : pluginArray } : RemixDevToolsProps ) => {
3233 useTimelineHandler ( ) ;
@@ -48,15 +49,10 @@ const DevTools = ({ plugins: pluginArray }: RemixDevToolsProps) => {
4849 const leftSideOriented = position . includes ( "left" ) ;
4950 const plugins = pluginArray ?. map ( ( plugin ) => ( typeof plugin === "function" ? plugin ( ) : plugin ) ) ;
5051 const debounceSetOpen = useDebounce ( ( ) => { setIsOpen ( ! isOpen ) ; setPersistOpen ( ! isOpen ) } , 100 ) ;
51- useAttachBodyListener ( "keydown" , ( e : any ) => {
52-
53- if ( isOpen && e . key === "Escape" ) {
54- debounceSetOpen ( ) ;
55- }
56- if ( e . shiftKey && e . key . toLowerCase ( ) === "a" ) {
57- debounceSetOpen ( ) ;
58- }
59- } ) ;
52+ useHotkeys ( settings . openHotkey , ( ) => debounceSetOpen ( ) ) ;
53+ useHotkeys ( "esc" , ( ) => isOpen ? debounceSetOpen ( ) : null ) ;
54+
55+
6056
6157 if ( settings . requireUrlFlag && ! url . includes ( settings . urlFlag ) ) return null ;
6258 // If the dev tools are detached, we don't want to render the main panel
Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ export type RemixDevToolsState = {
8686 routeViewMode : "list" | "tree" ;
8787 panelLocation : "top" | "bottom" ;
8888 withServerDevTools : boolean ;
89-
89+ openHotkey : string ;
9090 requireUrlFlag : boolean ;
9191 urlFlag : string ;
9292 } ;
@@ -119,7 +119,7 @@ export const initialState: RemixDevToolsState = {
119119 routeViewMode : "tree" ,
120120 panelLocation : "bottom" ,
121121 withServerDevTools : true ,
122-
122+ openHotkey : "shift+a" ,
123123 requireUrlFlag : false ,
124124 urlFlag : "rdt" ,
125125 } ,
@@ -219,6 +219,7 @@ type SetHtmlErrors = {
219219 payload : HTMLError [ ] ;
220220} ;
221221
222+
222223/** Aggregate of all action types */
223224export type RemixDevToolsActions =
224225 | SetTimelineEvent
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ export const SettingsTab = () => {
1212 const [ minHeight , setMinHeight ] = useState ( settings . minHeight . toString ( ) ) ;
1313 const [ maxHeight , setMaxHeight ] = useState ( settings . maxHeight . toString ( ) ) ;
1414 const [ expansionLevel , setExpansionLevel ] = useState ( settings . expansionLevel . toString ( ) ) ;
15+ const [ openHotkey , setOpenHotkey ] = useState ( settings . openHotkey . toString ( ) ) ;
1516
1617 return (
1718 < Stack className = "rdt-mb-4" >
@@ -74,6 +75,20 @@ export const SettingsTab = () => {
7475 }
7576 } }
7677 />
78+ < Input
79+ name = "openHotkey"
80+ id = "openHotkey"
81+ label = "Depth of expansion for JSON objects"
82+ hint = "This allows you to change the depth of expanded properties of json objects."
83+ value = { openHotkey }
84+ onChange = { ( e ) => setOpenHotkey ( e . target . value ?? "" ) }
85+ onBlur = { ( e ) => {
86+ const value = ( e . target . value ) ;
87+ if ( value ) {
88+ setSettings ( { openHotkey : value } ) ;
89+ }
90+ } }
91+ />
7792 < div className = "rdt-flex rdt-flex-col rdt-gap-2 lg:rdt-flex-row" >
7893 < Input
7994 name = "minHeight"
Original file line number Diff line number Diff line change @@ -165,7 +165,7 @@ export const remixDevTools: (args?:RemixViteConfig) => Plugin[] = (args) => {
165165
166166 return updatedCode ;
167167 }
168- if ( id . endsWith ( "/root.tsx" ) ) {
168+ if ( id . endsWith ( "/root.tsx" ) || id . endsWith ( "/root.jsx" ) ) {
169169 const [ , exports ] = parse ( code ) ;
170170 const exportNames = exports . map ( ( e ) => e . n ) ;
171171 const hasLinksExport = exportNames . includes ( "links" ) ;
You can’t perform that action at this time.
0 commit comments