mirror of
https://github.com/zebrajr/react.git
synced 2026-01-15 12:15:22 +00:00
[DevTools] Add column number to viewSourceLineFunction (#24814)
Add column number for `viewSourceLineFunction` and renamed the function to `viewUrlSourceFunction` to match the other source function naming conventions
This commit is contained in:
@@ -255,8 +255,8 @@ function createPanelIfReactLoaded() {
|
||||
}
|
||||
};
|
||||
|
||||
const viewSourceLineFunction = (url, line) => {
|
||||
chrome.devtools.panels.openResource(url, line);
|
||||
const viewUrlSourceFunction = (url, line, col) => {
|
||||
chrome.devtools.panels.openResource(url, line, col);
|
||||
};
|
||||
|
||||
let debugIDCounter = 0;
|
||||
@@ -395,7 +395,7 @@ function createPanelIfReactLoaded() {
|
||||
warnIfUnsupportedVersionDetected: true,
|
||||
viewAttributeSourceFunction,
|
||||
viewElementSourceFunction,
|
||||
viewSourceLineFunction,
|
||||
viewUrlSourceFunction,
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
|
||||
import {createContext} from 'react';
|
||||
|
||||
import type {ViewSourceLine} from 'react-devtools-shared/src/devtools/views/DevTools';
|
||||
import type {ViewUrlSource} from 'react-devtools-shared/src/devtools/views/DevTools';
|
||||
|
||||
export type Context = {|
|
||||
viewSourceLineFunction: ViewSourceLine | null,
|
||||
viewUrlSourceFunction: ViewUrlSource | null,
|
||||
|};
|
||||
|
||||
const ViewSourceContext = createContext<Context>(((null: any): Context));
|
||||
|
||||
@@ -58,7 +58,7 @@ export type ViewElementSource = (
|
||||
id: number,
|
||||
inspectedElement: InspectedElement,
|
||||
) => void;
|
||||
export type ViewSourceLine = (url: string, row: number, column: number) => void;
|
||||
export type ViewUrlSource = (url: string, row: number, column: number) => void;
|
||||
export type ViewAttributeSource = (
|
||||
id: number,
|
||||
path: Array<string | number>,
|
||||
@@ -79,7 +79,7 @@ export type Props = {|
|
||||
warnIfUnsupportedVersionDetected?: boolean,
|
||||
viewAttributeSourceFunction?: ?ViewAttributeSource,
|
||||
viewElementSourceFunction?: ?ViewElementSource,
|
||||
viewSourceLineFunction?: ?ViewSourceLine,
|
||||
viewUrlSourceFunction?: ?ViewUrlSource,
|
||||
readOnly?: boolean,
|
||||
hideSettings?: boolean,
|
||||
hideToggleErrorAction?: boolean,
|
||||
@@ -139,7 +139,7 @@ export default function DevTools({
|
||||
warnIfUnsupportedVersionDetected = false,
|
||||
viewAttributeSourceFunction,
|
||||
viewElementSourceFunction,
|
||||
viewSourceLineFunction,
|
||||
viewUrlSourceFunction,
|
||||
readOnly,
|
||||
hideSettings,
|
||||
hideToggleErrorAction,
|
||||
@@ -205,11 +205,11 @@ export default function DevTools({
|
||||
|
||||
const viewSource = useMemo(
|
||||
() => ({
|
||||
viewSourceLineFunction: viewSourceLineFunction || null,
|
||||
viewUrlSourceFunction: viewUrlSourceFunction || null,
|
||||
// todo(blakef): Add inspect(...) method here and remove viewElementSource
|
||||
// to consolidate source code inspection.
|
||||
}),
|
||||
[viewSourceLineFunction],
|
||||
[viewUrlSourceFunction],
|
||||
);
|
||||
|
||||
const contextMenu = useMemo(
|
||||
|
||||
@@ -22,7 +22,7 @@ export type Props = {||};
|
||||
|
||||
export default function SidebarEventInfo(_: Props) {
|
||||
const {profilingData, selectedCommitIndex} = useContext(ProfilerContext);
|
||||
const {viewSourceLineFunction} = useContext(ViewSourceContext);
|
||||
const {viewUrlSourceFunction} = useContext(ViewSourceContext);
|
||||
|
||||
const {stack} = useMemo(() => {
|
||||
if (
|
||||
@@ -55,8 +55,8 @@ export default function SidebarEventInfo(_: Props) {
|
||||
const hasSource = source != null;
|
||||
|
||||
const onClick = () => {
|
||||
if (viewSourceLineFunction != null && source != null) {
|
||||
viewSourceLineFunction(...source);
|
||||
if (viewUrlSourceFunction != null && source != null) {
|
||||
viewUrlSourceFunction(...source);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user