2021-02-02 22:23:42 +00:00
|
|
|
import { autoBindMethodsForReact } from 'class-autobind-decorator';
|
2021-07-22 23:04:56 +00:00
|
|
|
import React, { PureComponent } from 'react';
|
|
|
|
|
2021-02-02 22:23:42 +00:00
|
|
|
import { AUTOBIND_CFG } from '../../../common/constants';
|
2021-09-27 13:47:22 +00:00
|
|
|
import { CodeEditor, UnconnectedCodeEditor } from '../codemirror/code-editor';
|
2016-09-10 02:51:24 +00:00
|
|
|
|
2021-05-12 06:35:00 +00:00
|
|
|
interface Props {
|
2021-09-01 14:50:26 +00:00
|
|
|
value: string;
|
|
|
|
responseId?: string;
|
2021-05-12 06:35:00 +00:00
|
|
|
}
|
2021-02-02 22:23:42 +00:00
|
|
|
@autoBindMethodsForReact(AUTOBIND_CFG)
|
2021-09-27 13:47:22 +00:00
|
|
|
export class ResponseRawViewer extends PureComponent<Props> {
|
2021-09-15 13:01:35 +00:00
|
|
|
private _codeEditor?: UnconnectedCodeEditor;
|
2021-05-12 06:35:00 +00:00
|
|
|
|
2021-09-15 13:01:35 +00:00
|
|
|
_setCodeEditorRef(n: UnconnectedCodeEditor) {
|
2020-08-04 19:17:20 +00:00
|
|
|
this._codeEditor = n;
|
2016-09-10 02:51:24 +00:00
|
|
|
}
|
|
|
|
|
2018-11-30 05:52:07 +00:00
|
|
|
focus() {
|
2020-08-04 19:17:20 +00:00
|
|
|
if (this._codeEditor) {
|
|
|
|
this._codeEditor.focus();
|
2018-11-30 05:52:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
selectAll() {
|
2020-08-04 19:17:20 +00:00
|
|
|
if (this._codeEditor) {
|
|
|
|
this._codeEditor.selectAll();
|
2018-11-30 05:52:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-25 17:42:50 +00:00
|
|
|
render() {
|
2021-11-25 04:26:08 +00:00
|
|
|
const { responseId, value } = this.props;
|
2016-09-10 02:51:24 +00:00
|
|
|
return (
|
2020-08-04 19:17:20 +00:00
|
|
|
<CodeEditor
|
|
|
|
ref={this._setCodeEditorRef}
|
|
|
|
defaultValue={value}
|
|
|
|
hideLineNumbers
|
|
|
|
mode="text/plain"
|
|
|
|
noMatchBrackets
|
2016-09-10 02:51:24 +00:00
|
|
|
placeholder="..."
|
2020-08-04 19:17:20 +00:00
|
|
|
raw
|
2017-03-01 21:15:56 +00:00
|
|
|
readOnly
|
2020-08-04 19:17:20 +00:00
|
|
|
uniquenessKey={responseId}
|
2018-06-25 17:42:50 +00:00
|
|
|
/>
|
2016-09-10 02:51:24 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|