@@ -16,7 +16,10 @@ import {
16
16
useRef ,
17
17
useState ,
18
18
} from 'react' ;
19
- import { LOCAL_STORAGE_OPEN_IN_EDITOR_URL } from '../../../constants' ;
19
+ import {
20
+ LOCAL_STORAGE_OPEN_IN_EDITOR_URL ,
21
+ LOCAL_STORAGE_OPEN_IN_EDITOR_URL_PRESET ,
22
+ } from '../../../constants' ;
20
23
import { useLocalStorage , useSubscription } from '../hooks' ;
21
24
import { StoreContext } from '../context' ;
22
25
import Button from '../Button' ;
@@ -51,6 +54,8 @@ import type {
51
54
RegExpComponentFilter ,
52
55
} from 'react-devtools-shared/src/types' ;
53
56
57
+ const vscodeFilepath = 'vscode://file/{path}:{line}' ;
58
+
54
59
export default function ComponentsSettings ( _ : { } ) : React . Node {
55
60
const store = useContext ( StoreContext ) ;
56
61
const { parseHookNames, setParseHookNames} = useContext ( SettingsContext ) ;
@@ -83,6 +88,10 @@ export default function ComponentsSettings(_: {}): React.Node {
83
88
[ setParseHookNames ] ,
84
89
) ;
85
90
91
+ const [ openInEditorURLPreset , setOpenInEditorURLPreset ] = useLocalStorage <
92
+ 'vscode' | 'custom' ,
93
+ > ( LOCAL_STORAGE_OPEN_IN_EDITOR_URL_PRESET , 'custom ');
94
+
86
95
const [ openInEditorURL , setOpenInEditorURL ] = useLocalStorage < string > (
87
96
LOCAL_STORAGE_OPEN_IN_EDITOR_URL ,
88
97
getDefaultOpenInEditorURL ( ) ,
@@ -280,15 +289,32 @@ export default function ComponentsSettings(_: {}): React.Node {
280
289
281
290
< label className = { styles . OpenInURLSetting } >
282
291
Open in Editor URL:{ ' ' }
283
- < input
284
- className = { styles . Input }
285
- type = "text"
286
- placeholder = { process . env . EDITOR_URL ?? 'vscode://file/{path}:{line}' }
287
- value = { openInEditorURL }
288
- onChange = { event => {
289
- setOpenInEditorURL ( event . target . value ) ;
290
- } }
291
- />
292
+ < select
293
+ className = { styles . Select }
294
+ value = { openInEditorURLPreset }
295
+ onChange = { ( { currentTarget} ) => {
296
+ const selectedValue = currentTarget . value ;
297
+ setOpenInEditorURLPreset ( selectedValue ) ;
298
+ if ( selectedValue === 'vscode' ) {
299
+ setOpenInEditorURL ( vscodeFilepath ) ;
300
+ } else if ( selectedValue === 'custom' ) {
301
+ setOpenInEditorURL ( '' ) ;
302
+ }
303
+ } } >
304
+ < option value = "vscode" > VS Code</ option >
305
+ < option value = "custom" > Custom</ option >
306
+ </ select >
307
+ { openInEditorURLPreset === 'custom' && (
308
+ < input
309
+ className = { styles . Input }
310
+ type = "text"
311
+ placeholder = { process . env . EDITOR_URL ? process . env . EDITOR_URL : '' }
312
+ value = { openInEditorURL }
313
+ onChange = { event => {
314
+ setOpenInEditorURL ( event . target . value ) ;
315
+ } }
316
+ />
317
+ ) }
292
318
</ label >
293
319
294
320
< div className = { styles . Header } > Hide components where...</ div >
0 commit comments