disable context menu override (#7431)

This commit is contained in:
Jack Kavanagh 2024-05-21 19:14:52 +02:00 committed by GitHub
parent cb7e5896c4
commit 7abe25c3f2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 2 deletions

View File

@ -103,6 +103,7 @@ export interface CodeEditorProps {
// NOTE: for caching scroll and marks
uniquenessKey?: string;
updateFilter?: (filter: string) => void;
disableContextMenu?: boolean;
}
const normalizeMimeType = (mode?: string) => {
@ -171,6 +172,7 @@ export const CodeEditor = memo(forwardRef<CodeEditorHandle, CodeEditorProps>(({
style,
uniquenessKey,
updateFilter,
disableContextMenu,
}, ref) => {
const inputRef = useRef<HTMLInputElement>(null);
const textAreaRef = useRef<HTMLTextAreaElement>(null);
@ -570,7 +572,7 @@ export const CodeEditor = memo(forwardRef<CodeEditorHandle, CodeEditorProps>(({
data-editor-type="text"
data-testid="CodeEditor"
onContextMenu={event => {
if (readOnly) {
if (readOnly || disableContextMenu) {
return;
}
event.preventDefault();

View File

@ -201,11 +201,11 @@ export const PreRequestScriptEditor: FC<Props> = ({
<CodeEditor
key={uniquenessKey}
id="pre-request-script-editor"
disableContextMenu={true}
showPrettifyButton={true}
uniquenessKey={uniquenessKey}
defaultValue={defaultValue}
className={className}
// enableNunjucks
onChange={onChange}
mode='text/javascript'
placeholder="..."