fix: response is unable to be copied (#5995)

* fix: response is unable to be copied

* fix: enable selection of text on readonly

* fix: no cursor when readonly
This commit is contained in:
sanish chirayath
2025-11-05 20:17:09 +05:30
committed by GitHub
parent 60b437ef9d
commit fa28ab9b50
5 changed files with 10 additions and 15 deletions

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,
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);
this.editor.setOption('readOnly', this.props.readOnly);
}
this.ignoreChangeEvent = false;

View File

@@ -9,14 +9,15 @@ const StyledWrapper = styled.div`
&.read-only {
.CodeMirror .CodeMirror-lines {
cursor: not-allowed !important;
user-select: none !important;
-webkit-user-select: none !important;
-ms-user-select: none !important;
}
.CodeMirror-line {
color: ${(props) => props.theme.colors.text.muted} !important;
}
.CodeMirror-cursor {
display: none !important;
}
}
.CodeMirror {

View File

@@ -36,7 +36,7 @@ class MultiLineEditor extends Component {
brunoVarInfo: {
variables
},
readOnly: this.props.readOnly ? 'nocursor' : false,
readOnly: this.props.readOnly,
tabindex: 0,
extraKeys: {
'Ctrl-Enter': () => {
@@ -132,7 +132,7 @@ class MultiLineEditor extends Component {
this.editor.setOption('theme', this.props.theme === 'dark' ? 'monokai' : 'default');
}
if (this.props.readOnly !== prevProps.readOnly && this.editor) {
this.editor.setOption('readOnly', this.props.readOnly ? 'nocursor' : false);
this.editor.setOption('readOnly', this.props.readOnly);
}
if (this.props.value !== prevProps.value && this.props.value !== this.cachedValue && this.editor) {
this.cachedValue = String(this.props.value);

View File

@@ -7,12 +7,6 @@ const StyledWrapper = styled.div`
overflow-x: hidden;
&.read-only {
.CodeMirror .CodeMirror-lines {
user-select: none !important;
-webkit-user-select: none !important;
-ms-user-select: none !important;
}
.CodeMirror-cursor {
display: none !important;
}

View File

@@ -53,7 +53,7 @@ class SingleLineEditor extends Component {
},
scrollbarStyle: null,
tabindex: 0,
readOnly: this.props.readOnly ? 'nocursor' : false,
readOnly: this.props.readOnly,
extraKeys: {
Enter: runHandler,
'Ctrl-Enter': runHandler,
@@ -153,7 +153,7 @@ class SingleLineEditor extends Component {
this.setState({ maskInput: this.props.isSecret });
}
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;
}