fix: restore text selection and copy in read-only CodeEditor (#5983)

Fixes #5982

Changed CodeMirror readOnly option from 'nocursor' to boolean true
to allow text selection while maintaining read-only behavior.
Removed CSS rules that prevented text selection (user-select: none)
in read-only mode.

This restores the ability to copy text from the Response panel using
Ctrl+C or right-click context menu, which was broken in nightly builds
after v2.13.2.
This commit is contained in:
DrChiodo
2025-11-05 14:47:20 +01:00
committed by GitHub
parent bdc8f391b7
commit 2deee11718
2 changed files with 2 additions and 8 deletions

View File

@@ -2,12 +2,6 @@ import styled from 'styled-components';
const StyledWrapper = styled.div`
&.read-only {
div.CodeMirror .CodeMirror-lines {
user-select: none !important;
-webkit-user-select: none !important;
-ms-user-select: none !important;
}
div.CodeMirror .CodeMirror-cursor {
display: none !important;
}

View File

@@ -63,7 +63,7 @@ export default class CodeEditor extends React.Component {
foldGutter: true,
gutters: ['CodeMirror-linenumbers', 'CodeMirror-foldgutter', 'CodeMirror-lint-markers'],
lint: this.lintOptions,
readOnly: this.props.readOnly ? 'nocursor' : false,
readOnly: !!this.props.readOnly,
scrollbarStyle: 'overlay',
theme: this.props.theme === 'dark' ? 'monokai' : 'default',
extraKeys: {
@@ -246,7 +246,7 @@ export default class CodeEditor extends React.Component {
}
if (this.props.readOnly !== prevProps.readOnly && this.editor) {
this.editor.setOption('readOnly', this.props.readOnly ? 'nocursor' : false);
this.editor.setOption('readOnly', !!this.props.readOnly);
}
this.ignoreChangeEvent = false;