insomnia/packages/insomnia-app/app/ui/components/viewers/response-raw-viewer.tsx

48 lines
1.0 KiB
TypeScript
Raw Normal View History

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