File tree Expand file tree Collapse file tree
packages/react-devtools-extensions/src/main Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,7 +18,12 @@ import {
1818 LOCAL_STORAGE_TRACE_UPDATES_ENABLED_KEY ,
1919} from 'react-devtools-shared/src/constants' ;
2020import { logEvent } from 'react-devtools-shared/src/Logger' ;
21- import { normalizeUrlIfValid } from 'react-devtools-shared/src/utils' ;
21+ import {
22+ getAlwaysOpenInEditor ,
23+ getOpenInEditorURL ,
24+ normalizeUrlIfValid ,
25+ } from 'react-devtools-shared/src/utils' ;
26+ import { checkConditions } from 'react-devtools-shared/src/devtools/views/Editor/utils' ;
2227
2328import {
2429 setBrowserSelectionFromReact ,
@@ -530,3 +535,29 @@ if (__IS_FIREFOX__) {
530535connectExtensionPort ( ) ;
531536
532537mountReactDevToolsWhenReactHasLoaded ( ) ;
538+
539+ chrome . devtools . panels . setOpenResourceHandler (
540+ (
541+ resource ,
542+ lineNumber = 1 ,
543+ // The column is a new feature so we have to specify a default if it doesn't exist
544+ columnNumber = 1 ,
545+ ) => {
546+ const alwaysOpenInEditor = getAlwaysOpenInEditor ( ) ;
547+ const editorURL = getOpenInEditorURL ( ) ;
548+ if ( alwaysOpenInEditor && editorURL ) {
549+ const location = [ '' , resource . url , lineNumber , columnNumber ] ;
550+ const { url, shouldDisableButton} = checkConditions ( editorURL , location ) ;
551+ if ( ! shouldDisableButton ) {
552+ window . open ( url ) ;
553+ return ;
554+ }
555+ }
556+ // Otherwise fallback to the built-in behavior.
557+ chrome . devtools . panels . openResource (
558+ resource . url ,
559+ lineNumber - 1 ,
560+ columnNumber - 1 ,
561+ ) ;
562+ } ,
563+ ) ;
You can’t perform that action at this time.
0 commit comments