mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Disable "copy to clipboard" and "go to definition" context menu options for Firefox addon (#17668)
This commit is contained in:
+4
-1
@@ -211,12 +211,15 @@ function createPanelIfReactLoaded() {
|
||||
browserTheme: getBrowserTheme(),
|
||||
componentsPortalContainer,
|
||||
enabledInspectedElementContextMenu: true,
|
||||
enabledInspectedElementContextMenuCopy: isChrome,
|
||||
overrideTab,
|
||||
profilerPortalContainer,
|
||||
showTabBar: false,
|
||||
store,
|
||||
warnIfUnsupportedVersionDetected: true,
|
||||
viewAttributeSourceFunction,
|
||||
viewAttributeSourceFunction: isChrome
|
||||
? viewAttributeSourceFunction
|
||||
: null,
|
||||
viewElementSourceFunction,
|
||||
}),
|
||||
);
|
||||
|
||||
+9
-6
@@ -303,6 +303,7 @@ function InspectedElementView({
|
||||
|
||||
const {
|
||||
isEnabledForInspectedElement,
|
||||
supportsCopyOperation,
|
||||
viewAttributeSourceFunction,
|
||||
} = useContext(ContextMenuContext);
|
||||
|
||||
@@ -444,12 +445,14 @@ function InspectedElementView({
|
||||
<ContextMenu id="SelectedElement">
|
||||
{data => (
|
||||
<Fragment>
|
||||
<ContextMenuItem
|
||||
onClick={() => copyInspectedElementPath(id, data.path)}
|
||||
title="Copy value to clipboard">
|
||||
<Icon className={styles.ContextMenuIcon} type="copy" /> Copy
|
||||
value to clipboard
|
||||
</ContextMenuItem>
|
||||
{supportsCopyOperation && (
|
||||
<ContextMenuItem
|
||||
onClick={() => copyInspectedElementPath(id, data.path)}
|
||||
title="Copy value to clipboard">
|
||||
<Icon className={styles.ContextMenuIcon} type="copy" /> Copy
|
||||
value to clipboard
|
||||
</ContextMenuItem>
|
||||
)}
|
||||
<ContextMenuItem
|
||||
onClick={() => storeAsGlobal(id, data.path)}
|
||||
title="Store as global variable">
|
||||
|
||||
@@ -54,6 +54,7 @@ export type Props = {|
|
||||
canViewElementSourceFunction?: ?CanViewElementSource,
|
||||
defaultTab?: TabID,
|
||||
enabledInspectedElementContextMenu?: boolean,
|
||||
enabledInspectedElementContextMenuCopy?: boolean,
|
||||
showTabBar?: boolean,
|
||||
store: Store,
|
||||
warnIfLegacyBackendDetected?: boolean,
|
||||
@@ -96,6 +97,7 @@ export default function DevTools({
|
||||
componentsPortalContainer,
|
||||
defaultTab = 'components',
|
||||
enabledInspectedElementContextMenu = false,
|
||||
enabledInspectedElementContextMenuCopy = false,
|
||||
overrideTab,
|
||||
profilerPortalContainer,
|
||||
showTabBar = false,
|
||||
@@ -121,9 +123,14 @@ export default function DevTools({
|
||||
const contextMenu = useMemo(
|
||||
() => ({
|
||||
isEnabledForInspectedElement: enabledInspectedElementContextMenu,
|
||||
supportsCopyOperation: enabledInspectedElementContextMenuCopy,
|
||||
viewAttributeSourceFunction: viewAttributeSourceFunction || null,
|
||||
}),
|
||||
[enabledInspectedElementContextMenu, viewAttributeSourceFunction],
|
||||
[
|
||||
enabledInspectedElementContextMenu,
|
||||
enabledInspectedElementContextMenuCopy,
|
||||
viewAttributeSourceFunction,
|
||||
],
|
||||
);
|
||||
|
||||
useEffect(
|
||||
|
||||
@@ -23,11 +23,13 @@ StoreContext.displayName = 'StoreContext';
|
||||
|
||||
export type ContextMenuContextType = {|
|
||||
isEnabledForInspectedElement: boolean,
|
||||
supportsCopyOperation: boolean,
|
||||
viewAttributeSourceFunction?: ?ViewAttributeSource,
|
||||
|};
|
||||
|
||||
export const ContextMenuContext = createContext<ContextMenuContextType>({
|
||||
isEnabledForInspectedElement: false,
|
||||
supportsCopyOperation: false,
|
||||
viewAttributeSourceFunction: null,
|
||||
});
|
||||
ContextMenuContext.displayName = 'ContextMenuContext';
|
||||
|
||||
@@ -56,6 +56,7 @@ inject('dist/app.js', () => {
|
||||
createElement(DevTools, {
|
||||
browserTheme: 'light',
|
||||
enabledInspectedElementContextMenu: true,
|
||||
enabledInspectedElementContextMenuCopy: true,
|
||||
showTabBar: true,
|
||||
warnIfLegacyBackendDetected: true,
|
||||
warnIfUnsupportedVersionDetected: true,
|
||||
|
||||
Reference in New Issue
Block a user